summaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-26 10:59:24 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:57 +0200
commit8a938be4ffa97490d89206cc1fd079a057cfc65c (patch)
tree5f2794b8858551eb8cd9f1574d1682567674a04e /unittest
parentb37e5990aa409689e5d6162776583616ac03e0ac (diff)
downloadlibnitrokey-8a938be4ffa97490d89206cc1fd079a057cfc65c.tar.gz
libnitrokey-8a938be4ffa97490d89206cc1fd079a057cfc65c.tar.bz2
Manage retry counts of user and admin passwords
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest')
-rw-r--r--unittest/test_bindings.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py
index ac77140..51e1233 100644
--- a/unittest/test_bindings.py
+++ b/unittest/test_bindings.py
@@ -35,10 +35,10 @@ def C(request):
ffi.cdef(declaration)
C = ffi.dlopen("../build/libnitrokey.so")
- C.NK_set_debug(False)
C.NK_login('12345678', '123123123')
# C.NK_set_debug(True)
+
def fin():
print ('\nFinishing connection to device')
C.NK_logout()
@@ -50,6 +50,7 @@ def C(request):
def test_enable_password_safe(C):
+ # lock device
assert C.NK_enable_password_safe('wrong_password') == DeviceErrorCode.WRONG_PASSWORD
assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
@@ -72,6 +73,22 @@ def test_user_PIN_change(C):
assert C.NK_change_user_PIN('123123123', DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+def test_admin_retry_counts(C):
+ assert C.NK_get_admin_retry_count() == 3
+ assert C.NK_change_admin_PIN('wrong_password', '123123123') == DeviceErrorCode.WRONG_PASSWORD
+ assert C.NK_get_admin_retry_count() == 3 - 1
+ assert C.NK_change_admin_PIN(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN) == DeviceErrorCode.STATUS_OK
+ assert C.NK_get_admin_retry_count() == 3
+
+
+def test_user_retry_counts(C):
+ assert C.NK_get_user_retry_count() == 3
+ assert C.NK_enable_password_safe('wrong_password') == DeviceErrorCode.WRONG_PASSWORD
+ assert C.NK_get_user_retry_count() == 3 - 1
+ assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+ assert C.NK_get_user_retry_count() == 3
+
+
def test_HOTP_RFC(C):
# https://tools.ietf.org/html/rfc4226#page-32
C.NK_write_hotp_slot(1, 'python_test', RFC_SECRET, 0, '123123123')