From 8571e32755fd20eb7e1e30a5907f46ddafb950f7 Mon Sep 17 00:00:00 2001 From: arobbins Date: Fri, 28 Jun 2024 15:13:32 -0400 Subject: [PATCH] add last 1% for test coverage --- tests/fixtures/__init__.py | 9 +++++++++ tests/test_graphviz.py | 4 +++- tests/test_mermaid.py | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/fixtures/__init__.py b/tests/fixtures/__init__.py index 05cd045a..b6deaf1c 100644 --- a/tests/fixtures/__init__.py +++ b/tests/fixtures/__init__.py @@ -222,6 +222,14 @@ def get_tree_bundle(): start_refs=[action1.id, action2.id], created_by_ref=author.id, ) + condition = AttackCondition( + id="attack-condition--64d5bf0b-6acc-4f43-b0f2-aa93a219897a", + created=datetime(2022, 8, 25, 19, 26, 31), + modified=datetime(2022, 8, 25, 19, 26, 31), + description="My condition", + on_true_refs=[action1.id], + on_false_refs=[action2.id], + ) return stix2.Bundle( flow, author, @@ -234,5 +242,6 @@ def get_tree_bundle(): asset, infra, infra_rel, + condition, id="bundle--06cf9129-8d0d-4d58-9484-b5323caf09ad", ) \ No newline at end of file diff --git a/tests/test_graphviz.py b/tests/test_graphviz.py index e5728f01..55bdeaaa 100644 --- a/tests/test_graphviz.py +++ b/tests/test_graphviz.py @@ -38,7 +38,6 @@ def test_convert_attack_flow_to_graphviz(): def test_convert_attack_tree_to_graphviz(): output = attack_flow.graphviz.convert_attack_tree(get_tree_bundle()) - assert output == dedent( """\ digraph { @@ -58,6 +57,9 @@ def test_convert_attack_tree_to_graphviz(): \t"attack-asset--4ae37379-6a11-44c1-b6a8-d11733cfac06" -> "infrastructure--79d21912-36b7-4af9-8958-38949dd0d6de" [label=object] \t"infrastructure--a75c83f7-147e-4695-b173-0981521b2f01" [label=<
Infrastructure
NameTest Infra
Infrastructure Typesworkstation
> shape=plaintext] \t"attack-action--24fc6003-33f6-4dd7-a929-b6031927940f" -> "infrastructure--a75c83f7-147e-4695-b173-0981521b2f01" [label="related-to"] + \t"attack-condition--64d5bf0b-6acc-4f43-b0f2-aa93a219897a" [label=<
Condition
DescriptionMy condition
> shape=plaintext] + \t"attack-condition--64d5bf0b-6acc-4f43-b0f2-aa93a219897a" -> "attack-action--d63857d5-1043-45a4-9397-40ef68db4c5f" [label=on_true] + \t"attack-condition--64d5bf0b-6acc-4f43-b0f2-aa93a219897a" -> "attack-action--24fc6003-33f6-4dd7-a929-b6031927940f" [label=on_false] } """ ) diff --git a/tests/test_mermaid.py b/tests/test_mermaid.py index 0203d170..99cc13c3 100644 --- a/tests/test_mermaid.py +++ b/tests/test_mermaid.py @@ -66,10 +66,14 @@ class infrastructure__79d21912_36b7_4af9_8958_38949dd0d6de builtin class attack_asset__4ae37379_6a11_44c1_b6a8_d11733cfac06 builtin infrastructure__a75c83f7_147e_4695_b173_0981521b2f01["Infrastructure - Name:
Test Infra - Infrastructure
Types
: workstation"] class infrastructure__a75c83f7_147e_4695_b173_0981521b2f01 builtin + attack_condition__64d5bf0b_6acc_4f43_b0f2_aa93a219897a["Condition: My condition"] + class attack_condition__64d5bf0b_6acc_4f43_b0f2_aa93a219897a condition attack_action__d63857d5_1043_45a4_9397_40ef68db4c5f -->| | attack_action__1994e9f2_11f1_489a_a5e7_3ad4cfd8890a attack_action__1994e9f2_11f1_489a_a5e7_3ad4cfd8890a -->| | attack_action__a0847849_a533_4b1f_a94a_720bbd25fc17 attack_action__24fc6003_33f6_4dd7_a929_b6031927940f -->| | attack_action__1994e9f2_11f1_489a_a5e7_3ad4cfd8890a attack_action__24fc6003_33f6_4dd7_a929_b6031927940f -->|related-to| infrastructure__a75c83f7_147e_4695_b173_0981521b2f01 + attack_condition__64d5bf0b_6acc_4f43_b0f2_aa93a219897a -->|on_true| attack_action__d63857d5_1043_45a4_9397_40ef68db4c5f + attack_condition__64d5bf0b_6acc_4f43_b0f2_aa93a219897a -->|on_false| attack_action__24fc6003_33f6_4dd7_a929_b6031927940f """ )