summaryrefslogtreecommitdiff
path: root/unittest/test_pro.py
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-11-26 15:41:34 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2016-12-03 16:01:51 +0100
commitb9f7d118ecdef61764c3256a203010831e0c5d7d (patch)
tree2cccdf8fd463631794710269358f212d21538449 /unittest/test_pro.py
parent9e0c85241234ae607c7eea4bb9f3ee61762b5c0c (diff)
downloadlibnitrokey-b9f7d118ecdef61764c3256a203010831e0c5d7d.tar.gz
libnitrokey-b9f7d118ecdef61764c3256a203010831e0c5d7d.tar.bz2
Test for manual checking of TOTP slot written by Nitrokey App
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest/test_pro.py')
-rw-r--r--unittest/test_pro.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/unittest/test_pro.py b/unittest/test_pro.py
index c8be0e8..89a6ccf 100644
--- a/unittest/test_pro.py
+++ b/unittest/test_pro.py
@@ -683,3 +683,23 @@ def test_edit_OTP_slot(C):
assert gs(C.NK_get_hotp_slot_name(slot_number)) == changed_name
+@pytest.mark.skip
+@pytest.mark.parametrize("secret", ['31323334353637383930'*2,'31323334353637383930'*4] )
+def test_TOTP_codes_from_nitrokeyapp(secret, C):
+ """
+ Helper test for manual TOTP check of written secret by Nitrokey App
+ Destined to run by hand
+ """
+ slot_number = 0
+ PIN_protection = False
+ period = 30
+ assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
+ assert C.NK_write_config(255, 255, 255, PIN_protection, not PIN_protection,
+ DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
+ code_device = str(C.NK_get_totp_code(slot_number, 0, 0, period))
+ code_device = '0'+code_device if len(code_device) < 6 else code_device
+
+ oath = pytest.importorskip("oath")
+ lib_at = lambda : oath.totp(secret, period=period)
+ print (lib_at())
+ assert lib_at() == code_device