aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-08-08 20:29:18 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-09 18:34:00 +0200
commit8346fe8134ccb243bf871c7ba21645b81a2fd3fd (patch)
treebaa7e010d4a98cc9f34b341030aa9389294f6dd9
parent54d59fa9ea2d9f7a57f1d6310d0914f59bff9c58 (diff)
downloadlibnitrokey-8346fe8134ccb243bf871c7ba21645b81a2fd3fd.tar.gz
libnitrokey-8346fe8134ccb243bf871c7ba21645b81a2fd3fd.tar.bz2
Corrected test for getting OTP codes from not programmed slot and extracted
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--unittest/test_bindings.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py
index da5a4e4..0b071d5 100644
--- a/unittest/test_bindings.py
+++ b/unittest/test_bindings.py
@@ -44,7 +44,7 @@ def C(request):
C.NK_set_debug(False)
nk_login = C.NK_login_auto()
if nk_login != 1:
- print ('No devices detected!')
+ print('No devices detected!')
assert nk_login == 1 # returns 0 if not connected or wrong model or 1 when connected
# assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
@@ -346,10 +346,6 @@ def test_get_slot_names(C):
def test_get_OTP_codes(C):
assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
assert C.NK_write_config(255, 255, 255, False, True, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
- assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
- assert C.NK_erase_hotp_slot(0, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
- assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
- assert C.NK_erase_totp_slot(0, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
for i in range(15):
code = C.NK_get_totp_code(i, 0, 0, 0)
if code == 0:
@@ -360,6 +356,20 @@ def test_get_OTP_codes(C):
if code == 0:
assert C.NK_get_last_command_status() == DeviceErrorCode.NOT_PROGRAMMED
+def test_get_OTP_code_from_not_programmed_slot(C):
+ assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
+ assert C.NK_erase_hotp_slot(0, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
+ assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
+ assert C.NK_erase_totp_slot(0, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
+
+ code = C.NK_get_hotp_code(0)
+ assert code == 0
+ assert C.NK_get_last_command_status() == DeviceErrorCode.NOT_PROGRAMMED
+
+ code = C.NK_get_totp_code(0, 0, 0, 0)
+ assert code == 0
+ assert C.NK_get_last_command_status() == DeviceErrorCode.NOT_PROGRAMMED
+
def test_get_code_user_authorize(C):
C.NK_set_debug(True)
@@ -432,3 +442,10 @@ def test_factory_reset(C):
assert C.NK_build_aes_key(DefaultPasswords.ADMIN) == DeviceErrorCode.STATUS_OK
assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
assert C.NK_lock_device() == DeviceErrorCode.STATUS_OK
+
+
+def test_clear(C):
+ d = 'asdasdasd'
+ print(d)
+ C.clear_password(d)
+ print(d)