aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-08-05 17:18:28 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-05 17:19:47 +0200
commit64b25c28ee755a8cbfe6c85748d7410cffa81a2c (patch)
tree86ac2be253ac9c5dad94597da71bb18d86b6af29
parentf3229a742cb5707ea06490126b8f60ac2d4cc120 (diff)
downloadlibnitrokey-64b25c28ee755a8cbfe6c85748d7410cffa81a2c.tar.gz
libnitrokey-64b25c28ee755a8cbfe6c85748d7410cffa81a2c.tar.bz2
Test for writing token ID to OTP slot
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--unittest/test_bindings.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py
index fc680c0..3b57307 100644
--- a/unittest/test_bindings.py
+++ b/unittest/test_bindings.py
@@ -264,6 +264,24 @@ def test_HOTP_RFC_use8digits_usepin(C, use_8_digits, use_pin_protection):
check_HOTP_RFC_codes(C, C.NK_get_hotp_code, use_8_digits=use_8_digits)
+def test_HOTP_token(C):
+ """
+ Check HOTP routine with written token ID to slot.
+ """
+ use_pin_protection = False
+ assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
+ assert C.NK_write_config(255, 255, 255, use_pin_protection, not use_pin_protection,
+ DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
+ assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
+ token_ID = "AAV100000022"
+ assert C.NK_write_hotp_slot(1, 'python_test', RFC_SECRET, 0, False, False, True, token_ID,
+ DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
+ for i in range(5):
+ hotp_code = C.NK_get_hotp_code(1)
+ assert hotp_code != 0
+ assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK
+
+
@pytest.mark.xfail(reason="firmware bug: set time command not always changes the time on stick thus failing this test, "
"this does not influence normal use since setting time is not done every TOTP code request")
@pytest.mark.parametrize("PIN_protection", [False, True, ])