From e3c251b88f76420e56681a25ec3a5eb8cc172dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sosth=C3=A8ne=20Gu=C3=A9don?= Date: Fri, 23 Feb 2024 15:08:45 +0100 Subject: [PATCH] nkpk test: do not skip the status test Fix https://github.com/Nitrokey/pynitrokey/issues/504 --- pynitrokey/cli/nk3/__init__.py | 2 +- pynitrokey/cli/nkpk.py | 2 +- pynitrokey/cli/trussed/tests.py | 20 +++++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/pynitrokey/cli/nk3/__init__.py b/pynitrokey/cli/nk3/__init__.py index 7932bae0..21c9b41b 100644 --- a/pynitrokey/cli/nk3/__init__.py +++ b/pynitrokey/cli/nk3/__init__.py @@ -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, diff --git a/pynitrokey/cli/nkpk.py b/pynitrokey/cli/nkpk.py index 348e12ca..d04513e4 100644 --- a/pynitrokey/cli/nkpk.py +++ b/pynitrokey/cli/nkpk.py @@ -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, diff --git a/pynitrokey/cli/trussed/tests.py b/pynitrokey/cli/trussed/tests.py index ca12f3a6..019d4450 100644 --- a/pynitrokey/cli/trussed/tests.py +++ b/pynitrokey/cli/trussed/tests.py @@ -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 = [] @@ -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