aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-12-12 17:31:36 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2018-02-23 15:42:37 +0100
commit025774fc3759683a8ec0f6b1598b1e34b550e6d5 (patch)
treed2dfb91526189ad37ffa209c8fa43b3528d14bf1
parent0363caa230c06f920c9bd6bd9ecc349d322af016 (diff)
downloadlibnitrokey-025774fc3759683a8ec0f6b1598b1e34b550e6d5.tar.gz
libnitrokey-025774fc3759683a8ec0f6b1598b1e34b550e6d5.tar.bz2
Tests: set debug level from environment variable, show connected device model and version
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--NitrokeyManager.cc1
-rw-r--r--unittest/conftest.py6
-rw-r--r--unittest/test_storage.py2
3 files changed, 7 insertions, 2 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index eb52eee..de52e25 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -30,6 +30,7 @@
#include <mutex>
#include "include/cxx_semantics.h"
#include <functional>
+#include <stick10_commands.h>
std::mutex nitrokey::proto::send_receive_mtx;
diff --git a/unittest/conftest.py b/unittest/conftest.py
index edcbff4..26536cf 100644
--- a/unittest/conftest.py
+++ b/unittest/conftest.py
@@ -77,7 +77,8 @@ def C(request):
print("No library file found")
sys.exit(1)
- C.NK_set_debug(False)
+ C.NK_set_debug_level(int(os.environ.get('LIBNK_DEBUG', 2)))
+
nk_login = C.NK_login_auto()
if nk_login != 1:
print('No devices detected!')
@@ -86,6 +87,7 @@ def C(request):
firmware_version = C.NK_get_minor_firmware_version()
model = 'P' if firmware_version in [7,8] else 'S'
device_type = (model, firmware_version)
+ print('Connected device: {} {}'.format(model, firmware_version))
# assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
# assert C.NK_user_authenticate(DefaultPasswords.USER, DefaultPasswords.USER_TEMP) == DeviceErrorCode.STATUS_OK
@@ -99,6 +101,6 @@ def C(request):
request.addfinalizer(fin)
# C.NK_set_debug(True)
- C.NK_set_debug_level(3)
+ C.NK_set_debug_level(int(os.environ.get('LIBNK_DEBUG', 3)))
return C
diff --git a/unittest/test_storage.py b/unittest/test_storage.py
index 9d39371..f3fd801 100644
--- a/unittest/test_storage.py
+++ b/unittest/test_storage.py
@@ -53,6 +53,8 @@ def test_get_status_storage(C):
status_dict = get_dict_from_dissect(status_string.decode('ascii'))
default_admin_password_retry_count = 3
assert int(status_dict['AdminPwRetryCount']) == default_admin_password_retry_count
+ print('C.NK_get_major_firmware_version(): {}'.format(C.NK_get_major_firmware_version()))
+ print('C.NK_get_minor_firmware_version(): {}'.format(C.NK_get_minor_firmware_version()))
@pytest.mark.other