From 1c003474d48c2ae5275d5445816156b42fdb9d77 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Wed, 25 Nov 2020 13:32:11 +0100 Subject: added get-anchors response test --- reqres_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/reqres_test.go b/reqres_test.go index e53ed69..7d6b714 100644 --- a/reqres_test.go +++ b/reqres_test.go @@ -6,7 +6,10 @@ import ( "strconv" "testing" + "crypto/x509" "net/http" + + "github.com/system-transparency/stfe/testdata" ) // TODO: TestNewAddEntryRequest @@ -225,8 +228,16 @@ func TestNewGetConsistencyProofRequest(t *testing.T) { func TestNewGetEntriesResponse(t *testing.T) { } -// TODO: TestNewGetAnchorsResponse func TestNewGetAnchorsResponse(t *testing.T) { + rawAnchors := makeTestLogParameters(t, nil).newGetAnchorsResponse() + if got, want := len(rawAnchors), testdata.NumPemAnchors; got != want { + t.Errorf("got %d anchors but wanted %d", got, want) + } + for _, rawAnchor := range rawAnchors { + if _, err := x509.ParseCertificate(rawAnchor); err != nil { + t.Errorf("invalid trust anchor %X: %v", rawAnchor, err) + } + } } func mustParseInt64(t *testing.T, num string) int64 { -- cgit v1.2.3