aboutsummaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-01-06 00:36:07 +0100
committerRobin Krahl <robin.krahl@ireas.org>2020-01-06 00:51:28 +0100
commit1ba9938837a726580728c64bdd77d9676c98a020 (patch)
tree4ecc60bfbced15c94e20f92c0d9245bc44904a64 /unittest
parent2c52393d12dbb16ce1d643cf020aff964da6ec89 (diff)
downloadlibnitrokey-1ba9938837a726580728c64bdd77d9676c98a020.tar.gz
libnitrokey-1ba9938837a726580728c64bdd77d9676c98a020.tar.bz2
test_pro: Extend test_get_status test case
This patch extends the test_get_status test case to check the content of the returned status struct. The firmware version, serial number and config should match the values returned by the NK_*_firmware_version, NK_device_serial_number and NK_read_config functions. This does not work for the Nitrokey Storage, which will be fixed in the next patch.
Diffstat (limited to 'unittest')
-rw-r--r--unittest/test_pro.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/unittest/test_pro.py b/unittest/test_pro.py
index a8df7cd..203c8b1 100644
--- a/unittest/test_pro.py
+++ b/unittest/test_pro.py
@@ -723,8 +723,27 @@ def test_get_status(C):
raise Exception("Could not allocate status")
err = C.NK_get_status(status_st)
assert err == 0
+
+ # check firmware version
+ firmware_version_major = C.NK_get_major_firmware_version()
+ firmware_version_minor = C.NK_get_minor_firmware_version()
+
assert status_st.firmware_version_major == 0
assert status_st.firmware_version_minor != 0
+ assert status_st.firmware_version_major == firmware_version_major
+ assert status_st.firmware_version_minor == firmware_version_minor
+
+ # check serial number
+ serial_number = gs(C.NK_device_serial_number())
+ assert status_st.serial_number_smart_card != 0
+ assert '{:08x}'.format(status_st.serial_number_smart_card) == serial_number.decode('ascii')
+
+ # check config
+ config = C.NK_read_config()
+ assert status_st.config_numlock == config[0]
+ assert status_st.config_capslock == config[1]
+ assert status_st.config_scrolllock == config[2]
+ assert status_st.otp_user_password == config[3]
@pytest.mark.status
@@ -1094,4 +1113,4 @@ def test_OTP_all_rw(C):
this_loop_codes.append(('H', i, code))
all_codes.append(this_loop_codes)
from pprint import pprint
- pprint(all_codes) \ No newline at end of file
+ pprint(all_codes)