diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2019-06-13 15:01:23 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2019-06-13 15:01:23 +0200 |
commit | 3eb4856ed8c9a5a8179679f2432c01d382a9c07a (patch) | |
tree | a06f2f7dad5fe320677828b9f95d4482f0c4f7d9 /unittest | |
parent | 4a0da78d76906f052642e19dedf72f18298e5f9c (diff) | |
parent | 82e659779531a969155420f4f816b2458de3cfd5 (diff) | |
download | libnitrokey-3eb4856ed8c9a5a8179679f2432c01d382a9c07a.tar.gz libnitrokey-3eb4856ed8c9a5a8179679f2432c01d382a9c07a.tar.bz2 |
Merge branch 'bootloader_pro'
Add bootloader support for the Nitrokey Pro v0.11+
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/test_library.py | 2 | ||||
-rw-r--r-- | unittest/test_pro.py | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/unittest/test_library.py b/unittest/test_library.py index f6cf366..f26e587 100644 --- a/unittest/test_library.py +++ b/unittest/test_library.py @@ -41,6 +41,8 @@ def test_too_long_strings(C): long_string) == LibraryErrors.TOO_LONG_STRING assert gs(C.NK_get_hotp_code_PIN(0, long_string)) == b"" assert C.NK_get_last_command_status() == LibraryErrors.TOO_LONG_STRING + assert C.NK_change_firmware_password_pro(long_string, long_string) == LibraryErrors.TOO_LONG_STRING + assert C.NK_change_firmware_password_pro(DefaultPasswords.UPDATE, long_string) == LibraryErrors.TOO_LONG_STRING def test_invalid_slot(C): diff --git a/unittest/test_pro.py b/unittest/test_pro.py index d094dec..2930ed8 100644 --- a/unittest/test_pro.py +++ b/unittest/test_pro.py @@ -22,7 +22,7 @@ SPDX-License-Identifier: LGPL-3.0 import pytest from conftest import skip_if_device_version_lower_than -from constants import DefaultPasswords, DeviceErrorCode, RFC_SECRET, bb, bbRFC_SECRET +from constants import DefaultPasswords, DeviceErrorCode, RFC_SECRET, bb, bbRFC_SECRET, LibraryErrors from misc import ffi, gs, wait, cast_pointer_to_tuple, has_binary_counter from misc import is_pro_rtm_07, is_pro_rtm_08, is_storage @@ -939,3 +939,28 @@ def test_TOTP_codes_from_nitrokeyapp(secret, C): def test_get_device_model(C): assert C.NK_get_device_model() != 0 # assert C.NK_get_device_model() != C.NK_DISCONNECTED + + +@pytest.mark.firmware +def test_bootloader_password_change_pro(C): + skip_if_device_version_lower_than({'P': 11}) + assert C.NK_change_firmware_password_pro(b'zxcasd', b'zxcasd') == DeviceErrorCode.WRONG_PASSWORD + + assert C.NK_change_firmware_password_pro(DefaultPasswords.UPDATE, DefaultPasswords.UPDATE_TEMP) == DeviceErrorCode.STATUS_OK + assert C.NK_change_firmware_password_pro(DefaultPasswords.UPDATE_TEMP, DefaultPasswords.UPDATE) == DeviceErrorCode.STATUS_OK + + +@pytest.mark.firmware +def test_bootloader_run_pro(C): + skip_if_device_version_lower_than({'P': 11}) + assert C.NK_enable_firmware_update_pro(DefaultPasswords.UPDATE_TEMP) == DeviceErrorCode.WRONG_PASSWORD + # Not enabled due to lack of side-effect removal at this point + # assert C.NK_enable_firmware_update_pro(DefaultPasswords.UPDATE) == DeviceErrorCode.STATUS_OK + + +@pytest.mark.firmware +def test_bootloader_password_change_pro_too_long(C): + skip_if_device_version_lower_than({'P': 11}) + long_string = b'a' * 100 + assert C.NK_change_firmware_password_pro(long_string, long_string) == LibraryErrors.TOO_LONG_STRING + assert C.NK_change_firmware_password_pro(DefaultPasswords.UPDATE, long_string) == LibraryErrors.TOO_LONG_STRING |