Skip to content

Commit

Permalink
nkpk test: do not skip the status test
Browse files Browse the repository at this point in the history
Fix #504
  • Loading branch information
sosthene-nitrokey committed Feb 23, 2024
1 parent 6f6b041 commit e3c251b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pynitrokey/cli/nk3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_cases(self) -> list[TestCase]:
return [
tests.test_uuid_query,
tests.test_firmware_version_query,
tests.test_device_status,
tests.test_nk3_device_status,
tests.test_bootloader_configuration,
tests.test_firmware_mode,
tests.test_se050,
Expand Down
2 changes: 1 addition & 1 deletion pynitrokey/cli/nkpk.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_cases(self) -> list[TestCase]:
return [
tests.test_uuid_query,
tests.test_firmware_version_query,
tests.test_device_status,
tests.test_nkpk_device_status,
tests.test_bootloader_configuration,
tests.test_firmware_mode,
tests.test_fido2,
Expand Down
20 changes: 17 additions & 3 deletions pynitrokey/cli/trussed/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ def test_firmware_version_query(
return TestResult(TestStatus.SUCCESS, str(version))


@test_case("status", "Device status")
def test_device_status(ctx: TestContext, device: NitrokeyTrussedBase) -> TestResult:
def test_device_status_internal(
ctx: TestContext, device: NitrokeyTrussedBase, skip_if_version: Optional[Version]
) -> TestResult:
if not isinstance(device, NitrokeyTrussedDevice):
return TestResult(TestStatus.SKIPPED)
firmware_version = ctx.firmware_version or device.admin.version()
if firmware_version.core() < Version(1, 3, 0):

if skip_if_version is not None and firmware_version.core() < skip_if_version:
return TestResult(TestStatus.SKIPPED)

errors = []
Expand All @@ -80,6 +82,18 @@ def test_device_status(ctx: TestContext, device: NitrokeyTrussedBase) -> TestRes
return TestResult(TestStatus.SUCCESS, str(status))


@test_case("status", "Device status")
def test_nk3_device_status(ctx: TestContext, device: NitrokeyTrussedBase) -> TestResult:
return test_device_status_internal(ctx, device, skip_if_version=Version(1, 3, 0))


@test_case("status", "Device status")
def test_nkpk_device_status(
ctx: TestContext, device: NitrokeyTrussedBase
) -> TestResult:
return test_device_status_internal(ctx, device, skip_if_version=None)


@test_case("bootloader", "Bootloader configuration")
def test_bootloader_configuration(
ctx: TestContext, device: NitrokeyTrussedBase
Expand Down

0 comments on commit e3c251b

Please sign in to comment.