aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-10-14 14:08:10 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-10-19 16:34:34 +0200
commit234b0dc39d17ab8b2c5d8ed7af5c5681fde84ae4 (patch)
tree31178f25d618728f69ce83954d106ca230f71157
parent5e72941919f19c43c1cd7f79c5cb913caf2705e4 (diff)
downloadlibnitrokey-234b0dc39d17ab8b2c5d8ed7af5c5681fde84ae4.tar.gz
libnitrokey-234b0dc39d17ab8b2c5d8ed7af5c5681fde84ae4.tar.bz2
Tests: check user retry counter based on PIN changing. Lock device before tests.
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--unittest/test_bindings.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py
index 17ebb38..e681085 100644
--- a/unittest/test_bindings.py
+++ b/unittest/test_bindings.py
@@ -238,6 +238,7 @@ def test_invalid_slot(C):
def test_admin_retry_counts(C):
default_admin_retry_count = 3
+ assert C.NK_lock_device() == DeviceErrorCode.STATUS_OK
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() == default_admin_retry_count - 1
@@ -245,8 +246,20 @@ def test_admin_retry_counts(C):
assert C.NK_get_admin_retry_count() == default_admin_retry_count
-def test_user_retry_counts(C):
+def test_user_retry_counts_change_PIN(C):
+ assert C.NK_change_user_PIN(DefaultPasswords.USER, DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+ wrong_password = 'wrong_password'
+ default_user_retry_count = 3
+ assert C.NK_lock_device() == DeviceErrorCode.STATUS_OK
+ assert C.NK_get_user_retry_count() == default_user_retry_count
+ assert C.NK_change_user_PIN(wrong_password, wrong_password) == DeviceErrorCode.WRONG_PASSWORD
+ assert C.NK_get_user_retry_count() == default_user_retry_count - 1
+ assert C.NK_change_user_PIN(DefaultPasswords.USER, DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+ assert C.NK_get_user_retry_count() == default_user_retry_count
+
+def test_user_retry_counts_PWSafe(C):
default_user_retry_count = 3
+ assert C.NK_lock_device() == DeviceErrorCode.STATUS_OK
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() == default_user_retry_count - 1