aboutsummaryrefslogtreecommitdiff
path: root/unittest
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-09-10 10:50:59 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-09-10 10:51:53 +0200
commit3632e8a32d47950102bc077fd32f9c88316370e9 (patch)
treeca690bd0aa9b69c7fa0409c5c6679ca1f9cce6fb /unittest
parent77ea27f25165302491a693051bea05c67e6dfbed (diff)
downloadlibnitrokey-3632e8a32d47950102bc077fd32f9c88316370e9.tar.gz
libnitrokey-3632e8a32d47950102bc077fd32f9c88316370e9.tar.bz2
Assume secret is coded in hex for OTP slot write #31
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest')
-rw-r--r--unittest/test_bindings.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py
index eeda247..377203e 100644
--- a/unittest/test_bindings.py
+++ b/unittest/test_bindings.py
@@ -5,8 +5,15 @@ from enum import Enum
ffi = cffi.FFI()
gs = ffi.string
-RFC_SECRET = '12345678901234567890'
+def to_hex(s):
+ return "".join("{:02x}".format(ord(c)) for c in s)
+
+
+RFC_SECRET_HR = '12345678901234567890'
+RFC_SECRET = to_hex(RFC_SECRET_HR) #'12345678901234567890'
+
+# print( repr((RFC_SECRET, RFC_SECRET_, len(RFC_SECRET))) )
class DefaultPasswords(Enum):
ADMIN = '12345678'
@@ -214,7 +221,7 @@ def test_invalid_slot(C):
invalid_slot = 255
assert C.NK_erase_totp_slot(invalid_slot, 'some password') == LibraryErrors.INVALID_SLOT
assert C.NK_write_hotp_slot(invalid_slot, 'long_test', RFC_SECRET, 0, False, False, False, "",
- 'aaa') == LibraryErrors.INVALID_SLOT
+ 'aaa') == LibraryErrors.INVALID_SLOT
assert C.NK_get_hotp_code_PIN(invalid_slot, 'some password') == 0
assert C.NK_get_last_command_status() == LibraryErrors.INVALID_SLOT
assert C.NK_erase_password_safe_slot(invalid_slot) == LibraryErrors.INVALID_SLOT