Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

piv: don't attempt to access smartcard if --wipe-yubikey is not provided #167

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
strategy:
matrix:
go-version: [1.21.x, 1.22.x]
go-version: [1.22.x, 1.23.x]
name: Linux
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions v2/piv/pcsc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import (
)

func runContextTest(t *testing.T, f func(t *testing.T, c *scContext)) {
if !canModifyYubiKey {
t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag")
}
ctx, err := newSCContext()
if err != nil {
t.Fatalf("creating context: %v", err)
Expand Down
15 changes: 12 additions & 3 deletions v2/piv/piv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@ func testRequiresVersion(t *testing.T, yk *YubiKey, v version) {
func TestGetVersion(t *testing.T) { runHandleTest(t, testGetVersion) }

func TestCards(t *testing.T) {
if !canModifyYubiKey {
t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag")
}

if _, err := Cards(); err != nil {
t.Fatalf("listing cards: %v", err)
}
}

func newTestYubiKey(t *testing.T) (*YubiKey, func()) {
if !canModifyYubiKey {
t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag")
}

cards, err := Cards()
if err != nil {
t.Fatalf("listing cards: %v", err)
Expand All @@ -78,9 +86,6 @@ func newTestYubiKey(t *testing.T) (*YubiKey, func()) {
if !strings.Contains(strings.ToLower(card), "yubikey") {
continue
}
if !canModifyYubiKey {
t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag")
}
yk, err := Open(card)
if err != nil {
t.Fatalf("getting new yubikey: %v", err)
Expand All @@ -101,6 +106,10 @@ func TestNewYubiKey(t *testing.T) {
}

func TestMultipleConnections(t *testing.T) {
if !canModifyYubiKey {
t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag")
}

cards, err := Cards()
if err != nil {
t.Fatalf("listing cards: %v", err)
Expand Down
Loading