Skip to content

Commit

Permalink
Ignore the smart card tests if CardTerminals.list() fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ebourg committed May 16, 2024
1 parent d668c2e commit 2308eb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion jsign-core/src/test/java/net/jsign/jca/OpenPGPCardTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.security.PrivateKey;
import java.util.Set;
import javax.crypto.Cipher;
import javax.smartcardio.CardException;

import org.apache.commons.codec.binary.Hex;
import org.junit.Test;
Expand All @@ -32,7 +33,11 @@
public class OpenPGPCardTest {

public static void assumeCardPresent() throws Exception {
assumeTrue("OpenPGP card not found", SmartCard.getTerminal("Nitrokey") != null);
try {
assumeTrue("OpenPGP card not found", SmartCard.getTerminal("Nitrokey") != null);
} catch (CardException e) {
assumeNoException("OpenPGP card not found", e);
}
}

@Test
Expand Down
7 changes: 6 additions & 1 deletion jsign-core/src/test/java/net/jsign/jca/PIVCardTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.Set;
import javax.crypto.Cipher;
import javax.smartcardio.CardException;

import org.junit.Test;

Expand All @@ -34,7 +35,11 @@
public class PIVCardTest {

public static void assumeCardPresent() throws Exception {
assumeTrue("PIV card not found", SmartCard.getTerminal("Yubikey") != null);
try {
assumeTrue("PIV card not found", SmartCard.getTerminal("Yubikey") != null);
} catch (CardException e) {
assumeNoException("PIV card not found", e);
}
}

@Test
Expand Down

0 comments on commit 2308eb5

Please sign in to comment.