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"