ocsp: add Request.Marshal method

Tests that Marshaling a parsed response
returns the same bytes as were parsed.

Use Marshal in CreateRequest;
still passes CreateRequest's golden test.

Change-Id: I427ef8372d7b62c43b7718d7d90631d022377d32
Reviewed-on: https://go-review.googlesource.com/19488
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Roland Shoemaker
2016-10-06 17:46:04 +00:00
committed by Russ Cox
parent 7682e7e394
commit 0e69e08b8a
2 changed files with 56 additions and 20 deletions
+13
View File
@@ -159,6 +159,19 @@ func TestOCSPRequest(t *testing.T) {
if got := decodedRequest.SerialNumber; got.Cmp(cert.SerialNumber) != 0 {
t.Errorf("request.SerialNumber: got %x, want %x", got, cert.SerialNumber)
}
marshaledRequest, err := decodedRequest.Marshal()
if err != nil {
t.Fatal(err)
}
if bytes.Compare(expectedBytes, marshaledRequest) != 0 {
t.Errorf(
"Marshaled request doesn't match expected: wanted %x, got %x",
expectedBytes,
marshaledRequest,
)
}
}
func TestOCSPResponse(t *testing.T) {