From 32ed4100e098ae2930e6fd94800c6ce7041101c2 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Tue, 26 Jul 2016 12:23:26 +0200 Subject: Working PW safe getting slot name Signed-off-by: Szczepan Zalega --- unittest/test_bindings.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'unittest') 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 -- cgit v1.2.3