From ac52c308f36addfdf86a706e9add54b7020c3e11 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 19 Jul 2021 12:27:54 -0400 Subject: [PATCH] Tests: Mark slow tests with @pytest.mark.slow This allows you to skip slow tests by running `pytest -m 'not slow'`. --- .../monkey_island/cc/resources/test_configuration_import.py | 1 + .../cc/services/attack/test_mitre_api_interface.py | 3 +++ .../monkey_island/cc/services/utils/test_config_encryption.py | 4 ++++ pyproject.toml | 1 + 4 files changed, 9 insertions(+) diff --git a/monkey/tests/unit_tests/monkey_island/cc/resources/test_configuration_import.py b/monkey/tests/unit_tests/monkey_island/cc/resources/test_configuration_import.py index ed1d908cf..e9672ebdf 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/resources/test_configuration_import.py +++ b/monkey/tests/unit_tests/monkey_island/cc/resources/test_configuration_import.py @@ -13,6 +13,7 @@ def test_is_config_encrypted__json(monkey_config_json): assert not ConfigurationImport.is_config_encrypted(monkey_config_json) +@pytest.mark.slow def test_is_config_encrypted__ciphertext(monkey_config_json): encrypted_config = encrypt_string(monkey_config_json, PASSWORD) assert ConfigurationImport.is_config_encrypted(encrypted_config) diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/attack/test_mitre_api_interface.py b/monkey/tests/unit_tests/monkey_island/cc/services/attack/test_mitre_api_interface.py index b6b9acbc7..f93afc8d5 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/attack/test_mitre_api_interface.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/attack/test_mitre_api_interface.py @@ -1,6 +1,9 @@ +import pytest + from monkey_island.cc.services.attack.mitre_api_interface import MitreApiInterface +@pytest.mark.slow def test_get_all_mitigations(): mitigations = MitreApiInterface.get_all_mitigations() assert len(mitigations.items()) >= 282 diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/utils/test_config_encryption.py b/monkey/tests/unit_tests/monkey_island/cc/services/utils/test_config_encryption.py index 086b30109..fd3191f50 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/utils/test_config_encryption.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/utils/test_config_encryption.py @@ -16,21 +16,25 @@ PASSWORD = "hello123" INCORRECT_PASSWORD = "goodbye321" +@pytest.mark.slow def test_encrypt_decrypt_string(monkey_config_json): encrypted_config = encrypt_string(monkey_config_json, PASSWORD) assert decrypt_ciphertext(encrypted_config, PASSWORD) == monkey_config_json +@pytest.mark.slow def test_decrypt_string__wrong_password(monkey_config_json): with pytest.raises(InvalidCredentialsError): decrypt_ciphertext(VALID_CIPHER_TEXT, INCORRECT_PASSWORD) +@pytest.mark.slow def test_decrypt_string__malformed_corrupted(): with pytest.raises(ValueError): decrypt_ciphertext(MALFORMED_CIPHER_TEXT_CORRUPTED, PASSWORD) +@pytest.mark.slow def test_decrypt_string__no_password(monkey_config_json): with pytest.raises(InvalidCredentialsError): decrypt_ciphertext(VALID_CIPHER_TEXT, "") diff --git a/pyproject.toml b/pyproject.toml index 319c4cc1f..05c8dfe81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ log_cli_format = "%(asctime)s [%(levelname)s] %(module)s.%(funcName)s.%(lineno)d log_cli_date_format = "%H:%M:%S" addopts = "-v --capture=sys tests/unit_tests" norecursedirs = "node_modules dist" +markers = ["slow: mark test as slow"] [tool.vulture] exclude = ["monkey/monkey_island/cc/ui/", "monkey/tests/"]