aboutsummaryrefslogtreecommitdiff
path: root/x509util
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-25 17:44:39 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-25 17:44:39 +0100
commita67b1277a0ea25eef33fb89cce1b1252a9491544 (patch)
tree5f282a418b05ada679487e635ef8562b7fd95036 /x509util
parentfc1e8266b3701977701e8367184ac2ebafeee5ca (diff)
added NewCertPool tests
Diffstat (limited to 'x509util')
-rw-r--r--x509util/x509util_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/x509util/x509util_test.go b/x509util/x509util_test.go
index 8595360..4ef743c 100644
--- a/x509util/x509util_test.go
+++ b/x509util/x509util_test.go
@@ -1,8 +1,11 @@
package x509util
import (
+ "bytes"
"fmt"
"testing"
+
+ "github.com/system-transparency/stfe/testdata"
)
func TestNewEd25519PrivateKey(t *testing.T) {
@@ -211,6 +214,24 @@ Vc510vi4dM8I+e/vcoBsmMQP
}
func TestNewCertPool(t *testing.T) {
+ for i, chain := range [][]byte{
+ testdata.FirstPemChain,
+ testdata.SecondPemChain,
+ } {
+ list, err := NewCertificateList(chain)
+ if err != nil {
+ t.Fatalf("must parse chain: %v", err)
+ }
+ pool := NewCertPool(list)
+ if got, want := len(pool.Subjects()), len(list); got != want {
+ t.Errorf("got pool of size %d but wanted %d in test %d", got, want, i)
+ }
+ for j, got := range pool.Subjects() {
+ if want := list[j].RawSubject; !bytes.Equal(got, want) {
+ t.Errorf("got subject[%d]=%X but wanted %X in test %d", j, got, want, i)
+ }
+ }
+ }
}
func TestParseDerChain(t *testing.T) {