aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-25 13:32:11 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-25 13:32:11 +0100
commit1c003474d48c2ae5275d5445816156b42fdb9d77 (patch)
treea85fcc0c73181296c1626e09877e6bf13a7d65bb
parent65e2a7826b5be53fefa18629eeba525d1d3bcbf3 (diff)
added get-anchors response test
-rw-r--r--reqres_test.go13
1 files changed, 12 insertions, 1 deletions
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 {