Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nkpk test: do not skip the status test #505

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading