diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-09-20 08:42:54 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2017-10-04 19:19:57 +0200 |
commit | 1184f21319d6bfda2aa81e4170f9559a86a8fc6e (patch) | |
tree | b04c83ee360559769ba4d56e0a05e83e7128ba95 /unittest/test_storage.py | |
parent | 7f7cfeb45b579204e0bc94bea37e2c810d2e5ec9 (diff) | |
download | libnitrokey-1184f21319d6bfda2aa81e4170f9559a86a8fc6e.tar.gz libnitrokey-1184f21319d6bfda2aa81e4170f9559a86a8fc6e.tar.bz2 |
Organize tests into categories
... by adding pytest marks.
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'unittest/test_storage.py')
-rw-r--r-- | unittest/test_storage.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/unittest/test_storage.py b/unittest/test_storage.py index 6671f5b..ec4004f 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,6 +215,8 @@ 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 @@ -216,28 +229,34 @@ def test_hidden_volume_corruption(C): 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 +271,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 +280,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 +289,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 |