summaryrefslogtreecommitdiff
path: root/unittest/test_bindings.py
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-07-26 22:39:16 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-01 13:54:57 +0200
commit128a98b0f0a4eca879dbf9d6562ab744a36510e8 (patch)
treeaaf20c1d45215dce71cb2a5e849ff554f291c2d4 /unittest/test_bindings.py
parente8ba3a66cb706e8b62e478e6802817ede04634e1 (diff)
downloadlibnitrokey-128a98b0f0a4eca879dbf9d6562ab744a36510e8.tar.gz
libnitrokey-128a98b0f0a4eca879dbf9d6562ab744a36510e8.tar.bz2
Test code refactoring
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest/test_bindings.py')
-rw-r--r--unittest/test_bindings.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py
index 9591751..899c802 100644
--- a/unittest/test_bindings.py
+++ b/unittest/test_bindings.py
@@ -105,31 +105,35 @@ def test_password_safe_slot_status(C):
def test_admin_PIN_change(C):
- assert C.NK_change_admin_PIN('wrong_password', DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.WRONG_PASSWORD
- assert C.NK_change_admin_PIN(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
- assert C.NK_change_admin_PIN(DefaultPasswords.ADMIN_TEMP, DefaultPasswords.ADMIN) == DeviceErrorCode.STATUS_OK
+ new_password = '123123123'
+ assert C.NK_change_admin_PIN('wrong_password', new_password) == DeviceErrorCode.WRONG_PASSWORD
+ assert C.NK_change_admin_PIN(DefaultPasswords.ADMIN, new_password) == DeviceErrorCode.STATUS_OK
+ assert C.NK_change_admin_PIN(new_password, DefaultPasswords.ADMIN) == DeviceErrorCode.STATUS_OK
def test_user_PIN_change(C):
- assert C.NK_change_user_PIN('wrong_password', DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.WRONG_PASSWORD
- assert C.NK_change_user_PIN(DefaultPasswords.USER, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK
- assert C.NK_change_user_PIN(DefaultPasswords.ADMIN_TEMP, DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+ new_password = '123123123'
+ assert C.NK_change_user_PIN('wrong_password', new_password) == DeviceErrorCode.WRONG_PASSWORD
+ assert C.NK_change_user_PIN(DefaultPasswords.USER, new_password) == DeviceErrorCode.STATUS_OK
+ assert C.NK_change_user_PIN(new_password, DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
def test_admin_retry_counts(C):
- assert C.NK_get_admin_retry_count() == 3
+ default_admin_retry_count = 3
+ assert C.NK_get_admin_retry_count() == default_admin_retry_count
assert C.NK_change_admin_PIN('wrong_password', DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.WRONG_PASSWORD
- assert C.NK_get_admin_retry_count() == 3 - 1
+ assert C.NK_get_admin_retry_count() == default_admin_retry_count - 1
assert C.NK_change_admin_PIN(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN) == DeviceErrorCode.STATUS_OK
- assert C.NK_get_admin_retry_count() == 3
+ assert C.NK_get_admin_retry_count() == default_admin_retry_count
def test_user_retry_counts(C):
- assert C.NK_get_user_retry_count() == 3
+ default_user_retry_count = 3
+ assert C.NK_get_user_retry_count() == default_user_retry_count
assert C.NK_enable_password_safe('wrong_password') == DeviceErrorCode.WRONG_PASSWORD
- assert C.NK_get_user_retry_count() == 3 - 1
+ assert C.NK_get_user_retry_count() == default_user_retry_count - 1
assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
- assert C.NK_get_user_retry_count() == 3
+ assert C.NK_get_user_retry_count() == default_user_retry_count
def test_HOTP_RFC(C):