summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--unittest/test_library.py2
-rw-r--r--unittest/test_pro.py13
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