Skip to content

Commit

Permalink
piv: add test that Certificate() returns ErrNotFound
Browse files Browse the repository at this point in the history
  • Loading branch information
ericchiang committed Apr 22, 2020
1 parent 1d325bc commit 04943c8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions piv/key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ func TestYubiKeySignECDSA(t *testing.T) {
}

func TestSlots(t *testing.T) {
yk, close := newTestYubiKey(t)
if err := yk.Reset(); err != nil {
t.Fatalf("resetting yubikey: %v", err)
}
close()

tests := []struct {
name string
slot Slot
Expand Down Expand Up @@ -125,6 +131,10 @@ func TestSlots(t *testing.T) {
if err != nil {
t.Fatalf("parse certificate: %v", err)
}

if _, err := yk.Certificate(test.slot); err == nil || !errors.Is(err, ErrNotFound) {
t.Errorf("get certificate, got err=%v, want=ErrNotFound", err)
}
if err := yk.SetCertificate(DefaultManagementKey, test.slot, cert); err != nil {
t.Fatalf("set certificate: %v", err)
}
Expand Down

0 comments on commit 04943c8

Please sign in to comment.