Skip to content

Commit

Permalink
nk3 test/fido2: early exit if pin not set - fixes #411
Browse files Browse the repository at this point in the history
  • Loading branch information
daringer committed Sep 19, 2023
1 parent 6894d37 commit 09604da
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pynitrokey/cli/nk3/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from pynitrokey.cli.exceptions import CliException
from pynitrokey.fido2 import device_path_to_str
from pynitrokey.fido2.client import NKFido2Client
from pynitrokey.helpers import local_print
from pynitrokey.nk3.admin_app import AdminApp
from pynitrokey.nk3.base import Nitrokey3Base
Expand Down Expand Up @@ -347,6 +348,20 @@ def run_tests(ctx: TestContext, device: Nitrokey3Base, selector: TestSelector) -
if not test_cases:
raise CliException("No test cases selected", support_hint=False)

assert isinstance(device, Nitrokey3Device)

client = NKFido2Client()
client.find_device(device.device)

if (
any("fido2" == tc.name for tc in test_cases)
and client.has_pin()
and not ctx.pin
):
raise CliException(
"FIDO2 tests: Device requires pin, but not set", support_hint=False
)

results = []

local_print("")
Expand Down

0 comments on commit 09604da

Please sign in to comment.