summaryrefslogtreecommitdiff
path: root/unittest/test_storage.py
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2017-10-10 18:25:32 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2017-10-10 18:25:32 +0200
commit343e4b1e6d53f042df84e951209b5a33b9a617c3 (patch)
treeba771942520fe6649d6e47a223814a260b9c5f31 /unittest/test_storage.py
parentfa871ecba4333ffe9a96b0a662b9d77089cf69b7 (diff)
parentbe675e293fe94a4a6926125a61e67e92e8788d8a (diff)
downloadlibnitrokey-343e4b1e6d53f042df84e951209b5a33b9a617c3.tar.gz
libnitrokey-343e4b1e6d53f042df84e951209b5a33b9a617c3.tar.bz2
Merge branch 'test_organize'
Improve test organization Disable CRC check Improve log
Diffstat (limited to 'unittest/test_storage.py')
-rw-r--r--unittest/test_storage.py39
1 files changed, 35 insertions, 4 deletions
diff --git a/unittest/test_storage.py b/unittest/test_storage.py
index 6671f5b..2466779 100644
--- a/unittest/test_storage.py
+++ b/unittest/test_storage.py
@@ -1,5 +1,4 @@
import pprint
-
import pytest
from conftest import skip_if_device_version_lower_than
@@ -22,6 +21,8 @@ def get_dict_from_dissect(status):
return d
+@pytest.mark.other
+@pytest.mark.info
def test_get_status_storage(C):
skip_if_device_version_lower_than({'S': 43})
status_pointer = C.NK_get_status_storage_as_string()
@@ -33,6 +34,8 @@ def test_get_status_storage(C):
assert int(status_dict['AdminPwRetryCount']) == default_admin_password_retry_count
+@pytest.mark.other
+@pytest.mark.info
def test_sd_card_usage(C):
skip_if_device_version_lower_than({'S': 43})
data_pointer = C.NK_get_SD_usage_data_as_string()
@@ -43,12 +46,14 @@ def test_sd_card_usage(C):
assert int(data_dict['WriteLevelMax']) <= 100
+@pytest.mark.encrypted
def test_encrypted_volume_unlock(C):
skip_if_device_version_lower_than({'S': 43})
assert C.NK_lock_device() == DeviceErrorCode.STATUS_OK
assert C.NK_unlock_encrypted_volume(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+@pytest.mark.hidden
def test_encrypted_volume_unlock_hidden(C):
skip_if_device_version_lower_than({'S': 43})
hidden_volume_password = b'hiddenpassword'
@@ -58,6 +63,7 @@ def test_encrypted_volume_unlock_hidden(C):
assert C.NK_unlock_hidden_volume(hidden_volume_password) == DeviceErrorCode.STATUS_OK
+@pytest.mark.hidden
def test_encrypted_volume_setup_multiple_hidden_lock(C):
import random
skip_if_device_version_lower_than({'S': 45}) #hangs device on lower version
@@ -73,6 +79,7 @@ def test_encrypted_volume_setup_multiple_hidden_lock(C):
assert C.NK_unlock_hidden_volume(p(i)) == DeviceErrorCode.STATUS_OK
+@pytest.mark.hidden
@pytest.mark.parametrize("volumes_to_setup", range(1, 5))
def test_encrypted_volume_setup_multiple_hidden_no_lock_device_volumes(C, volumes_to_setup):
skip_if_device_version_lower_than({'S': 43})
@@ -92,6 +99,7 @@ def test_encrypted_volume_setup_multiple_hidden_no_lock_device_volumes(C, volume
assert C.NK_lock_hidden_volume() == DeviceErrorCode.STATUS_OK
+@pytest.mark.hidden
@pytest.mark.parametrize("volumes_to_setup", range(1, 5))
def test_encrypted_volume_setup_multiple_hidden_no_lock_device_volumes_unlock_at_once(C, volumes_to_setup):
skip_if_device_version_lower_than({'S': 43})
@@ -113,6 +121,7 @@ def test_encrypted_volume_setup_multiple_hidden_no_lock_device_volumes_unlock_at
assert C.NK_lock_hidden_volume() == DeviceErrorCode.STATUS_OK
+@pytest.mark.hidden
@pytest.mark.parametrize("use_slot", range(4))
def test_encrypted_volume_setup_one_hidden_no_lock_device_slot(C, use_slot):
skip_if_device_version_lower_than({'S': 43})
@@ -134,6 +143,8 @@ def test_encrypted_volume_setup_one_hidden_no_lock_device_slot(C, use_slot):
assert C.NK_lock_hidden_volume() == DeviceErrorCode.STATUS_OK
+@pytest.mark.hidden
+@pytest.mark.PWS
def test_password_safe_slot_name_corruption(C):
skip_if_device_version_lower_than({'S': 43})
volumes_to_setup = 4
@@ -204,40 +215,56 @@ def test_password_safe_slot_name_corruption(C):
check_volumes_correctness(C)
check_PWS_correctness(C)
+
+@pytest.mark.hidden
def test_hidden_volume_corruption(C):
# bug: this should return error without unlocking encrypted volume each hidden volume lock, but it does not
- assert C.NK_lock_encrypted_volume() == DeviceErrorCode.STATUS_OK
- assert C.NK_unlock_encrypted_volume(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+ skip_if_device_version_lower_than({'S': 43})
hidden_volume_password = b'hiddenpassword'
p = lambda i: hidden_volume_password + bb(str(i))
- for i in range(4):
+ volumes_to_setup = 4
+ for i in range(volumes_to_setup):
+ assert C.NK_create_hidden_volume(i, 20 + i * 10, 20 + i * 10 + i + 1, p(i)) == DeviceErrorCode.STATUS_OK
+ assert C.NK_unlock_hidden_volume(p(i)) == DeviceErrorCode.STATUS_OK
+ assert C.NK_lock_hidden_volume() == DeviceErrorCode.STATUS_OK
+
+ assert C.NK_lock_encrypted_volume() == DeviceErrorCode.STATUS_OK
+
+ assert C.NK_unlock_encrypted_volume(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+ for i in range(volumes_to_setup):
assert C.NK_unlock_encrypted_volume(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
assert C.NK_unlock_hidden_volume(p(i)) == DeviceErrorCode.STATUS_OK
wait(2)
assert C.NK_lock_hidden_volume() == DeviceErrorCode.STATUS_OK
+
+@pytest.mark.unencrypted
def test_unencrypted_volume_set_read_only(C):
skip_if_device_version_lower_than({'S': 43})
assert C.NK_lock_device() == DeviceErrorCode.STATUS_OK
assert C.NK_set_unencrypted_read_only(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+@pytest.mark.unencrypted
def test_unencrypted_volume_set_read_write(C):
skip_if_device_version_lower_than({'S': 43})
assert C.NK_lock_device() == DeviceErrorCode.STATUS_OK
assert C.NK_set_unencrypted_read_write(DefaultPasswords.USER) == DeviceErrorCode.STATUS_OK
+@pytest.mark.other
def test_export_firmware(C):
skip_if_device_version_lower_than({'S': 43})
assert C.NK_export_firmware(DefaultPasswords.ADMIN) == DeviceErrorCode.STATUS_OK
+@pytest.mark.other
def test_clear_new_sd_card_notification(C):
skip_if_device_version_lower_than({'S': 43})
assert C.NK_clear_new_sd_card_warning(DefaultPasswords.ADMIN) == DeviceErrorCode.STATUS_OK
+@pytest.mark.encrypted
@pytest.mark.slowtest
@pytest.mark.skip(reason='long test (about 1h)')
def test_fill_SD_card(C):
@@ -252,6 +279,8 @@ def test_fill_SD_card(C):
wait(5)
+@pytest.mark.other
+@pytest.mark.info
def test_get_busy_progress_on_idle(C):
skip_if_device_version_lower_than({'S': 43})
value = C.NK_get_progress_bar_value()
@@ -259,6 +288,7 @@ def test_get_busy_progress_on_idle(C):
assert C.NK_get_last_command_status() == DeviceErrorCode.STATUS_OK
+@pytest.mark.update
def test_change_update_password(C):
skip_if_device_version_lower_than({'S': 43})
wrong_password = b'aaaaaaaaaaa'
@@ -267,6 +297,7 @@ def test_change_update_password(C):
assert C.NK_change_update_password(DefaultPasswords.UPDATE_TEMP, DefaultPasswords.UPDATE) == DeviceErrorCode.STATUS_OK
+@pytest.mark.other
def test_send_startup(C):
skip_if_device_version_lower_than({'S': 43})
time_seconds_from_epoch = 0 # FIXME set proper date