From 1adf462ac39a166a9af367a24c17757162f4002b Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 12 Oct 2021 15:54:41 +0530 Subject: [PATCH] tests: Modify unit tests as per changes to reverse schema and attack report generation --- .../test_technique_reports.py | 7 ++++--- .../test_config_schema_per_attack_technique.py | 1 + .../monkey_island/cc/services/conftest.py | 18 +++++++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/attack/technique_reports/test_technique_reports.py b/monkey/tests/unit_tests/monkey_island/cc/services/attack/technique_reports/test_technique_reports.py index 82a23a9ae..05f051ac2 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/attack/technique_reports/test_technique_reports.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/attack/technique_reports/test_technique_reports.py @@ -12,6 +12,7 @@ FAKE_CONFIG_SCHEMA_PER_ATTACK_TECHNIQUE = { "T0000": { "Definition Type 1": ["Config Option 1", "Config Option 2"], "Definition Type 2": ["Config Option 5", "Config Option 6"], + "Property Type 1": ["Config Option 1 (Tab 1)"], }, "T0001": { "Definition Type 1": ["Config Option 1"], @@ -23,7 +24,7 @@ FAKE_CONFIG_SCHEMA_PER_ATTACK_TECHNIQUE = { @pytest.fixture(scope="function", autouse=True) def mock_config_schema_per_attack_technique(monkeypatch, fake_schema): monkeypatch.setattr( - ("monkey_island.cc.services.attack.technique_reports." "__init__.SCHEMA"), + ("monkey_island.cc.services.attack.technique_reports.__init__.SCHEMA"), fake_schema, ) @@ -42,7 +43,7 @@ class FakeAttackTechnique_TwoRelevantSystems(AttackTechnique): class ExpectedMsgs_TwoRelevantSystems(Enum): UNSCANNED: str = ( "UNSCANNED due to one of the following reasons:\n" - "- The following configuration options were disabled:
" + "- The following configuration options were disabled or empty:
" "- Definition Type 1 — Config Option 1
" "- Definition Type 2 — Config Option 5
" ) @@ -65,7 +66,7 @@ class ExpectedMsgs_OneRelevantSystem(Enum): UNSCANNED: str = ( "UNSCANNED due to one of the following reasons:\n" "- Monkey did not run on any System 1 systems.\n" - "- The following configuration options were disabled:
" + "- The following configuration options were disabled or empty:
" "- Definition Type 1 — Config Option 1
" "- Definition Type 2 — Config Option 5
" ) diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/config_schema/test_config_schema_per_attack_technique.py b/monkey/tests/unit_tests/monkey_island/cc/services/config_schema/test_config_schema_per_attack_technique.py index bacdae5dd..fdaf36374 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/config_schema/test_config_schema_per_attack_technique.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/config_schema/test_config_schema_per_attack_technique.py @@ -6,6 +6,7 @@ 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": ["Config Option 1 (Tab 1)"], }, "T0001": { "Definition Type 1": ["Config Option 1"], diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/conftest.py b/monkey/tests/unit_tests/monkey_island/cc/services/conftest.py index b89be55f9..90ffdb7d7 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/conftest.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/conftest.py @@ -66,5 +66,21 @@ def fake_schema(): }, ], }, - } + }, + "properties": { + "property_type_1": { + "title": "Property Type 1", + "properties": { + "tab_1": { + "title": "Tab 1", + "properties": { + "config_option_1": { + "title": "Config Option 1", + "related_attack_techniques": ["T0000"], + }, + }, + } + }, + } + }, }