From f375ecdce3586627c81665307b8f959abfddb769 Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Sat, 20 Aug 2016 20:21:43 +0100 Subject: Add key expiry time to the comment --- cmd/cashier/client_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cmd/cashier/client_test.go') diff --git a/cmd/cashier/client_test.go b/cmd/cashier/client_test.go index b82d78f..dcf674b 100644 --- a/cmd/cashier/client_test.go +++ b/cmd/cashier/client_test.go @@ -9,6 +9,7 @@ import ( "net/http" "net/http/httptest" "testing" + "time" "github.com/nsheridan/cashier/lib" "github.com/nsheridan/cashier/testdata" @@ -22,6 +23,7 @@ func TestLoadCert(t *testing.T) { key := priv.(*rsa.PrivateKey) pub, _ := ssh.NewPublicKey(&key.PublicKey) c := &ssh.Certificate{ + KeyId: "test_key_12345", Key: pub, CertType: ssh.UserCert, ValidBefore: ssh.CertTimeInfinity, @@ -46,6 +48,13 @@ func TestLoadCert(t *testing.T) { if !bytes.Equal(listedKeys[0].Marshal(), c.Marshal()) { t.Fatal("Certs not equal") } + for _, k := range listedKeys { + exp := time.Unix(int64(c.ValidBefore), 0).String() + want := fmt.Sprintf("%s [Expires %s]", c.KeyId, exp) + if k.Comment != want { + t.Errorf("key comment:\nwanted:%s\ngot: %s", want, k.Comment) + } + } } func TestSignGood(t *testing.T) { -- cgit v1.2.3