summaryrefslogtreecommitdiff
path: root/unittest/test_bindings.py
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-26 12:23:26 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:57 +0200
commit32ed4100e098ae2930e6fd94800c6ce7041101c2 (patch)
tree5cd408f732d1b40ec1651dbcae35ffa0f4501206 /unittest/test_bindings.py
parent39b7c99bbd00c0bc4906939ceefb724a3d9ddc35 (diff)
downloadlibnitrokey-32ed4100e098ae2930e6fd94800c6ce7041101c2.tar.gz
libnitrokey-32ed4100e098ae2930e6fd94800c6ce7041101c2.tar.bz2
Working PW safe getting slot name
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest/test_bindings.py')
-rw-r--r--unittest/test_bindings.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py
index ec7608e..f5d5cf7 100644
--- a/unittest/test_bindings.py
+++ b/unittest/test_bindings.py
@@ -2,8 +2,10 @@ import pytest
import cffi
from enum import Enum
-RFC_SECRET = '12345678901234567890'
+ffi = cffi.FFI()
+gs = ffi.string
+RFC_SECRET = '12345678901234567890'
class DefaultPasswords(Enum):
ADMIN = '12345678'
@@ -14,10 +16,7 @@ class DeviceErrorCode(Enum):
STATUS_OK = 0
NOT_PROGRAMMED = 3
WRONG_PASSWORD = 4
-
-
-ffi = cffi.FFI()
-
+ STATUS_NOT_AUTHORIZED = 5
@pytest.fixture(scope="module")
def C(request):
@@ -55,6 +54,18 @@ def test_enable_password_safe(C):
assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+def test_get_password_safe_slot_name(C):
+ C.NK_set_debug(True)
+ assert C.NK_lock_device() == DeviceErrorCode.STATUS_OK
+ assert gs(C.NK_get_password_safe_slot_name(0, '123123123')) == ''
+ assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_NOT_AUTHORIZED
+
+ assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+ assert gs(C.NK_get_password_safe_slot_name(0, '123123123')) == '1'
+ assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK
+ C.NK_set_debug(False)
+
+
def test_password_safe_slot_status(C):
C.NK_set_debug(True)
assert C.NK_get_password_safe_slot_status() == DeviceErrorCode.STATUS_OK