Skip to content

Commit 0383b0a

Browse files
committed
piv: don't attempt to access smartcard if --wipe-yubikey is not provided
We're seeing CI issues with attempting to access the daemon on GitHub. Since Action's don't exercise most of this package's logic, don't bother even attempting to access the smartcard.
1 parent 2fae465 commit 0383b0a

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
build:
1414
strategy:
1515
matrix:
16-
go-version: [1.21.x, 1.22.x]
16+
go-version: [1.22.x, 1.23.x]
1717
name: Linux
1818
runs-on: ubuntu-latest
1919
steps:

v2/piv/pcsc_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import (
2121
)
2222

2323
func runContextTest(t *testing.T, f func(t *testing.T, c *scContext)) {
24+
if !canModifyYubiKey {
25+
t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag")
26+
}
2427
ctx, err := newSCContext()
2528
if err != nil {
2629
t.Fatalf("creating context: %v", err)

v2/piv/piv_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,20 @@ func testRequiresVersion(t *testing.T, yk *YubiKey, v version) {
6464
func TestGetVersion(t *testing.T) { runHandleTest(t, testGetVersion) }
6565

6666
func TestCards(t *testing.T) {
67+
if !canModifyYubiKey {
68+
t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag")
69+
}
70+
6771
if _, err := Cards(); err != nil {
6872
t.Fatalf("listing cards: %v", err)
6973
}
7074
}
7175

7276
func newTestYubiKey(t *testing.T) (*YubiKey, func()) {
77+
if !canModifyYubiKey {
78+
t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag")
79+
}
80+
7381
cards, err := Cards()
7482
if err != nil {
7583
t.Fatalf("listing cards: %v", err)
@@ -78,9 +86,6 @@ func newTestYubiKey(t *testing.T) (*YubiKey, func()) {
7886
if !strings.Contains(strings.ToLower(card), "yubikey") {
7987
continue
8088
}
81-
if !canModifyYubiKey {
82-
t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag")
83-
}
8489
yk, err := Open(card)
8590
if err != nil {
8691
t.Fatalf("getting new yubikey: %v", err)
@@ -101,6 +106,10 @@ func TestNewYubiKey(t *testing.T) {
101106
}
102107

103108
func TestMultipleConnections(t *testing.T) {
109+
if !canModifyYubiKey {
110+
t.Skip("not running test that accesses yubikey, provide --wipe-yubikey flag")
111+
}
112+
104113
cards, err := Cards()
105114
if err != nil {
106115
t.Fatalf("listing cards: %v", err)

0 commit comments

Comments
 (0)