diff options
| author | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-02 13:00:42 +0200 | 
|---|---|---|
| committer | Szczepan Zalega <szczepan@nitrokey.com> | 2016-08-05 10:17:26 +0200 | 
| commit | 24b1ff2b610b3af78bdb894e17a31ea937dd0d3e (patch) | |
| tree | e957776575a035dfb21205ec497cffd0c5e19839 /unittest | |
| parent | 24690509898c855409f499f0c81c780602bb0aa7 (diff) | |
| download | libnitrokey-24b1ff2b610b3af78bdb894e17a31ea937dd0d3e.tar.gz libnitrokey-24b1ff2b610b3af78bdb894e17a31ea937dd0d3e.tar.bz2 | |
Tests' code reformat
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest')
| -rw-r--r-- | unittest/test_bindings.py | 22 | 
1 files changed, 15 insertions, 7 deletions
| diff --git a/unittest/test_bindings.py b/unittest/test_bindings.py index 98b2d1b..ddae6e7 100644 --- a/unittest/test_bindings.py +++ b/unittest/test_bindings.py @@ -40,15 +40,16 @@ def C(request):      C = ffi.dlopen("../build/libnitrokey.so")      C.NK_set_debug(False)      C.NK_login('P') +      # assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK      # assert C.NK_user_authenticate(DefaultPasswords.USER, DefaultPasswords.USER_TEMP) == DeviceErrorCode.STATUS_OK      # C.NK_status()      def fin(): -        print ('\nFinishing connection to device') +        print('\nFinishing connection to device')          C.NK_logout() -        print ('Finished') +        print('Finished')      request.addfinalizer(fin)      C.NK_set_debug(True) @@ -188,10 +189,12 @@ def test_user_retry_counts(C):      assert C.NK_enable_password_safe(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK      assert C.NK_get_user_retry_count() == default_user_retry_count +  def test_admin_auth(C):      assert C.NK_first_authenticate('wrong_password', DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.WRONG_PASSWORD      assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK +  def test_user_auth(C):      assert C.NK_user_authenticate('wrong_password', DefaultPasswords.USER_TEMP) == DeviceErrorCode.WRONG_PASSWORD      assert C.NK_user_authenticate(DefaultPasswords.USER, DefaultPasswords.USER_TEMP) == DeviceErrorCode.STATUS_OK @@ -199,7 +202,8 @@ def test_user_auth(C):  def check_RFC_codes(C, func, prep=None):      assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK -    assert C.NK_write_hotp_slot(1, 'python_test', RFC_SECRET, 0, False, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK +    assert C.NK_write_hotp_slot(1, 'python_test', RFC_SECRET, 0, False, +                                DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK      test_data = [          755224, 287082, 359152, 969429, 338314, 254676, 287922, 162583, 399871, 520489,      ] @@ -216,7 +220,8 @@ def test_HOTP_RFC_pin_protection(C):      assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK      assert C.NK_write_config(True, True, True, True, False, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK      assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK -    assert C.NK_write_hotp_slot(1, 'python_test', RFC_SECRET, 0, False, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK +    assert C.NK_write_hotp_slot(1, 'python_test', RFC_SECRET, 0, False, +                                DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK      # check_RFC_codes(C, lambda x: C.NK_get_hotp_code_PIN(x, DefaultPasswords.USER_TEMP), lambda: C.NK_user_authenticate(DefaultPasswords.USER, DefaultPasswords.USER_TEMP))      assert C.NK_user_authenticate(DefaultPasswords.USER, DefaultPasswords.USER_TEMP) == DeviceErrorCode.STATUS_OK      assert C.NK_get_hotp_code_PIN(1, DefaultPasswords.USER_TEMP) == 755224 @@ -225,11 +230,13 @@ def test_HOTP_RFC_pin_protection(C):  @pytest.mark.skip(reason="not implemented yet")  def test_HOTP_RFC_no_pin_protection_8digits(C): -    assert False # TODO to write +    assert False  # TODO to write +  def test_HOTP_RFC_no_pin_protection(C):      assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK -    assert C.NK_write_hotp_slot(1, 'python_test', RFC_SECRET, 0, False, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK +    assert C.NK_write_hotp_slot(1, 'python_test', RFC_SECRET, 0, False, +                                DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK      assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK      assert C.NK_write_config(True, True, True, False, True, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK      # https://tools.ietf.org/html/rfc4226#page-32 @@ -241,7 +248,8 @@ def test_TOTP_RFC_no_pin_protection(C):      assert C.NK_write_config(True, True, True, False, True, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK      # test according to https://tools.ietf.org/html/rfc6238#appendix-B      assert C.NK_first_authenticate(DefaultPasswords.ADMIN, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK -    assert C.NK_write_totp_slot(1, 'python_test', RFC_SECRET, 30, True, DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK +    assert C.NK_write_totp_slot(1, 'python_test', RFC_SECRET, 30, True, +                                DefaultPasswords.ADMIN_TEMP) == DeviceErrorCode.STATUS_OK      test_data = [          (59, 1, 94287082),          (1111111109, 0x00000000023523EC, 7081804), | 
