aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-23 18:20:23 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:57 +0200
commit068c9559b240ee4f74f30a39521438cf2a1daa01 (patch)
tree5508bf61c07deb295a1ef01fc0d9a1343769785a
parent9c3951314a3a0f623aefbd6c322a4da29550bdc6 (diff)
downloadlibnitrokey-068c9559b240ee4f74f30a39521438cf2a1daa01.tar.gz
libnitrokey-068c9559b240ee4f74f30a39521438cf2a1daa01.tar.bz2
Checking not programmed slots
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--unittest/test_bindings.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py
index 29856e9..32baf69 100644
--- a/unittest/test_bindings.py
+++ b/unittest/test_bindings.py
@@ -6,7 +6,6 @@ ffi = cffi.FFI()
@pytest.fixture(scope="module")
def C(request):
-
fp = '../NK_C_API.h'
declarations = []
@@ -22,10 +21,12 @@ def C(request):
C = ffi.dlopen("../build/libnitrokey.so")
C.NK_login('12345678', '123123123')
- C.NK_set_debug(True)
+
+ # C.NK_set_debug(True)
def fin():
C.NK_logout()
request.addfinalizer(fin)
+
return C
@@ -56,19 +57,23 @@ def test_TOTP_RFC(C):
def test_get_slot_names(C):
- s = []
for i in range(16):
- s.append(ffi.string(C.NK_get_totp_slot_name(i)))
+ name = ffi.string(C.NK_get_totp_slot_name(i))
+ if name == '':
+ assert C.NK_get_last_command_status() == 3 # NOT PROGRAMMED
for i in range(3):
- s.append(ffi.string(C.NK_get_hotp_slot_name(i)))
- print(repr(s))
- print(s)
+ name = ffi.string(C.NK_get_hotp_slot_name(i))
+ if name == '':
+ assert C.NK_get_last_command_status() == 3 # NOT PROGRAMMED
+
def test_get_OTP_codes(C):
- s = []
for i in range(16):
- s.append(C.NK_get_totp_code(i, 0, 0, 0))
+ code = C.NK_get_totp_code(i, 0, 0, 0)
+ if code == 0:
+ assert C.NK_get_last_command_status() == 3 # NOT PROGRAMMED
+
for i in range(3):
- s.append(C.NK_get_hotp_code(i))
- print(repr(s))
- print(s)
+ code = C.NK_get_hotp_code(i)
+ if code == 0:
+ assert C.NK_get_last_command_status() == 3 # NOT PROGRAMMED