Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1037)

Delta Between Two Patch Sets: ocsp/ocsp_test.go

Issue 5564059: code review 5564059: go.crypto: initial code (Closed)
Left Patch Set: Created 12 years, 2 months ago
Right Patch Set: diff -r b50a7fb49394 https://code.google.com/p/go.crypto Created 12 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « ocsp/ocsp.go ('k') | openpgp/armor/armor.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package ocsp
6
7 import (
8 "bytes"
9 "encoding/hex"
10 "reflect"
11 "testing"
12 "time"
13 )
14
15 func TestOCSPDecode(t *testing.T) {
16 responseBytes, _ := hex.DecodeString(ocspResponseHex)
17 resp, err := ParseResponse(responseBytes)
18 if err != nil {
19 t.Error(err)
20 }
21
22 expected := Response{
23 Status: 0,
24 SerialNumber: []byte{0x1, 0xd0, 0xfa},
25 RevocationReason: 0,
26 ThisUpdate: time.Date(2010, 7, 7, 15, 1, 5, 0, time.UTC),
27 NextUpdate: time.Date(2010, 7, 7, 18, 35, 17, 0, time.UTC) ,
28 }
29
30 if !reflect.DeepEqual(resp.ThisUpdate, expected.ThisUpdate) {
31 t.Errorf("resp.ThisUpdate: got %d, want %d", resp.ThisUpdate, ex pected.ThisUpdate)
32 }
33
34 if !reflect.DeepEqual(resp.NextUpdate, expected.NextUpdate) {
35 t.Errorf("resp.NextUpdate: got %d, want %d", resp.NextUpdate, ex pected.NextUpdate)
36 }
37
38 if resp.Status != expected.Status {
39 t.Errorf("resp.Status: got %d, want %d", resp.Status, expected.S tatus)
40 }
41
42 if !bytes.Equal(resp.SerialNumber, expected.SerialNumber) {
43 t.Errorf("resp.SerialNumber: got %x, want %x", resp.SerialNumber , expected.SerialNumber)
44 }
45
46 if resp.RevocationReason != expected.RevocationReason {
47 t.Errorf("resp.RevocationReason: got %d, want %d", resp.Revocati onReason, expected.RevocationReason)
48 }
49 }
50
51 // This OCSP response was taken from Thawte's public OCSP responder.
52 // To recreate:
53 // $ openssl s_client -tls1 -showcerts -servername www.google.com -connect www .google.com:443
54 // Copy and paste the first certificate into /tmp/cert.crt and the second into
55 // /tmp/intermediate.crt
56 // $ openssl ocsp -issuer /tmp/intermediate.crt -cert /tmp/cert.crt -url http: //ocsp.thawte.com -resp_text -respout /tmp/ocsp.der
57 // Then hex encode the result:
58 // $ python -c 'print file("/tmp/ocsp.der", "r").read().encode("hex")'
59
60 const ocspResponseHex = "308206bc0a0100a08206b5308206b106092b0601050507300101048 206a23082069e3081" +
61 "c9a14e304c310b300906035504061302494c31163014060355040a130d5374617274436 f" +
62 "6d204c74642e312530230603550403131c5374617274436f6d20436c6173732031204f4 3" +
63 "5350205369676e6572180f32303130303730373137333531375a30663064303c3009060 5" +
64 "2b0e03021a050004146568874f40750f016a3475625e1f5c93e5a26d580414eb4234d09 8" +
65 "b0ab9ff41b6b08f7cc642eef0e2c45020301d0fa8000180f32303130303730373135303 1" +
66 "30355aa011180f32303130303730373138333531375a300d06092a864886f70d0101050 5" +
67 "000382010100ab557ff070d1d7cebbb5f0ec91a15c3fed22eb2e1b8244f1b84545f013a 4" +
68 "fb46214c5e3fbfbebb8a56acc2b9db19f68fd3c3201046b3824d5ba689f99864328710c b" +
69 "467195eb37d84f539e49f859316b32964dc3e47e36814ce94d6c56dd02733b1d0802f7f f" +
70 "4eebdbbd2927dcf580f16cbc290f91e81b53cb365e7223f1d6e20a88ea064104875e014 5" +
71 "672b20fc14829d51ca122f5f5d77d3ad6c83889c55c7dc43680ba2fe3cef8b05dbcabdc 0" +
72 "d3e09aaf9725597f8c858c2fa38c0d6aed2e6318194420dd1a1137445d13e1c97ab4789 6" +
73 "17a4e08925f46f867b72e3a4dc1f08cb870b2b0717f7207faa0ac512e628a029aba7457 a" +
74 "e63dcf3281e2162d9349a08204ba308204b6308204b23082039aa003020102020101300 d" +
75 "06092a864886f70d010105050030818c310b300906035504061302494c3116301406035 5" +
76 "040a130d5374617274436f6d204c74642e312b3029060355040b1322536563757265204 4" +
77 "69676974616c204365727469666963617465205369676e696e673138303606035504031 3" +
78 "2f5374617274436f6d20436c6173732031205072696d61727920496e7465726d6564696 1" +
79 "746520536572766572204341301e170d3037313032353030323330365a170d313231303 2" +
80 "333030323330365a304c310b300906035504061302494c31163014060355040a130d537 4" +
81 "617274436f6d204c74642e312530230603550403131c5374617274436f6d20436c61737 3" +
82 "2031204f435350205369676e657230820122300d06092a864886f70d010101050003820 1" +
83 "0f003082010a0282010100b9561b4c45318717178084e96e178df2255e18ed8d8ecc7c2 b" +
84 "7b51a6c1c2e6bf0aa3603066f132fe10ae97b50e99fa24b83fc53dd2777496387d14e1c 3" +
85 "a9b6a4933e2ac12413d085570a95b8147414a0bc007c7bcf222446ef7f1a156d7ea1c57 7" +
86 "fc5f0facdfd42eb0f5974990cb2f5cefebceef4d1bdc7ae5c1075c5a99a93171f2b0845 b" +
87 "4ff0864e973fcfe32f9d7511ff87a3e943410c90a4493a306b6944359340a9ca96f02b6 6" +
88 "ce67f028df2980a6aaee8d5d5d452b8b0eb93f923cc1e23fcccbdbe7ffcb114d08fa7a6 a" +
89 "3c404f825d1a0e715935cf623a8c7b59670014ed0622f6089a9447a7a19010f7fe58f84 1" +
90 "29a2765ea367824d1c3bb2fda308530203010001a382015c30820158300c0603551d130 1" +
91 "01ff04023000300b0603551d0f0404030203a8301e0603551d250417301506082b06010 5" +
92 "0507030906092b0601050507300105301d0603551d0e0416041445e0a36695414c5dd44 9" +
93 "bc00e33cdcdbd2343e173081a80603551d230481a030819d8014eb4234d098b0ab9ff41 b" +
94 "6b08f7cc642eef0e2c45a18181a47f307d310b300906035504061302494c31163014060 3" +
95 "55040a130d5374617274436f6d204c74642e312b3029060355040b13225365637572652 0" +
96 "4469676974616c204365727469666963617465205369676e696e6731293027060355040 3" +
97 "13205374617274436f6d2043657274696669636174696f6e20417574686f72697479820 1" +
98 "0a30230603551d12041c301a8618687474703a2f2f7777772e737461727473736c2e636 f" +
99 "6d2f302c06096086480186f842010d041f161d5374617274436f6d205265766f6361746 9" +
100 "6f6e20417574686f72697479300d06092a864886f70d01010505000382010100182d221 5" +
101 "8f0fc0291324fa8574c49bb8ff2835085adcbf7b7fc4191c397ab6951328253fffe1e5e c" +
102 "2a7da0d50fca1a404e6968481366939e666c0a6209073eca57973e2fefa9ed1718e8176 f" +
103 "1d85527ff522c08db702e3b2b180f1cbff05d98128252cf0f450f7dd2772f4188047f19 d" +
104 "c85317366f94bc52d60f453a550af58e308aaab00ced33040b62bf37f5b1ab2a4f7f0f8 0" +
105 "f763bf4d707bc8841d7ad9385ee2a4244469260b6f2bf085977af9074796048ecc2f9d4 8" +
106 "a1d24ce16e41a9941568fec5b42771e118f16c106a54ccc339a4b02166445a167902e75 e" +
107 "6d8620b0825dcd18a069b90fd851d10fa8effd409deec02860d26d8d833f304b10669b4 2"
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b