From e4c9729f8bef5a2c381f5164ab551e8fa90730d7 Mon Sep 17 00:00:00 2001 From: kooomix Date: Thu, 16 Jan 2025 09:24:30 +0200 Subject: [PATCH] Update system test mapping and enhance attack chain assertions in scenarios manager --- system_test_mapping.json | 8 ++++---- systest_utils/scenarios_manager.py | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/system_test_mapping.json b/system_test_mapping.json index e5ed54c9..cf1eb3fc 100644 --- a/system_test_mapping.json +++ b/system_test_mapping.json @@ -619,10 +619,10 @@ "Backend" ], "target_repositories": [ - "cadashboardbe", - "careportsreceiver", - "event-ingester-service", - "gateway" + "cadashboardbe-dummy", + "careportsreceiver-dummy", + "event-ingester-service-dummy", + "gateway-dummy" ], "description": "", "skip_on_environment": "", diff --git a/systest_utils/scenarios_manager.py b/systest_utils/scenarios_manager.py index d4aa9005..43a15d12 100644 --- a/systest_utils/scenarios_manager.py +++ b/systest_utils/scenarios_manager.py @@ -214,9 +214,11 @@ def check_attack_chains_results(self, result, expected): expected: expected attack chains. :exception Exception: if the content is not as expected. """ - + assert "response" in result, f"'response' key not found in the result" assert len(result['response']['attackChains']) > 0, "No attack chains found, expecting attack chains" found = False + + expected_ac = expected['response']['attackChains'][0] # Some example of assertion needed to recognize attack chain scenarios for acid, ac in enumerate(result['response']['attackChains']): if ac['name'] != self.attack_track: @@ -224,12 +226,13 @@ def check_attack_chains_results(self, result, expected): found = True ac_node_result = result['response']['attackChains'][acid]['attackChainNodes'] - ac_node_expected = expected['response']['attackChains'][acid]['attackChainNodes'] + ac_node_expected = expected_ac['attackChainNodes'] # comparing the 'name' (type: attack track) of the attack chain assert ac_node_result['name'] == ac_node_expected['name'], f"Attack chain name mismatch: result: {ac_node_result['name']} != expected: {ac_node_expected['name']}" self.compare_nodes(ac_node_result, ac_node_expected) + break assert found, f"Attack chain {self.attack_track} not found, expecting attack chains"