Skip to content

Commit

Permalink
fix: Adding tests for campaigns
Browse files Browse the repository at this point in the history
  • Loading branch information
MSAdministrator committed Feb 10, 2023
1 parent ecf5eba commit 40809bc
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/test_campaigns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import pytest


@pytest.mark.parametrize("target_attribute", ["enterprise"])
def test_campaigns(attck_fixture, target_attribute):
"""
All MITRE ATT&CK Frameworks Campaigns should have tools
Args:
attck_fixture ([type]): our default MITRE ATT&CK JSON fixture
"""
campaign_list = set()
for campaign in getattr(attck_fixture, target_attribute).campaigns:
if campaign.name not in campaign_list:
campaign_list.add(campaign.name)
else:
assert False
assert True


@pytest.mark.parametrize("target_attribute", ["enterprise"])
def test_campaigns_have_malwares(attck_fixture, target_attribute):
"""
All MITRE ATT&CK Framework Campaigns should have malwares
Args:
attck_fixture ([type]): our default MITRE ATT&CK JSON fixture
"""
for campaign in getattr(attck_fixture, target_attribute).campaigns:
if campaign.malwares:
assert getattr(campaign, "malwares")


@pytest.mark.parametrize("target_attribute", ["enterprise", "mobile", "preattack"])
def test_campaigns_have_techniques(attck_fixture, target_attribute):
"""
All MITRE ATT&CK Campaigns should have techniques
Args:
attck_fixture ([type]): our default MITRE ATT&CK JSON fixture
"""
for campaign in getattr(attck_fixture, target_attribute).campaigns:
if campaign.techniques:
assert getattr(campaign, "techniques")

0 comments on commit 40809bc

Please sign in to comment.