From bf082d36ef81528ae9df2736fed529aae1a593db Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 5 Oct 2021 12:14:10 -0400 Subject: [PATCH] Tests: Mark encryption tests as slow --- .../cc/models/telemetries/test_telemetry_dal.py | 10 ++++------ .../field_encryptors/test_string_list_encryptor.py | 4 ++++ .../encryption/test_data_store_encryptor.py | 4 ++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/models/telemetries/test_telemetry_dal.py b/monkey/tests/unit_tests/monkey_island/cc/models/telemetries/test_telemetry_dal.py index f2b81eb24..77003ec8f 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/models/telemetries/test_telemetry_dal.py +++ b/monkey/tests/unit_tests/monkey_island/cc/models/telemetries/test_telemetry_dal.py @@ -51,6 +51,7 @@ def fake_mongo(monkeypatch): monkeypatch.setattr("monkey_island.cc.models.telemetries.telemetry_dal.mongo", mongo) +@pytest.mark.slow @pytest.mark.usefixtures("uses_database", "uses_encryptor") def test_telemetry_encryption(): secret_keys = ["password", "lm_hash", "ntlm_hash"] @@ -62,20 +63,17 @@ def test_telemetry_encryption(): assert encrypted_telemetry["data"]["credentials"][user]["username"] == user for s in secret_keys: - assert ( - encrypted_telemetry["data"]["credentials"][user][s] != MOCK_CREDENTIALS[user][s] - ) + assert encrypted_telemetry["data"]["credentials"][user][s] != MOCK_CREDENTIALS[user][s] decrypted_telemetry = get_telemetry_by_query({})[0] for user in MOCK_CREDENTIALS.keys(): assert decrypted_telemetry["data"]["credentials"][user]["username"] == user for s in secret_keys: - assert ( - decrypted_telemetry["data"]["credentials"][user][s] == MOCK_CREDENTIALS[user][s] - ) + assert decrypted_telemetry["data"]["credentials"][user][s] == MOCK_CREDENTIALS[user][s] +@pytest.mark.slow @pytest.mark.usefixtures("uses_database", "uses_encryptor") def test_no_encryption_needed(): # Make sure telemetry save doesn't break when telemetry doesn't need encryption diff --git a/monkey/tests/unit_tests/monkey_island/cc/models/utils/field_encryptors/test_string_list_encryptor.py b/monkey/tests/unit_tests/monkey_island/cc/models/utils/field_encryptors/test_string_list_encryptor.py index 7ea21849b..e39dffd94 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/models/utils/field_encryptors/test_string_list_encryptor.py +++ b/monkey/tests/unit_tests/monkey_island/cc/models/utils/field_encryptors/test_string_list_encryptor.py @@ -1,3 +1,5 @@ +import pytest + from monkey_island.cc.server_utils.encryption.dict_encryption.field_encryptors import ( StringListEncryptor, ) @@ -6,6 +8,7 @@ MOCK_STRING_LIST = ["test_1", "test_2"] EMPTY_LIST = [] +@pytest.mark.slow def test_encryption_and_decryption(uses_encryptor): encrypted_list = StringListEncryptor.encrypt(MOCK_STRING_LIST) assert not encrypted_list == MOCK_STRING_LIST @@ -13,6 +16,7 @@ def test_encryption_and_decryption(uses_encryptor): assert decrypted_list == MOCK_STRING_LIST +@pytest.mark.slow def test_empty_list(uses_encryptor): # Tests that no errors are raised encrypted_list = StringListEncryptor.encrypt(EMPTY_LIST) diff --git a/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_data_store_encryptor.py b/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_data_store_encryptor.py index 7c379af1c..f24040c22 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_data_store_encryptor.py +++ b/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_data_store_encryptor.py @@ -11,6 +11,7 @@ PLAINTEXT = "Hello, Monkey!" MOCK_SECRET = "53CR31" +@pytest.mark.slow @pytest.mark.usefixtures("uses_encryptor") def test_encryption(data_for_tests_dir): encrypted_data = get_datastore_encryptor().encrypt(PLAINTEXT) @@ -33,10 +34,12 @@ def initialized_encryptor_dir(tmpdir): return tmpdir +@pytest.mark.slow def test_key_creation(initialized_encryptor_dir): assert (initialized_encryptor_dir / data_store_encryptor._KEY_FILENAME).isfile() +@pytest.mark.slow def test_key_removal(initialized_encryptor_dir): remove_old_datastore_key(initialized_encryptor_dir) assert not (initialized_encryptor_dir / data_store_encryptor._KEY_FILENAME).isfile() @@ -49,6 +52,7 @@ def test_key_removal__no_key(tmpdir): data_store_encryptor._factory = None +@pytest.mark.slow @pytest.mark.usefixtures("cleanup_encryptor") def test_key_file_encryption(tmpdir, monkeypatch): monkeypatch.setattr(data_store_encryptor, "_get_random_bytes", lambda: PLAINTEXT.encode())