Skip to content

Commit

Permalink
Merge branch 'joerger/custom-piv-slot' into joerger/piv-pin-policy-base
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerger committed Sep 20, 2023
2 parents 4b9a235 + 8060194 commit 43eb67e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/utils/keys/yubikey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestGetYubiKeyPrivateKey_Interactive(t *testing.T) {
t.Cleanup(func() { resetYubikey(ctx, t) })

// GetYubiKeyPrivateKey should generate a new YubiKeyPrivateKey.
priv, err := GetOrGenerateYubiKeyPrivateKey(policy == PrivateKeyPolicyHardwareKeyTouch)
priv, err := GetYubiKeyPrivateKey(ctx, policy, slot)
require.NoError(t, err)

// test HardwareSigner methods
Expand All @@ -70,7 +70,7 @@ func TestGetYubiKeyPrivateKey_Interactive(t *testing.T) {
require.NoError(t, err)

// Another call to GetYubiKeyPrivateKey should retrieve the previously generated key.
retrievePriv, err := GetOrGenerateYubiKeyPrivateKey(policy == PrivateKeyPolicyHardwareKeyTouch)
retrievePriv, err := GetYubiKeyPrivateKey(ctx, policy, slot)
require.NoError(t, err)
require.Equal(t, priv.Public(), retrievePriv.Public())

Expand Down Expand Up @@ -100,12 +100,12 @@ func TestOverwritePrompt(t *testing.T) {
testOverwritePrompt := func(t *testing.T) {
// Fail to overwrite slot when user denies
prompt.SetStdin(prompt.NewFakeReader().AddString("n"))
_, err := GetOrGenerateYubiKeyPrivateKey(true)
_, err := GetYubiKeyPrivateKey(ctx, PrivateKeyPolicyHardwareKeyTouch, "" /* slot */)
require.True(t, trace.IsCompareFailed(err), "Expected compare failed error but got %v", err)

// Successfully overwrite slot when user accepts
prompt.SetStdin(prompt.NewFakeReader().AddString("y"))
_, err = GetOrGenerateYubiKeyPrivateKey(true)
_, err = GetYubiKeyPrivateKey(ctx, PrivateKeyPolicyHardwareKeyTouch, "" /* slot */)
require.NoError(t, err)
}

Expand Down

0 comments on commit 43eb67e

Please sign in to comment.