Codebase list golang-github-go-piv-piv-go / v1.3.0
piv: add test that Certificate() returns ErrNotFound Eric Chiang authored 4 years ago Eric Chiang committed 4 years ago
1 changed file(s) with 10 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
7979 }
8080
8181 func TestSlots(t *testing.T) {
82 yk, close := newTestYubiKey(t)
83 if err := yk.Reset(); err != nil {
84 t.Fatalf("resetting yubikey: %v", err)
85 }
86 close()
87
8288 tests := []struct {
8389 name string
8490 slot Slot
123129 cert, err := x509.ParseCertificate(raw)
124130 if err != nil {
125131 t.Fatalf("parse certificate: %v", err)
132 }
133
134 if _, err := yk.Certificate(test.slot); err == nil || !errors.Is(err, ErrNotFound) {
135 t.Errorf("get certificate, got err=%v, want=ErrNotFound", err)
126136 }
127137 if err := yk.SetCertificate(DefaultManagementKey, test.slot, cert); err != nil {
128138 t.Fatalf("set certificate: %v", err)