diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-07-25 18:32:59 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-01 13:54:57 +0200 |
commit | b37e5990aa409689e5d6162776583616ac03e0ac (patch) | |
tree | efb9585d220fa737aab90a35541b76bddfb6a09d /unittest/test_bindings.py | |
parent | 689f38b7a4bbb823b8d43bab8357a32558d3775c (diff) | |
download | libnitrokey-b37e5990aa409689e5d6162776583616ac03e0ac.tar.gz libnitrokey-b37e5990aa409689e5d6162776583616ac03e0ac.tar.bz2 |
Enabling password safe and password safe status (latter not working yet)
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest/test_bindings.py')
-rw-r--r-- | unittest/test_bindings.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py index 6e87c65..ac77140 100644 --- a/unittest/test_bindings.py +++ b/unittest/test_bindings.py @@ -4,10 +4,12 @@ from enum import Enum RFC_SECRET = '12345678901234567890' + class DefaultPasswords(Enum): ADMIN = '12345678' USER = '123456' + class DeviceErrorCode(Enum): STATUS_OK = 0 NOT_PROGRAMMED = 3 @@ -16,6 +18,7 @@ class DeviceErrorCode(Enum): ffi = cffi.FFI() + @pytest.fixture(scope="module") def C(request): fp = '../NK_C_API.h' @@ -32,31 +35,41 @@ 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() + print ('Finished') request.addfinalizer(fin) return C -def test_admin_PIN_change(C): +def test_enable_password_safe(C): + assert C.NK_enable_password_safe('wrong_password') == DeviceErrorCode.WRONG_PASSWORD + assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK + + +def test_password_safe_slot_status(C): C.NK_set_debug(True) + assert C.NK_get_password_safe_slot_status() == DeviceErrorCode.STATUS_OK + C.NK_set_debug(False) + + +def test_admin_PIN_change(C): assert C.NK_change_admin_PIN('wrong_password', '123123123') == DeviceErrorCode.WRONG_PASSWORD assert C.NK_change_admin_PIN(DefaultPasswords.ADMIN, '123123123') == DeviceErrorCode.STATUS_OK assert C.NK_change_admin_PIN('123123123', DefaultPasswords.ADMIN) == DeviceErrorCode.STATUS_OK - C.NK_set_debug(False) def test_user_PIN_change(C): - C.NK_set_debug(True) assert C.NK_change_user_PIN('wrong_password', '123123123') == DeviceErrorCode.WRONG_PASSWORD assert C.NK_change_user_PIN(DefaultPasswords.USER, '123123123') == DeviceErrorCode.STATUS_OK assert C.NK_change_user_PIN('123123123', DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK - C.NK_set_debug(False) def test_HOTP_RFC(C): |