diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2019-06-13 14:21:06 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2019-06-13 15:00:59 +0200 |
commit | 0deddc2205b164cb775ff908265eebdf80943df2 (patch) | |
tree | 5ff1ead7ddc4644d8d27cbea623a64ab1ed8a91b /unittest | |
parent | ae95a590a652cd17c82dbef4098ac496485c7cbd (diff) | |
download | libnitrokey-0deddc2205b164cb775ff908265eebdf80943df2.tar.gz libnitrokey-0deddc2205b164cb775ff908265eebdf80943df2.tar.bz2 |
Add test for firmware password length
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/test_library.py | 2 | ||||
-rw-r--r-- | unittest/test_pro.py | 13 |
2 files changed, 11 insertions, 4 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 dc21f0c..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 @@ -944,12 +944,10 @@ def test_get_device_model(C): @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 - # FIXME add tests for maximum password length @pytest.mark.firmware @@ -958,4 +956,11 @@ def test_bootloader_run_pro(C): 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 - # FIXME add tests for maximum password length
\ No newline at end of file + + +@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 |