aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-10-19 11:03:41 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-10-19 16:55:05 +0200
commitb0a06732852f3cdf203949a117e41c4b6f5f144b (patch)
tree2c8302f38d969ac3378be14c1f74aa4ec56fcc2d
parent7d579ca0ca59095596275f7b891dacce54398f1f (diff)
downloadlibnitrokey-b0a06732852f3cdf203949a117e41c4b6f5f144b.tar.gz
libnitrokey-b0a06732852f3cdf203949a117e41c4b6f5f144b.tar.bz2
Tests: detect device Pro/Storage. skip AES_support command test for Storage
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--include/stick10_commands.h5
-rw-r--r--unittest/test_bindings.py23
2 files changed, 26 insertions, 2 deletions
diff --git a/include/stick10_commands.h b/include/stick10_commands.h
index a60be59..d1f12b6 100644
--- a/include/stick10_commands.h
+++ b/include/stick10_commands.h
@@ -331,7 +331,10 @@ class GetStatus : Command<CommandID::GET_STATUS> {
std::string dissect() const {
std::stringstream ss;
- ss << "firmware_version:\t" << firmware_version << std::endl;
+ ss << "firmware_version:\t"
+ << "[" << firmware_version << "]" << "\t"
+ << ::nitrokey::misc::hexdump(
+ (const char *)(&firmware_version), 2, false);
ss << "card_serial:\t"
<< ::nitrokey::misc::hexdump((const char *)(card_serial),
sizeof card_serial, false);
diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py
index 438e88f..7984848 100644
--- a/unittest/test_bindings.py
+++ b/unittest/test_bindings.py
@@ -85,6 +85,26 @@ def C(request):
return C
+def get_firmware_version_from_status(C):
+ status = gs(C.NK_status())
+ status = [s if 'firmware_version' in s else '' for s in status.split('\n')]
+ firmware = status[0].split(':')[1]
+ return firmware
+
+
+def is_pro_rtm_07(C):
+ firmware = get_firmware_version_from_status(C)
+ return '07 00' in firmware
+
+
+def is_storage(C):
+ """
+ exact firmware storage is sent by other function
+ """
+ firmware = get_firmware_version_from_status(C)
+ return '01 00' in firmware
+
+
def test_enable_password_safe(C):
assert C.NK_lock_device() == DeviceErrorCode.STATUS_OK
assert C.NK_enable_password_safe('wrong_password') == DeviceErrorCode.WRONG_PASSWORD
@@ -188,8 +208,9 @@ def test_destroy_password_safe(C):
assert is_slot_programmed[0] == 0
-@pytest.mark.xfail
def test_is_AES_supported(C):
+ if is_storage(C):
+ pytest.skip("Storage does not implement this command")
assert C.NK_is_AES_supported('wrong password') != 1
assert C.NK_get_last_command_status() == DeviceErrorCode.WRONG_PASSWORD
assert C.NK_is_AES_supported(DefaultPasswords.USER) == 1