From 8a938be4ffa97490d89206cc1fd079a057cfc65c Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 26 Jul 2016 10:59:24 +0200 Subject: Manage retry counts of user and admin passwords Signed-off-by: Szczepan Zalega --- unittest/test_bindings.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'unittest') 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') -- cgit v1.2.1