UT: Remove tests related to config schema per attack technique
This commit is contained in:
parent
98fbc7592c
commit
9b23cc0bef
|
@ -1,20 +1,13 @@
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from common.utils.attack_utils import ScanStatus
|
from common.utils.attack_utils import ScanStatus
|
||||||
from monkey_island.cc.services.attack.technique_reports.__init__ import AttackTechnique
|
from monkey_island.cc.services.attack.technique_reports.__init__ import (
|
||||||
|
UNSCANNED_MESSAGE,
|
||||||
|
AttackTechnique,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="function", autouse=True)
|
class FakeAttackTechnique(AttackTechnique):
|
||||||
def mock_config_schema_per_attack_technique(monkeypatch, fake_schema):
|
|
||||||
monkeypatch.setattr(
|
|
||||||
("monkey_island.cc.services.attack.technique_reports.__init__.SCHEMA"),
|
|
||||||
fake_schema,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class FakeAttackTechnique_TwoRelevantSystems(AttackTechnique):
|
|
||||||
tech_id = "T0000"
|
tech_id = "T0000"
|
||||||
relevant_systems = ["System 1", "System 2"]
|
relevant_systems = ["System 1", "System 2"]
|
||||||
unscanned_msg = "UNSCANNED"
|
unscanned_msg = "UNSCANNED"
|
||||||
|
@ -25,83 +18,22 @@ class FakeAttackTechnique_TwoRelevantSystems(AttackTechnique):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ExpectedMsgs_TwoRelevantSystems(Enum):
|
class ExpectedMsgs(Enum):
|
||||||
UNSCANNED: str = (
|
UNSCANNED: str = UNSCANNED_MESSAGE
|
||||||
"UNSCANNED due to one of the following reasons:\n"
|
|
||||||
"- The following configuration options were disabled or empty:<br/>"
|
|
||||||
"- Definition Type 1 — Config Option 1, Config Option 2<br/>"
|
|
||||||
"- Definition Type 2 — Config Option 5, Config Option 6<br/>"
|
|
||||||
"- Property Type 1 -> Category 1 — Config Option 1<br/>"
|
|
||||||
"- Property Type 2 -> Category 1 — Config Option 1<br/>"
|
|
||||||
"- Property Type 2 -> Category 2 -> Config Option 1 — Config Option 1.1<br/>"
|
|
||||||
"- Property Type 2 -> Category 2 -> Config Option 2 — Config Option 2.1<br/>"
|
|
||||||
"- Property Type 2 -> Category 2 -> Config Option 2 -> Config Option 2.1 — Config Option "
|
|
||||||
"2.1.1<br/>"
|
|
||||||
)
|
|
||||||
SCANNED: str = "SCANNED"
|
SCANNED: str = "SCANNED"
|
||||||
USED: str = "USED"
|
USED: str = "USED"
|
||||||
|
|
||||||
|
|
||||||
class FakeAttackTechnique_OneRelevantSystem(AttackTechnique):
|
def test_get_message_by_status_unscanned():
|
||||||
tech_id = "T0001"
|
technique_msg = FakeAttackTechnique.get_message_by_status(ScanStatus.UNSCANNED.value)
|
||||||
relevant_systems = ["System 1"]
|
assert technique_msg == ExpectedMsgs.UNSCANNED.value
|
||||||
unscanned_msg = "UNSCANNED"
|
|
||||||
scanned_msg = "SCANNED"
|
|
||||||
used_msg = "USED"
|
|
||||||
|
|
||||||
def get_report_data():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ExpectedMsgs_OneRelevantSystem(Enum):
|
def test_get_message_by_status_scanned():
|
||||||
UNSCANNED: str = (
|
technique_msg = FakeAttackTechnique.get_message_by_status(ScanStatus.SCANNED.value)
|
||||||
"UNSCANNED due to one of the following reasons:\n"
|
assert technique_msg == ExpectedMsgs.SCANNED.value
|
||||||
"- Monkey did not run on any System 1 systems.\n"
|
|
||||||
"- The following configuration options were disabled or empty:<br/>"
|
|
||||||
"- Definition Type 1 — Config Option 1<br/>"
|
|
||||||
"- Definition Type 2 — Config Option 5<br/>"
|
|
||||||
)
|
|
||||||
SCANNED: str = "SCANNED"
|
|
||||||
USED: str = "USED"
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_message_by_status_unscanned_two_relevant_systems():
|
def test_get_message_by_status_used():
|
||||||
technique_msg = FakeAttackTechnique_TwoRelevantSystems.get_message_by_status(
|
technique_msg = FakeAttackTechnique.get_message_by_status(ScanStatus.USED.value)
|
||||||
ScanStatus.UNSCANNED.value
|
assert technique_msg == ExpectedMsgs.USED.value
|
||||||
)
|
|
||||||
assert technique_msg == ExpectedMsgs_TwoRelevantSystems.UNSCANNED.value
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_message_by_status_scanned_two_relevant_systems():
|
|
||||||
technique_msg = FakeAttackTechnique_TwoRelevantSystems.get_message_by_status(
|
|
||||||
ScanStatus.SCANNED.value
|
|
||||||
)
|
|
||||||
assert technique_msg == ExpectedMsgs_TwoRelevantSystems.SCANNED.value
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_message_by_status_used_two_relevant_systems():
|
|
||||||
technique_msg = FakeAttackTechnique_TwoRelevantSystems.get_message_by_status(
|
|
||||||
ScanStatus.USED.value
|
|
||||||
)
|
|
||||||
assert technique_msg == ExpectedMsgs_TwoRelevantSystems.USED.value
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_message_by_status_unscanned_one_relevant_system():
|
|
||||||
technique_msg = FakeAttackTechnique_OneRelevantSystem.get_message_by_status(
|
|
||||||
ScanStatus.UNSCANNED.value
|
|
||||||
)
|
|
||||||
assert technique_msg == ExpectedMsgs_OneRelevantSystem.UNSCANNED.value
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_message_by_status_scanned_one_relevant_system():
|
|
||||||
technique_msg = FakeAttackTechnique_OneRelevantSystem.get_message_by_status(
|
|
||||||
ScanStatus.SCANNED.value
|
|
||||||
)
|
|
||||||
assert technique_msg == ExpectedMsgs_OneRelevantSystem.SCANNED.value
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_message_by_status_used_one_relevant_system():
|
|
||||||
technique_msg = FakeAttackTechnique_OneRelevantSystem.get_message_by_status(
|
|
||||||
ScanStatus.USED.value
|
|
||||||
)
|
|
||||||
assert technique_msg == ExpectedMsgs_OneRelevantSystem.USED.value
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
from monkey_island.cc.services.config_schema.config_schema_per_attack_technique import (
|
|
||||||
ConfigSchemaPerAttackTechnique,
|
|
||||||
)
|
|
||||||
|
|
||||||
REVERSE_FAKE_SCHEMA = {
|
|
||||||
"T0000": {
|
|
||||||
"Definition Type 1": ["Config Option 1", "Config Option 2"],
|
|
||||||
"Definition Type 2": ["Config Option 5", "Config Option 6"],
|
|
||||||
"Property Type 1 -> Category 1": ["Config Option 1"],
|
|
||||||
"Property Type 2 -> Category 1": ["Config Option 1"],
|
|
||||||
"Property Type 2 -> Category 2 -> Config Option 1": ["Config Option 1.1"],
|
|
||||||
"Property Type 2 -> Category 2 -> Config Option 2": ["Config Option 2.1"],
|
|
||||||
"Property Type 2 -> Category 2 -> Config Option 2 -> Config Option 2.1": [
|
|
||||||
"Config Option 2.1.1"
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"T0001": {"Definition Type 1": ["Config Option 1"], "Definition Type 2": ["Config Option 5"]},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_config_schema_per_attack_technique(monkeypatch, fake_schema):
|
|
||||||
assert (
|
|
||||||
ConfigSchemaPerAttackTechnique().get_config_schema_per_attack_technique(fake_schema)
|
|
||||||
== REVERSE_FAKE_SCHEMA
|
|
||||||
)
|
|
Loading…
Reference in New Issue