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 1eabb0d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pynitrokey/cli/nk3/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@

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
from pynitrokey.nk3.device import Nitrokey3Device
from pynitrokey.nk3.utils import Fido2Certs, Uuid, Version


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -347,6 +349,15 @@ 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 1eabb0d

Please sign in to comment.