diff --git a/monkey/monkey_island/cc/test_common/fixtures/__init__.py b/monkey/monkey_island/cc/test_common/fixtures/__init__.py deleted file mode 100644 index fd208655a..000000000 --- a/monkey/monkey_island/cc/test_common/fixtures/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# Without these imports pytests can't use fixtures, -# because they are not found -from .fixture_enum import FixtureEnum # noqa: F401 -from .mongomock_fixtures import * # noqa: F401,F403 diff --git a/monkey/monkey_island/cc/test_common/fixtures/fixture_enum.py b/monkey/monkey_island/cc/test_common/fixtures/fixture_enum.py deleted file mode 100644 index c0bc1f1aa..000000000 --- a/monkey/monkey_island/cc/test_common/fixtures/fixture_enum.py +++ /dev/null @@ -1,2 +0,0 @@ -class FixtureEnum: - USES_DATABASE = "uses_database" diff --git a/monkey/monkey_island/cc/test_common/__init__.py b/monkey/tests/__init__.py similarity index 100% rename from monkey/monkey_island/cc/test_common/__init__.py rename to monkey/tests/__init__.py diff --git a/monkey/tests/monkey_island/cc/conftest.py b/monkey/tests/monkey_island/cc/conftest.py deleted file mode 100644 index 0ed1533ab..000000000 --- a/monkey/tests/monkey_island/cc/conftest.py +++ /dev/null @@ -1,3 +0,0 @@ -# Without these imports pytests can't use fixtures, -# because they are not found -from monkey_island.cc.test_common.fixtures import * # noqa: F401,F403 diff --git a/monkey/monkey_island/cc/test_common/profiling/README.md b/monkey/tests/profiling/README.md similarity index 76% rename from monkey/monkey_island/cc/test_common/profiling/README.md rename to monkey/tests/profiling/README.md index d0cb92bfa..d22d2188c 100644 --- a/monkey/monkey_island/cc/test_common/profiling/README.md +++ b/monkey/tests/profiling/README.md @@ -1,9 +1,9 @@ # Profiling island -To profile specific methods on island a `@profile(sort_args=['cumulative'], print_args=[100])` -decorator can be used. +To profile specific methods on island a `@profile(sort_args=['cumulative'], print_args=[100])` +decorator can be used. Use it as a parameterised decorator(`@profile()`). After decorated method is used, a file will appear in a directory provided in `profiler_decorator.py`. Filename describes the path of the method that was profiled. For example if method `monkey_island/cc/resources/netmap.get` -was profiled, then the results of this profiling will appear in +was profiled, then the results of this profiling will appear in `monkey_island_cc_resources_netmap_get`. diff --git a/monkey/monkey_island/cc/test_common/profiling/profiler_decorator.py b/monkey/tests/profiling/profiler_decorator.py similarity index 100% rename from monkey/monkey_island/cc/test_common/profiling/profiler_decorator.py rename to monkey/tests/profiling/profiler_decorator.py diff --git a/monkey/tests/unit_tests/__init__.py b/monkey/tests/unit_tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/monkey/tests/common/cloud/aws/test_aws_instance.py b/monkey/tests/unit_tests/common/cloud/aws/test_aws_instance.py similarity index 100% rename from monkey/tests/common/cloud/aws/test_aws_instance.py rename to monkey/tests/unit_tests/common/cloud/aws/test_aws_instance.py diff --git a/monkey/tests/common/cloud/aws/test_aws_service.py b/monkey/tests/unit_tests/common/cloud/aws/test_aws_service.py similarity index 100% rename from monkey/tests/common/cloud/aws/test_aws_service.py rename to monkey/tests/unit_tests/common/cloud/aws/test_aws_service.py diff --git a/monkey/tests/common/cloud/azure/test_azure_instance.py b/monkey/tests/unit_tests/common/cloud/azure/test_azure_instance.py similarity index 100% rename from monkey/tests/common/cloud/azure/test_azure_instance.py rename to monkey/tests/unit_tests/common/cloud/azure/test_azure_instance.py diff --git a/monkey/tests/common/cloud/gcp/test_gcp_instance.py b/monkey/tests/unit_tests/common/cloud/gcp/test_gcp_instance.py similarity index 100% rename from monkey/tests/common/cloud/gcp/test_gcp_instance.py rename to monkey/tests/unit_tests/common/cloud/gcp/test_gcp_instance.py diff --git a/monkey/tests/common/network/test_network_utils.py b/monkey/tests/unit_tests/common/network/test_network_utils.py similarity index 100% rename from monkey/tests/common/network/test_network_utils.py rename to monkey/tests/unit_tests/common/network/test_network_utils.py diff --git a/monkey/tests/common/network/test_segmentation_utils.py b/monkey/tests/unit_tests/common/network/test_segmentation_utils.py similarity index 100% rename from monkey/tests/common/network/test_segmentation_utils.py rename to monkey/tests/unit_tests/common/network/test_segmentation_utils.py diff --git a/monkey/tests/common/utils/test_shellcode_obfuscator.py b/monkey/tests/unit_tests/common/utils/test_shellcode_obfuscator.py similarity index 100% rename from monkey/tests/common/utils/test_shellcode_obfuscator.py rename to monkey/tests/unit_tests/common/utils/test_shellcode_obfuscator.py diff --git a/monkey/tests/infection_monkey/exploit/test_zerologon.py b/monkey/tests/unit_tests/infection_monkey/exploit/test_zerologon.py similarity index 100% rename from monkey/tests/infection_monkey/exploit/test_zerologon.py rename to monkey/tests/unit_tests/infection_monkey/exploit/test_zerologon.py diff --git a/monkey/tests/infection_monkey/exploit/tools/test_helpers.py b/monkey/tests/unit_tests/infection_monkey/exploit/tools/test_helpers.py similarity index 100% rename from monkey/tests/infection_monkey/exploit/tools/test_helpers.py rename to monkey/tests/unit_tests/infection_monkey/exploit/tools/test_helpers.py diff --git a/monkey/tests/infection_monkey/exploit/tools/test_payload.py b/monkey/tests/unit_tests/infection_monkey/exploit/tools/test_payload.py similarity index 100% rename from monkey/tests/infection_monkey/exploit/tools/test_payload.py rename to monkey/tests/unit_tests/infection_monkey/exploit/tools/test_payload.py diff --git a/monkey/tests/infection_monkey/exploit/zerologon_utils/test_vuln_assessment.py b/monkey/tests/unit_tests/infection_monkey/exploit/zerologon_utils/test_vuln_assessment.py similarity index 100% rename from monkey/tests/infection_monkey/exploit/zerologon_utils/test_vuln_assessment.py rename to monkey/tests/unit_tests/infection_monkey/exploit/zerologon_utils/test_vuln_assessment.py diff --git a/monkey/tests/infection_monkey/model/test_victim_host_generator.py b/monkey/tests/unit_tests/infection_monkey/model/test_victim_host_generator.py similarity index 100% rename from monkey/tests/infection_monkey/model/test_victim_host_generator.py rename to monkey/tests/unit_tests/infection_monkey/model/test_victim_host_generator.py diff --git a/monkey/tests/infection_monkey/post_breach/actions/test_users_custom_pba.py b/monkey/tests/unit_tests/infection_monkey/post_breach/actions/test_users_custom_pba.py similarity index 100% rename from monkey/tests/infection_monkey/post_breach/actions/test_users_custom_pba.py rename to monkey/tests/unit_tests/infection_monkey/post_breach/actions/test_users_custom_pba.py diff --git a/monkey/tests/infection_monkey/system_info/windows_cred_collector/test_pypykatz_handler.py b/monkey/tests/unit_tests/infection_monkey/system_info/windows_cred_collector/test_pypykatz_handler.py similarity index 100% rename from monkey/tests/infection_monkey/system_info/windows_cred_collector/test_pypykatz_handler.py rename to monkey/tests/unit_tests/infection_monkey/system_info/windows_cred_collector/test_pypykatz_handler.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_attack_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_attack_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_attack_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_attack_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_t1005_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1005_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_t1005_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1005_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_t1035_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1035_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_t1035_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1035_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_t1064_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1064_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_t1064_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1064_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_t1105_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1105_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_t1105_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1105_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_t1106_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1106_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_t1106_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1106_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_t1107_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1107_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_t1107_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1107_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_t1129_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1129_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_t1129_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1129_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_t1197_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1197_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_t1197_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1197_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_t1222_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1222_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_t1222_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_t1222_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_usage_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_usage_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_usage_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_usage_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/attack/test_victim_host_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_victim_host_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/attack/test_victim_host_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/attack/test_victim_host_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/conftest.py b/monkey/tests/unit_tests/infection_monkey/telemetry/conftest.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/conftest.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/conftest.py diff --git a/monkey/tests/infection_monkey/telemetry/test_exploit_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/test_exploit_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/test_exploit_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/test_exploit_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/test_post_breach_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/test_post_breach_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/test_post_breach_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/test_post_breach_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/test_scan_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/test_scan_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/test_scan_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/test_scan_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/test_state_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/test_state_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/test_state_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/test_state_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/test_system_info_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/test_system_info_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/test_system_info_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/test_system_info_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/test_trace_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/test_trace_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/test_trace_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/test_trace_telem.py diff --git a/monkey/tests/infection_monkey/telemetry/test_tunnel_telem.py b/monkey/tests/unit_tests/infection_monkey/telemetry/test_tunnel_telem.py similarity index 100% rename from monkey/tests/infection_monkey/telemetry/test_tunnel_telem.py rename to monkey/tests/unit_tests/infection_monkey/telemetry/test_tunnel_telem.py diff --git a/monkey/tests/infection_monkey/utils/linux/test_users.py b/monkey/tests/unit_tests/infection_monkey/utils/linux/test_users.py similarity index 100% rename from monkey/tests/infection_monkey/utils/linux/test_users.py rename to monkey/tests/unit_tests/infection_monkey/utils/linux/test_users.py diff --git a/monkey/tests/infection_monkey/utils/plugins/test_plugin.py b/monkey/tests/unit_tests/infection_monkey/utils/plugins/test_plugin.py similarity index 100% rename from monkey/tests/infection_monkey/utils/plugins/test_plugin.py rename to monkey/tests/unit_tests/infection_monkey/utils/plugins/test_plugin.py diff --git a/monkey/tests/infection_monkey/utils/test_auto_new_user_factory.py b/monkey/tests/unit_tests/infection_monkey/utils/test_auto_new_user_factory.py similarity index 100% rename from monkey/tests/infection_monkey/utils/test_auto_new_user_factory.py rename to monkey/tests/unit_tests/infection_monkey/utils/test_auto_new_user_factory.py diff --git a/monkey/tests/infection_monkey/utils/test_random_password_generator.py b/monkey/tests/unit_tests/infection_monkey/utils/test_random_password_generator.py similarity index 100% rename from monkey/tests/infection_monkey/utils/test_random_password_generator.py rename to monkey/tests/unit_tests/infection_monkey/utils/test_random_password_generator.py diff --git a/monkey/tests/unit_tests/monkey_island/__init__.py b/monkey/tests/unit_tests/monkey_island/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/monkey/tests/unit_tests/monkey_island/cc/__init__.py b/monkey/tests/unit_tests/monkey_island/cc/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/monkey/tests/unit_tests/monkey_island/cc/conftest.py b/monkey/tests/unit_tests/monkey_island/cc/conftest.py new file mode 100644 index 000000000..af35c9b25 --- /dev/null +++ b/monkey/tests/unit_tests/monkey_island/cc/conftest.py @@ -0,0 +1,3 @@ +# Without these imports pytests can't use fixtures, +# because they are not found +from tests.unit_tests.monkey_island.cc.mongomock_fixtures import * # noqa: F401,F403 diff --git a/monkey/tests/monkey_island/cc/environment/conftest.py b/monkey/tests/unit_tests/monkey_island/cc/environment/conftest.py similarity index 100% rename from monkey/tests/monkey_island/cc/environment/conftest.py rename to monkey/tests/unit_tests/monkey_island/cc/environment/conftest.py diff --git a/monkey/tests/monkey_island/cc/environment/test_environment.py b/monkey/tests/unit_tests/monkey_island/cc/environment/test_environment.py similarity index 100% rename from monkey/tests/monkey_island/cc/environment/test_environment.py rename to monkey/tests/unit_tests/monkey_island/cc/environment/test_environment.py diff --git a/monkey/tests/monkey_island/cc/environment/test_environment_config.py b/monkey/tests/unit_tests/monkey_island/cc/environment/test_environment_config.py similarity index 100% rename from monkey/tests/monkey_island/cc/environment/test_environment_config.py rename to monkey/tests/unit_tests/monkey_island/cc/environment/test_environment_config.py diff --git a/monkey/tests/monkey_island/cc/environment/test_user_creds.py b/monkey/tests/unit_tests/monkey_island/cc/environment/test_user_creds.py similarity index 100% rename from monkey/tests/monkey_island/cc/environment/test_user_creds.py rename to monkey/tests/unit_tests/monkey_island/cc/environment/test_user_creds.py diff --git a/monkey/tests/monkey_island/cc/models/test_monkey.py b/monkey/tests/unit_tests/monkey_island/cc/models/test_monkey.py similarity index 92% rename from monkey/tests/monkey_island/cc/models/test_monkey.py rename to monkey/tests/unit_tests/monkey_island/cc/models/test_monkey.py index 542309ae5..2df8be4dd 100644 --- a/monkey/tests/monkey_island/cc/models/test_monkey.py +++ b/monkey/tests/unit_tests/monkey_island/cc/models/test_monkey.py @@ -6,13 +6,12 @@ import pytest from monkey_island.cc.models.monkey import Monkey, MonkeyNotFoundError from monkey_island.cc.models.monkey_ttl import MonkeyTtl -from monkey_island.cc.test_common.fixtures import FixtureEnum logger = logging.getLogger(__name__) class TestMonkey: - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_is_dead(self): # Arrange alive_monkey_ttl = MonkeyTtl.create_ttl_expire_in(30) @@ -38,7 +37,7 @@ class TestMonkey: assert mia_monkey.is_dead() assert not alive_monkey.is_dead() - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_ttl_renewal(self): # Arrange monkey = Monkey(guid=str(uuid.uuid4())) @@ -49,7 +48,7 @@ class TestMonkey: monkey.renew_ttl() assert monkey.ttl_ref - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_get_single_monkey_by_id(self): # Arrange a_monkey = Monkey(guid=str(uuid.uuid4())) @@ -63,7 +62,7 @@ class TestMonkey: with pytest.raises(MonkeyNotFoundError) as _: _ = Monkey.get_single_monkey_by_id("abcdefabcdefabcdefabcdef") - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_get_os(self): linux_monkey = Monkey( guid=str(uuid.uuid4()), @@ -79,7 +78,7 @@ class TestMonkey: assert 1 == len([m for m in Monkey.objects() if m.get_os() == "linux"]) assert 1 == len([m for m in Monkey.objects() if m.get_os() == "unknown"]) - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_get_tunneled_monkeys(self): linux_monkey = Monkey(guid=str(uuid.uuid4()), description="Linux shay-Virtual-Machine") windows_monkey = Monkey( @@ -100,7 +99,7 @@ class TestMonkey: ) assert test - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_get_label_by_id(self): hostname_example = "a_hostname" ip_example = "1.1.1.1" @@ -148,7 +147,7 @@ class TestMonkey: assert cache_info_after_query_3.hits == 1 assert cache_info_after_query_3.misses == 2 - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_is_monkey(self): a_monkey = Monkey(guid=str(uuid.uuid4())) a_monkey.save() diff --git a/monkey/tests/monkey_island/cc/models/zero_trust/test_event.py b/monkey/tests/unit_tests/monkey_island/cc/models/zero_trust/test_event.py similarity index 100% rename from monkey/tests/monkey_island/cc/models/zero_trust/test_event.py rename to monkey/tests/unit_tests/monkey_island/cc/models/zero_trust/test_event.py diff --git a/monkey/tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py b/monkey/tests/unit_tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py similarity index 91% rename from monkey/tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py rename to monkey/tests/unit_tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py index f7cf39d22..ec0f741df 100644 --- a/monkey/tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py +++ b/monkey/tests/unit_tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py @@ -6,14 +6,13 @@ from monkey_island.cc.models.zero_trust.event import Event from monkey_island.cc.models.zero_trust.finding import Finding from monkey_island.cc.models.zero_trust.monkey_finding import MonkeyFinding from monkey_island.cc.models.zero_trust.monkey_finding_details import MonkeyFindingDetails -from monkey_island.cc.test_common.fixtures import FixtureEnum MONKEY_FINDING_DETAIL_MOCK = MonkeyFindingDetails() MONKEY_FINDING_DETAIL_MOCK.events = ["mock1", "mock2"] class TestMonkeyFinding: - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_save_finding_validation(self): with pytest.raises(ValidationError): _ = MonkeyFinding.save_finding( @@ -22,7 +21,7 @@ class TestMonkeyFinding: detail_ref=MONKEY_FINDING_DETAIL_MOCK, ) - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_save_finding_sanity(self): assert len(Finding.objects(test=zero_trust_consts.TEST_SEGMENTATION)) == 0 diff --git a/monkey/tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py b/monkey/tests/unit_tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py similarity index 91% rename from monkey/tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py rename to monkey/tests/unit_tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py index 07809cd90..a9ce8837e 100644 --- a/monkey/tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py +++ b/monkey/tests/unit_tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py @@ -7,7 +7,6 @@ from monkey_island.cc.models.zero_trust.monkey_finding_details import MonkeyFind from monkey_island.cc.models.zero_trust.scoutsuite_finding import ScoutSuiteFinding from monkey_island.cc.models.zero_trust.scoutsuite_finding_details import ScoutSuiteFindingDetails from monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data import RULES -from monkey_island.cc.test_common.fixtures import FixtureEnum MONKEY_FINDING_DETAIL_MOCK = MonkeyFindingDetails() MONKEY_FINDING_DETAIL_MOCK.events = ["mock1", "mock2"] @@ -16,7 +15,7 @@ SCOUTSUITE_FINDING_DETAIL_MOCK.scoutsuite_rules = [] class TestScoutSuiteFinding: - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_save_finding_validation(self): with pytest.raises(ValidationError): _ = ScoutSuiteFinding.save_finding( @@ -25,7 +24,7 @@ class TestScoutSuiteFinding: detail_ref=SCOUTSUITE_FINDING_DETAIL_MOCK, ) - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_save_finding_sanity(self): assert len(Finding.objects(test=zero_trust_consts.TEST_SEGMENTATION)) == 0 diff --git a/monkey/monkey_island/cc/test_common/fixtures/mongomock_fixtures.py b/monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py similarity index 93% rename from monkey/monkey_island/cc/test_common/fixtures/mongomock_fixtures.py rename to monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py index 079c91fb7..26a41685a 100644 --- a/monkey/monkey_island/cc/test_common/fixtures/mongomock_fixtures.py +++ b/monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py @@ -6,7 +6,7 @@ from monkey_island.cc.models.edge import Edge from monkey_island.cc.models.zero_trust.finding import Finding -@pytest.fixture(scope="session", autouse=True) +@pytest.fixture(scope="module", autouse=True) def change_to_mongo_mock(): # Make sure tests are working with mongomock mongoengine.disconnect() diff --git a/monkey/tests/monkey_island/cc/resources/test_bootloader.py b/monkey/tests/unit_tests/monkey_island/cc/resources/test_bootloader.py similarity index 100% rename from monkey/tests/monkey_island/cc/resources/test_bootloader.py rename to monkey/tests/unit_tests/monkey_island/cc/resources/test_bootloader.py diff --git a/monkey/tests/monkey_island/cc/server_utils/test_island_logger.py b/monkey/tests/unit_tests/monkey_island/cc/server_utils/test_island_logger.py similarity index 100% rename from monkey/tests/monkey_island/cc/server_utils/test_island_logger.py rename to monkey/tests/unit_tests/monkey_island/cc/server_utils/test_island_logger.py diff --git a/monkey/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 similarity index 100% rename from monkey/tests/monkey_island/cc/services/attack/test_mitre_api_interface.py rename to monkey/tests/unit_tests/monkey_island/cc/services/attack/test_mitre_api_interface.py diff --git a/monkey/tests/monkey_island/cc/services/edge/test_displayed_edge_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/edge/test_displayed_edge_service.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/edge/test_displayed_edge_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/edge/test_displayed_edge_service.py diff --git a/monkey/tests/monkey_island/cc/services/edge/test_edge_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/edge/test_edge_service.py similarity index 93% rename from monkey/tests/monkey_island/cc/services/edge/test_edge_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/edge/test_edge_service.py index 99ecf52d7..8754d5fac 100644 --- a/monkey/tests/monkey_island/cc/services/edge/test_edge_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/edge/test_edge_service.py @@ -5,13 +5,12 @@ from mongomock import ObjectId from monkey_island.cc.models.edge import Edge from monkey_island.cc.services.edge.edge import EdgeService -from monkey_island.cc.test_common.fixtures import FixtureEnum logger = logging.getLogger(__name__) class TestEdgeService: - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_get_or_create_edge(self): src_id = ObjectId() dst_id = ObjectId() diff --git a/monkey/tests/monkey_island/cc/services/reporting/test_report.py b/monkey/tests/unit_tests/monkey_island/cc/services/reporting/test_report.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/reporting/test_report.py rename to monkey/tests/unit_tests/monkey_island/cc/services/reporting/test_report.py diff --git a/monkey/tests/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_environment_telemetry_processing.py b/monkey/tests/unit_tests/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_environment_telemetry_processing.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_environment_telemetry_processing.py rename to monkey/tests/unit_tests/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_environment_telemetry_processing.py diff --git a/monkey/tests/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_system_info_telemetry_dispatcher.py b/monkey/tests/unit_tests/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_system_info_telemetry_dispatcher.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_system_info_telemetry_dispatcher.py rename to monkey/tests/unit_tests/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_system_info_telemetry_dispatcher.py diff --git a/monkey/tests/monkey_island/cc/services/telemetry/processing/test_post_breach.py b/monkey/tests/unit_tests/monkey_island/cc/services/telemetry/processing/test_post_breach.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/telemetry/processing/test_post_breach.py rename to monkey/tests/unit_tests/monkey_island/cc/services/telemetry/processing/test_post_breach.py diff --git a/monkey/tests/monkey_island/cc/services/telemetry/zero_trust_checks/test_segmentation_checks.py b/monkey/tests/unit_tests/monkey_island/cc/services/telemetry/zero_trust_checks/test_segmentation_checks.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/telemetry/zero_trust_checks/test_segmentation_checks.py rename to monkey/tests/unit_tests/monkey_island/cc/services/telemetry/zero_trust_checks/test_segmentation_checks.py diff --git a/monkey/tests/monkey_island/cc/services/test_bootloader_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_bootloader_service.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/test_bootloader_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/test_bootloader_service.py diff --git a/monkey/tests/monkey_island/cc/services/test_config.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_config.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/test_config.py rename to monkey/tests/unit_tests/monkey_island/cc/services/test_config.py diff --git a/monkey/tests/monkey_island/cc/services/test_post_breach_files.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_post_breach_files.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/test_post_breach_files.py rename to monkey/tests/unit_tests/monkey_island/cc/services/test_post_breach_files.py diff --git a/monkey/tests/monkey_island/cc/services/test_representations.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_representations.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/test_representations.py rename to monkey/tests/unit_tests/monkey_island/cc/services/test_representations.py diff --git a/monkey/tests/monkey_island/cc/services/utils/test_node_states.py b/monkey/tests/unit_tests/monkey_island/cc/services/utils/test_node_states.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/utils/test_node_states.py rename to monkey/tests/unit_tests/monkey_island/cc/services/utils/test_node_states.py diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_details_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_details_service.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_details_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_details_service.py diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py similarity index 94% rename from monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py index b92a52ae1..6248be02c 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py @@ -9,7 +9,6 @@ from monkey_island.cc.models.zero_trust.monkey_finding import MonkeyFinding from monkey_island.cc.services.zero_trust.monkey_findings.monkey_zt_finding_service import ( MonkeyZTFindingService, ) -from monkey_island.cc.test_common.fixtures import FixtureEnum EVENTS = [ Event.create_event( @@ -40,7 +39,7 @@ STATUS = [ class TestMonkeyZTFindingService: - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_create_or_add_to_existing_creation(self): # Create new finding MonkeyZTFindingService.create_or_add_to_existing( @@ -55,7 +54,7 @@ class TestMonkeyZTFindingService: assert len(finding_details.events) == 1 assert finding_details.events[0].message == EVENTS[0].message - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_create_or_add_to_existing_addition(self): # Create new finding MonkeyZTFindingService.create_or_add_to_existing( diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/data_parsing/test_rule_parser.py b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/scoutsuite/data_parsing/test_rule_parser.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/data_parsing/test_rule_parser.py rename to monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/scoutsuite/data_parsing/test_rule_parser.py diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py similarity index 91% rename from monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py index 00eae32e7..faea76f4f 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py @@ -10,14 +10,13 @@ from monkey_island.cc.services.config import ConfigService from monkey_island.cc.services.zero_trust.scoutsuite.scoutsuite_auth_service import ( is_aws_keys_setup, ) -from monkey_island.cc.test_common.fixtures import FixtureEnum class MockObject: pass -@pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) +@pytest.mark.usefixtures("uses_database") def test_is_aws_keys_setup(tmp_path): # Mock default configuration ConfigService.init_default_config() diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_rule_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_rule_service.py similarity index 100% rename from monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_rule_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_rule_service.py diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py similarity index 94% rename from monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py index de7b5635e..51598c1a9 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py @@ -9,11 +9,10 @@ from monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data im RULES, SCOUTSUITE_FINDINGS, ) -from monkey_island.cc.test_common.fixtures import FixtureEnum class TestScoutSuiteZTFindingService: - @pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) + @pytest.mark.usefixtures("uses_database") def test_process_rule(self): # Creates new PermissiveFirewallRules finding with a rule ScoutSuiteZTFindingService.process_rule(SCOUTSUITE_FINDINGS[0], RULES[0]) diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py similarity index 93% rename from monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py index 37d432bf4..81bee7d95 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py @@ -22,10 +22,9 @@ from monkey_island.cc.services.zero_trust.zero_trust_report.finding_service impo EnrichedFinding, FindingService, ) -from monkey_island.cc.test_common.fixtures.fixture_enum import FixtureEnum -@pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) +@pytest.mark.usefixtures("uses_database") def test_get_all_findings(): get_scoutsuite_finding_dto().save() get_monkey_finding_dto().save() diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py similarity index 96% rename from monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py index 3b6da848f..34c8c4975 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py @@ -16,10 +16,9 @@ from monkey_island.cc.services.zero_trust.zero_trust_report.pillar_service impor from monkey_island.cc.services.zero_trust.zero_trust_report.test_common.example_finding_data import ( # noqa: E501 save_example_findings, ) -from monkey_island.cc.test_common.fixtures import FixtureEnum -@pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) +@pytest.mark.usefixtures("uses_database") def test_get_pillars_grades(): save_example_findings() expected_grades = _get_expected_pillar_grades() @@ -97,7 +96,7 @@ def _get_cnt_of_tests_in_pillar(pillar: str): return len(tests_in_pillar) -@pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) +@pytest.mark.usefixtures("uses_database") def test_get_pillars_to_statuses(): # Test empty database expected = { diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py similarity index 96% rename from monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py rename to monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py index 7eb6b19cd..37721e3dc 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py @@ -8,7 +8,6 @@ from monkey_island.cc.services.zero_trust.test_common.finding_data import ( from monkey_island.cc.services.zero_trust.zero_trust_report.principle_service import ( PrincipleService, ) -from monkey_island.cc.test_common.fixtures import FixtureEnum EXPECTED_DICT = { "test_pillar1": [ @@ -39,7 +38,7 @@ EXPECTED_DICT = { } -@pytest.mark.usefixtures(FixtureEnum.USES_DATABASE) +@pytest.mark.usefixtures("uses_database") def test_get_principles_status(): TEST_PILLAR1 = "test_pillar1" TEST_PILLAR2 = "test_pillar2" diff --git a/monkey/tests/monkey_island/cc/test_consts.py b/monkey/tests/unit_tests/monkey_island/cc/test_consts.py similarity index 100% rename from monkey/tests/monkey_island/cc/test_consts.py rename to monkey/tests/unit_tests/monkey_island/cc/test_consts.py diff --git a/monkey/tests/monkey_island/cc/test_encryptor.py b/monkey/tests/unit_tests/monkey_island/cc/test_encryptor.py similarity index 100% rename from monkey/tests/monkey_island/cc/test_encryptor.py rename to monkey/tests/unit_tests/monkey_island/cc/test_encryptor.py diff --git a/monkey/tests/monkey_island/conftest.py b/monkey/tests/unit_tests/monkey_island/conftest.py similarity index 100% rename from monkey/tests/monkey_island/conftest.py rename to monkey/tests/unit_tests/monkey_island/conftest.py diff --git a/monkey/tests/monkey_island/test_config_loader.py b/monkey/tests/unit_tests/monkey_island/test_config_loader.py similarity index 100% rename from monkey/tests/monkey_island/test_config_loader.py rename to monkey/tests/unit_tests/monkey_island/test_config_loader.py