From c85ac0f6109b7bc1fe28391d1f08c51d46965551 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Wed, 19 May 2021 09:30:20 +0300 Subject: [PATCH 1/6] Moved unit test files and profiling test decorator into test directory away from production code --- monkey/monkey_island/cc/test_common/__init__.py | 0 monkey/monkey_island/cc/test_common/fixtures/__init__.py | 4 ---- monkey/tests/monkey_island/cc/conftest.py | 2 +- .../fixtures => tests/monkey_island/cc}/fixture_enum.py | 0 monkey/tests/monkey_island/cc/models/test_monkey.py | 2 +- .../cc/models/zero_trust/test_monkey_finding.py | 2 +- .../cc/models/zero_trust/test_scoutsuite_finding.py | 2 +- .../monkey_island/cc}/mongomock_fixtures.py | 0 .../monkey_island/cc/services/edge/test_edge_service.py | 2 +- .../monkey_findings/test_monkey_zt_finding_service.py | 2 +- .../zero_trust/scoutsuite/test_scoutsuite_auth_service.py | 2 +- .../scoutsuite/test_scoutsuite_zt_finding_service.py | 2 +- .../zero_trust/zero_trust_report/test_finding_service.py | 2 +- .../zero_trust/zero_trust_report/test_pillar_service.py | 2 +- .../zero_trust/zero_trust_report/test_principle_service.py | 2 +- .../cc/test_common => tests}/profiling/README.md | 6 +++--- .../test_common => tests}/profiling/profiler_decorator.py | 0 17 files changed, 14 insertions(+), 18 deletions(-) delete mode 100644 monkey/monkey_island/cc/test_common/__init__.py delete mode 100644 monkey/monkey_island/cc/test_common/fixtures/__init__.py rename monkey/{monkey_island/cc/test_common/fixtures => tests/monkey_island/cc}/fixture_enum.py (100%) rename monkey/{monkey_island/cc/test_common/fixtures => tests/monkey_island/cc}/mongomock_fixtures.py (100%) rename monkey/{monkey_island/cc/test_common => tests}/profiling/README.md (76%) rename monkey/{monkey_island/cc/test_common => tests}/profiling/profiler_decorator.py (100%) diff --git a/monkey/monkey_island/cc/test_common/__init__.py b/monkey/monkey_island/cc/test_common/__init__.py deleted file mode 100644 index e69de29bb..000000000 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/tests/monkey_island/cc/conftest.py b/monkey/tests/monkey_island/cc/conftest.py index 0ed1533ab..b9aabe4ef 100644 --- a/monkey/tests/monkey_island/cc/conftest.py +++ b/monkey/tests/monkey_island/cc/conftest.py @@ -1,3 +1,3 @@ # Without these imports pytests can't use fixtures, # because they are not found -from monkey_island.cc.test_common.fixtures import * # noqa: F401,F403 +from tests.monkey_island.cc.mongomock_fixtures import * # noqa: F401,F403 diff --git a/monkey/monkey_island/cc/test_common/fixtures/fixture_enum.py b/monkey/tests/monkey_island/cc/fixture_enum.py similarity index 100% rename from monkey/monkey_island/cc/test_common/fixtures/fixture_enum.py rename to monkey/tests/monkey_island/cc/fixture_enum.py diff --git a/monkey/tests/monkey_island/cc/models/test_monkey.py b/monkey/tests/monkey_island/cc/models/test_monkey.py index 542309ae5..503c2a6f3 100644 --- a/monkey/tests/monkey_island/cc/models/test_monkey.py +++ b/monkey/tests/monkey_island/cc/models/test_monkey.py @@ -3,10 +3,10 @@ import uuid from time import sleep import pytest +from tests.monkey_island.cc.fixture_enum import FixtureEnum 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__) diff --git a/monkey/tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py b/monkey/tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py index f7cf39d22..04482b0de 100644 --- a/monkey/tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py +++ b/monkey/tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py @@ -1,12 +1,12 @@ import pytest from mongoengine import ValidationError +from tests.monkey_island.cc.fixture_enum import FixtureEnum import common.common_consts.zero_trust_consts as zero_trust_consts 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"] diff --git a/monkey/tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py b/monkey/tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py index 07809cd90..5c45d773e 100644 --- a/monkey/tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py +++ b/monkey/tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py @@ -1,5 +1,6 @@ import pytest from mongoengine import ValidationError +from tests.monkey_island.cc.fixture_enum import FixtureEnum import common.common_consts.zero_trust_consts as zero_trust_consts from monkey_island.cc.models.zero_trust.finding import Finding @@ -7,7 +8,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"] diff --git a/monkey/monkey_island/cc/test_common/fixtures/mongomock_fixtures.py b/monkey/tests/monkey_island/cc/mongomock_fixtures.py similarity index 100% rename from monkey/monkey_island/cc/test_common/fixtures/mongomock_fixtures.py rename to monkey/tests/monkey_island/cc/mongomock_fixtures.py diff --git a/monkey/tests/monkey_island/cc/services/edge/test_edge_service.py b/monkey/tests/monkey_island/cc/services/edge/test_edge_service.py index 99ecf52d7..cc4f7f4a0 100644 --- a/monkey/tests/monkey_island/cc/services/edge/test_edge_service.py +++ b/monkey/tests/monkey_island/cc/services/edge/test_edge_service.py @@ -2,10 +2,10 @@ import logging import pytest from mongomock import ObjectId +from tests.monkey_island.cc.fixture_enum import FixtureEnum 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__) diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py b/monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py index b92a52ae1..2d42cdf61 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py @@ -1,6 +1,7 @@ from datetime import datetime import pytest +from tests.monkey_island.cc.fixture_enum import FixtureEnum from common.common_consts import zero_trust_consts from monkey_island.cc.models.zero_trust.event import Event @@ -9,7 +10,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( diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py b/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py index 00eae32e7..4b61d6396 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py @@ -2,6 +2,7 @@ from unittest.mock import MagicMock import dpath.util import pytest +from tests.monkey_island.cc.fixture_enum import FixtureEnum from common.config_value_paths import AWS_KEYS_PATH from monkey_island.cc.database import mongo @@ -10,7 +11,6 @@ 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: diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py b/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py index de7b5635e..64febd08c 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py @@ -1,4 +1,5 @@ import pytest +from tests.monkey_island.cc.fixture_enum import FixtureEnum from monkey_island.cc.models.zero_trust.finding import Finding from monkey_island.cc.models.zero_trust.scoutsuite_finding import ScoutSuiteFinding @@ -9,7 +10,6 @@ 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: diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py b/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py index 37d432bf4..46946c7ba 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py @@ -1,6 +1,7 @@ from unittest.mock import MagicMock import pytest +from tests.monkey_island.cc.fixture_enum import FixtureEnum from common.common_consts.zero_trust_consts import ( DEVICES, @@ -22,7 +23,6 @@ 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) diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py b/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py index 3b6da848f..51c94cb32 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py @@ -1,6 +1,7 @@ from typing import List import pytest +from tests.monkey_island.cc.fixture_enum import FixtureEnum from common.common_consts import zero_trust_consts from common.common_consts.zero_trust_consts import ( @@ -16,7 +17,6 @@ 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) diff --git a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py b/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py index 7eb6b19cd..be744b3b0 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py @@ -1,4 +1,5 @@ import pytest +from tests.monkey_island.cc.fixture_enum import FixtureEnum from common.common_consts import zero_trust_consts from monkey_island.cc.services.zero_trust.test_common.finding_data import ( @@ -8,7 +9,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": [ 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 From 4f25e1b6c897a389783a23254adfefcc3ebcdda0 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Wed, 19 May 2021 09:38:12 +0300 Subject: [PATCH 2/6] Refactored to use fixtures without enum, to be consistent with other UT code --- monkey/tests/monkey_island/cc/fixture_enum.py | 2 -- .../tests/monkey_island/cc/models/test_monkey.py | 15 +++++++-------- .../cc/models/zero_trust/test_monkey_finding.py | 5 ++--- .../models/zero_trust/test_scoutsuite_finding.py | 5 ++--- .../cc/services/edge/test_edge_service.py | 3 +-- .../test_monkey_zt_finding_service.py | 5 ++--- .../scoutsuite/test_scoutsuite_auth_service.py | 3 +-- .../test_scoutsuite_zt_finding_service.py | 3 +-- .../zero_trust_report/test_finding_service.py | 3 +-- .../zero_trust_report/test_pillar_service.py | 5 ++--- .../zero_trust_report/test_principle_service.py | 3 +-- 11 files changed, 20 insertions(+), 32 deletions(-) delete mode 100644 monkey/tests/monkey_island/cc/fixture_enum.py diff --git a/monkey/tests/monkey_island/cc/fixture_enum.py b/monkey/tests/monkey_island/cc/fixture_enum.py deleted file mode 100644 index c0bc1f1aa..000000000 --- a/monkey/tests/monkey_island/cc/fixture_enum.py +++ /dev/null @@ -1,2 +0,0 @@ -class FixtureEnum: - USES_DATABASE = "uses_database" diff --git a/monkey/tests/monkey_island/cc/models/test_monkey.py b/monkey/tests/monkey_island/cc/models/test_monkey.py index 503c2a6f3..2df8be4dd 100644 --- a/monkey/tests/monkey_island/cc/models/test_monkey.py +++ b/monkey/tests/monkey_island/cc/models/test_monkey.py @@ -3,7 +3,6 @@ import uuid from time import sleep import pytest -from tests.monkey_island.cc.fixture_enum import FixtureEnum from monkey_island.cc.models.monkey import Monkey, MonkeyNotFoundError from monkey_island.cc.models.monkey_ttl import MonkeyTtl @@ -12,7 +11,7 @@ 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_monkey_finding.py b/monkey/tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py index 04482b0de..ec0f741df 100644 --- a/monkey/tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py +++ b/monkey/tests/monkey_island/cc/models/zero_trust/test_monkey_finding.py @@ -1,6 +1,5 @@ import pytest from mongoengine import ValidationError -from tests.monkey_island.cc.fixture_enum import FixtureEnum import common.common_consts.zero_trust_consts as zero_trust_consts from monkey_island.cc.models.zero_trust.event import Event @@ -13,7 +12,7 @@ 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/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py index 5c45d773e..a9ce8837e 100644 --- a/monkey/tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py +++ b/monkey/tests/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py @@ -1,6 +1,5 @@ import pytest from mongoengine import ValidationError -from tests.monkey_island.cc.fixture_enum import FixtureEnum import common.common_consts.zero_trust_consts as zero_trust_consts from monkey_island.cc.models.zero_trust.finding import Finding @@ -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/tests/monkey_island/cc/services/edge/test_edge_service.py b/monkey/tests/monkey_island/cc/services/edge/test_edge_service.py index cc4f7f4a0..8754d5fac 100644 --- a/monkey/tests/monkey_island/cc/services/edge/test_edge_service.py +++ b/monkey/tests/monkey_island/cc/services/edge/test_edge_service.py @@ -2,7 +2,6 @@ import logging import pytest from mongomock import ObjectId -from tests.monkey_island.cc.fixture_enum import FixtureEnum from monkey_island.cc.models.edge import Edge from monkey_island.cc.services.edge.edge import EdgeService @@ -11,7 +10,7 @@ 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/zero_trust/monkey_findings/test_monkey_zt_finding_service.py b/monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py index 2d42cdf61..6248be02c 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py @@ -1,7 +1,6 @@ from datetime import datetime import pytest -from tests.monkey_island.cc.fixture_enum import FixtureEnum from common.common_consts import zero_trust_consts from monkey_island.cc.models.zero_trust.event import 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/test_scoutsuite_auth_service.py b/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py index 4b61d6396..faea76f4f 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py @@ -2,7 +2,6 @@ from unittest.mock import MagicMock import dpath.util import pytest -from tests.monkey_island.cc.fixture_enum import FixtureEnum from common.config_value_paths import AWS_KEYS_PATH from monkey_island.cc.database import mongo @@ -17,7 +16,7 @@ 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_zt_finding_service.py b/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py index 64febd08c..51598c1a9 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py @@ -1,5 +1,4 @@ import pytest -from tests.monkey_island.cc.fixture_enum import FixtureEnum from monkey_island.cc.models.zero_trust.finding import Finding from monkey_island.cc.models.zero_trust.scoutsuite_finding import ScoutSuiteFinding @@ -13,7 +12,7 @@ from monkey_island.cc.services.zero_trust.test_common.scoutsuite_finding_data im 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/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py index 46946c7ba..81bee7d95 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py @@ -1,7 +1,6 @@ from unittest.mock import MagicMock import pytest -from tests.monkey_island.cc.fixture_enum import FixtureEnum from common.common_consts.zero_trust_consts import ( DEVICES, @@ -25,7 +24,7 @@ from monkey_island.cc.services.zero_trust.zero_trust_report.finding_service impo ) -@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/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py index 51c94cb32..34c8c4975 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py @@ -1,7 +1,6 @@ from typing import List import pytest -from tests.monkey_island.cc.fixture_enum import FixtureEnum from common.common_consts import zero_trust_consts from common.common_consts.zero_trust_consts import ( @@ -19,7 +18,7 @@ from monkey_island.cc.services.zero_trust.zero_trust_report.test_common.example_ ) -@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/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py index be744b3b0..37721e3dc 100644 --- a/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py +++ b/monkey/tests/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py @@ -1,5 +1,4 @@ import pytest -from tests.monkey_island.cc.fixture_enum import FixtureEnum from common.common_consts import zero_trust_consts from monkey_island.cc.services.zero_trust.test_common.finding_data import ( @@ -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" From 30008d47a80fac29edf71308533c9ab34ae103c4 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Wed, 19 May 2021 09:41:15 +0300 Subject: [PATCH 3/6] Created a separate directory for unit tests and moved them into that directory --- monkey/tests/monkey_island/cc/conftest.py | 3 --- .../{ => unit_tests}/common/cloud/aws/test_aws_instance.py | 0 .../{ => unit_tests}/common/cloud/aws/test_aws_service.py | 0 .../{ => unit_tests}/common/cloud/azure/test_azure_instance.py | 0 .../{ => unit_tests}/common/cloud/gcp/test_gcp_instance.py | 0 .../{ => unit_tests}/common/network/test_network_utils.py | 0 .../{ => unit_tests}/common/network/test_segmentation_utils.py | 0 .../{ => unit_tests}/common/utils/test_shellcode_obfuscator.py | 0 .../infection_monkey/exploit/test_zerologon.py | 0 .../infection_monkey/exploit/tools/test_helpers.py | 0 .../infection_monkey/exploit/tools/test_payload.py | 0 .../exploit/zerologon_utils/test_vuln_assessment.py | 0 .../infection_monkey/model/test_victim_host_generator.py | 0 .../post_breach/actions/test_users_custom_pba.py | 0 .../windows_cred_collector/test_pypykatz_handler.py | 0 .../infection_monkey/telemetry/attack/test_attack_telem.py | 0 .../infection_monkey/telemetry/attack/test_t1005_telem.py | 0 .../infection_monkey/telemetry/attack/test_t1035_telem.py | 0 .../infection_monkey/telemetry/attack/test_t1064_telem.py | 0 .../infection_monkey/telemetry/attack/test_t1105_telem.py | 0 .../infection_monkey/telemetry/attack/test_t1106_telem.py | 0 .../infection_monkey/telemetry/attack/test_t1107_telem.py | 0 .../infection_monkey/telemetry/attack/test_t1129_telem.py | 0 .../infection_monkey/telemetry/attack/test_t1197_telem.py | 0 .../infection_monkey/telemetry/attack/test_t1222_telem.py | 0 .../infection_monkey/telemetry/attack/test_usage_telem.py | 0 .../telemetry/attack/test_victim_host_telem.py | 0 .../{ => unit_tests}/infection_monkey/telemetry/conftest.py | 0 .../infection_monkey/telemetry/test_exploit_telem.py | 0 .../infection_monkey/telemetry/test_post_breach_telem.py | 0 .../infection_monkey/telemetry/test_scan_telem.py | 0 .../infection_monkey/telemetry/test_state_telem.py | 0 .../infection_monkey/telemetry/test_system_info_telem.py | 0 .../infection_monkey/telemetry/test_trace_telem.py | 0 .../infection_monkey/telemetry/test_tunnel_telem.py | 0 .../infection_monkey/utils/linux/test_users.py | 0 .../infection_monkey/utils/plugins/test_plugin.py | 0 .../infection_monkey/utils/test_auto_new_user_factory.py | 0 monkey/tests/unit_tests/monkey_island/cc/conftest.py | 3 +++ .../{ => unit_tests}/monkey_island/cc/environment/conftest.py | 0 .../monkey_island/cc/environment/test_environment.py | 0 .../monkey_island/cc/environment/test_environment_config.py | 0 .../monkey_island/cc/environment/test_user_creds.py | 0 .../{ => unit_tests}/monkey_island/cc/models/test_monkey.py | 0 .../monkey_island/cc/models/zero_trust/test_event.py | 0 .../monkey_island/cc/models/zero_trust/test_monkey_finding.py | 0 .../cc/models/zero_trust/test_scoutsuite_finding.py | 0 .../{ => unit_tests}/monkey_island/cc/mongomock_fixtures.py | 0 .../monkey_island/cc/resources/test_bootloader.py | 0 .../monkey_island/cc/server_utils/test_island_logger.py | 0 .../cc/services/attack/test_mitre_api_interface.py | 0 .../cc/services/edge/test_displayed_edge_service.py | 0 .../monkey_island/cc/services/edge/test_edge_service.py | 0 .../monkey_island/cc/services/reporting/test_report.py | 0 .../test_environment_telemetry_processing.py | 0 .../test_system_info_telemetry_dispatcher.py | 0 .../cc/services/telemetry/processing/test_post_breach.py | 0 .../telemetry/zero_trust_checks/test_segmentation_checks.py | 0 .../monkey_island/cc/services/test_bootloader_service.py | 0 .../{ => unit_tests}/monkey_island/cc/services/test_config.py | 0 .../monkey_island/cc/services/test_post_breach_files.py | 0 .../monkey_island/cc/services/test_representations.py | 0 .../monkey_island/cc/services/utils/test_node_states.py | 0 .../monkey_findings/test_monkey_zt_details_service.py | 0 .../monkey_findings/test_monkey_zt_finding_service.py | 0 .../zero_trust/scoutsuite/data_parsing/test_rule_parser.py | 0 .../zero_trust/scoutsuite/test_scoutsuite_auth_service.py | 0 .../zero_trust/scoutsuite/test_scoutsuite_rule_service.py | 0 .../scoutsuite/test_scoutsuite_zt_finding_service.py | 0 .../zero_trust/zero_trust_report/test_finding_service.py | 0 .../zero_trust/zero_trust_report/test_pillar_service.py | 0 .../zero_trust/zero_trust_report/test_principle_service.py | 0 monkey/tests/{ => unit_tests}/monkey_island/cc/test_consts.py | 0 .../tests/{ => unit_tests}/monkey_island/cc/test_encryptor.py | 0 monkey/tests/{ => unit_tests}/monkey_island/conftest.py | 0 .../tests/{ => unit_tests}/monkey_island/test_config_loader.py | 0 76 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 monkey/tests/monkey_island/cc/conftest.py rename monkey/tests/{ => unit_tests}/common/cloud/aws/test_aws_instance.py (100%) rename monkey/tests/{ => unit_tests}/common/cloud/aws/test_aws_service.py (100%) rename monkey/tests/{ => unit_tests}/common/cloud/azure/test_azure_instance.py (100%) rename monkey/tests/{ => unit_tests}/common/cloud/gcp/test_gcp_instance.py (100%) rename monkey/tests/{ => unit_tests}/common/network/test_network_utils.py (100%) rename monkey/tests/{ => unit_tests}/common/network/test_segmentation_utils.py (100%) rename monkey/tests/{ => unit_tests}/common/utils/test_shellcode_obfuscator.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/exploit/test_zerologon.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/exploit/tools/test_helpers.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/exploit/tools/test_payload.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/exploit/zerologon_utils/test_vuln_assessment.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/model/test_victim_host_generator.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/post_breach/actions/test_users_custom_pba.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/system_info/windows_cred_collector/test_pypykatz_handler.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_attack_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_t1005_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_t1035_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_t1064_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_t1105_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_t1106_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_t1107_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_t1129_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_t1197_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_t1222_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_usage_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/attack/test_victim_host_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/conftest.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/test_exploit_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/test_post_breach_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/test_scan_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/test_state_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/test_system_info_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/test_trace_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/telemetry/test_tunnel_telem.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/utils/linux/test_users.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/utils/plugins/test_plugin.py (100%) rename monkey/tests/{ => unit_tests}/infection_monkey/utils/test_auto_new_user_factory.py (100%) create mode 100644 monkey/tests/unit_tests/monkey_island/cc/conftest.py rename monkey/tests/{ => unit_tests}/monkey_island/cc/environment/conftest.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/environment/test_environment.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/environment/test_environment_config.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/environment/test_user_creds.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/models/test_monkey.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/models/zero_trust/test_event.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/models/zero_trust/test_monkey_finding.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/models/zero_trust/test_scoutsuite_finding.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/mongomock_fixtures.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/resources/test_bootloader.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/server_utils/test_island_logger.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/attack/test_mitre_api_interface.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/edge/test_displayed_edge_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/edge/test_edge_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/reporting/test_report.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_environment_telemetry_processing.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/telemetry/processing/system_info_collectors/test_system_info_telemetry_dispatcher.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/telemetry/processing/test_post_breach.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/telemetry/zero_trust_checks/test_segmentation_checks.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/test_bootloader_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/test_config.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/test_post_breach_files.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/test_representations.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/utils/test_node_states.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_details_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/zero_trust/monkey_findings/test_monkey_zt_finding_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/zero_trust/scoutsuite/data_parsing/test_rule_parser.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_auth_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_rule_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/zero_trust/scoutsuite/test_scoutsuite_zt_finding_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/zero_trust/zero_trust_report/test_finding_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/zero_trust/zero_trust_report/test_pillar_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/services/zero_trust/zero_trust_report/test_principle_service.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/test_consts.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/cc/test_encryptor.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/conftest.py (100%) rename monkey/tests/{ => unit_tests}/monkey_island/test_config_loader.py (100%) diff --git a/monkey/tests/monkey_island/cc/conftest.py b/monkey/tests/monkey_island/cc/conftest.py deleted file mode 100644 index b9aabe4ef..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 tests.monkey_island.cc.mongomock_fixtures import * # noqa: F401,F403 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/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 100% rename from monkey/tests/monkey_island/cc/models/test_monkey.py rename to monkey/tests/unit_tests/monkey_island/cc/models/test_monkey.py 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 100% 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 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 100% 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 diff --git a/monkey/tests/monkey_island/cc/mongomock_fixtures.py b/monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py similarity index 100% rename from monkey/tests/monkey_island/cc/mongomock_fixtures.py rename to monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py 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 100% 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 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 100% 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 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 100% 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 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 100% 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 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 100% 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 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 100% 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 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 100% 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 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 From 99bbe36c62b3d3312563b61264c2d0cab89dd5b7 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 20 May 2021 09:58:58 +0300 Subject: [PATCH 4/6] Moved a unit test into unit_tests folder --- .../infection_monkey/utils/test_random_password_generator.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename monkey/tests/{ => unit_tests}/infection_monkey/utils/test_random_password_generator.py (100%) 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 From 0ab91ef27dcd5a689f8cc887d21c848deeb71b39 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 20 May 2021 10:22:20 +0300 Subject: [PATCH 5/6] Altered mongomock fixture to be a module-scoped, in an attempt to fix fixture import error --- monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py b/monkey/tests/unit_tests/monkey_island/cc/mongomock_fixtures.py index 079c91fb7..26a41685a 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/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() From e97882369c9523575ec729ddd7e6ffe946e5e8d0 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 20 May 2021 10:30:10 +0300 Subject: [PATCH 6/6] Added init files to test directories so that conftest files could import fixtures --- monkey/tests/__init__.py | 0 monkey/tests/unit_tests/__init__.py | 0 monkey/tests/unit_tests/monkey_island/__init__.py | 0 monkey/tests/unit_tests/monkey_island/cc/__init__.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 monkey/tests/__init__.py create mode 100644 monkey/tests/unit_tests/__init__.py create mode 100644 monkey/tests/unit_tests/monkey_island/__init__.py create mode 100644 monkey/tests/unit_tests/monkey_island/cc/__init__.py diff --git a/monkey/tests/__init__.py b/monkey/tests/__init__.py new file mode 100644 index 000000000..e69de29bb 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/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