aboutsummaryrefslogtreecommitdiff
path: root/server/signer/signer_test.go
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2016-07-31 20:41:52 +0100
committerNiall Sheridan <nsheridan@gmail.com>2016-07-31 21:18:55 +0100
commit531f63e5a9e82d86a6ee1f5d44bebee0bc51d828 (patch)
tree882b6dfb10c4db96b9e983fd6112a29d227a416a /server/signer/signer_test.go
parent44fef1c2a163bdfd781ef08a06e3cf5cf9b7d5da (diff)
Use a KRL for revoked certs
Diffstat (limited to 'server/signer/signer_test.go')
-rw-r--r--server/signer/signer_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/server/signer/signer_test.go b/server/signer/signer_test.go
index a80e64a..9c76f4b 100644
--- a/server/signer/signer_test.go
+++ b/server/signer/signer_test.go
@@ -7,7 +7,9 @@ import (
"time"
"github.com/nsheridan/cashier/lib"
+ "github.com/nsheridan/cashier/server/store"
"github.com/nsheridan/cashier/testdata"
+ "github.com/stripe/krl"
"golang.org/x/crypto/ssh"
)
@@ -49,3 +51,32 @@ func TestCert(t *testing.T) {
t.Fatalf("Invalid validity, expected %d, got %d", r.ValidUntil, cert.ValidBefore)
}
}
+
+func TestRevocationList(t *testing.T) {
+ r := &lib.SignRequest{
+ Key: string(testdata.Pub),
+ Principal: "revoked",
+ ValidUntil: time.Now().Add(1 * time.Hour),
+ }
+ cert1, _ := signer.SignUserKey(r)
+ r.Principal = "ok"
+ cert2, _ := signer.SignUserKey(r)
+ var rec []*store.CertRecord
+ rec = append(rec, &store.CertRecord{
+ KeyID: cert1.KeyId,
+ })
+ rl, err := signer.GenerateRevocationList(rec)
+ if err != nil {
+ t.Error(err)
+ }
+ k, err := krl.ParseKRL(rl)
+ if err != nil {
+ t.Error(err)
+ }
+ if !k.IsRevoked(cert1) {
+ t.Errorf("expected cert %s to be revoked", cert1.KeyId)
+ }
+ if k.IsRevoked(cert2) {
+ t.Errorf("cert %s should not be revoked", cert2.KeyId)
+ }
+}