Skip to content

Commit

Permalink
test(engine_risk): 🔖 test to handle_filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ssantaa9 committed Nov 7, 2024
1 parent f37fe7a commit 2b0830a
Showing 1 changed file with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,84 @@ def test_filter(self, mock_get_priority_vulnerability, mock_get_active_findings)

assert len(result) == 2

def test_filter_duplicated(self):
findings = [
Report(
id=["CVE-2021-1234"],
date="21022024",
status="stat2",
where="path2",
tags=["tag1"],
severity="low",
active=True,
),
Report(
id=["CVE-2021-1234"],
date="21022024",
status="stat2",
where="path2",
tags=["tag2"],
severity="low",
active=None,
),
Report(
id=["vuln_id"],
date="21022024",
status="stat3",
where="path3",
tags=["tag3"],
severity="info",
active=True,
),
]

result = self.handle_filters.filter_duplicated(findings)

assert len(result) == 2

@patch(
"devsecops_engine_tools.engine_risk.src.domain.usecases.handle_filters.Console"
)
def test_filter_tags_days(self, mock_console):
remote_config = {"TAG_EXCLUSION_DAYS": {"tag1": 5, "tag2": 10}}
findings = [
Report(
id=["CVE-2021-1234"],
date="21022024",
status="stat2",
where="path2",
tags=["tag1"],
severity="low",
active=True,
age=4,
),
Report(
id=["CVE-2021-1234"],
date="21022024",
status="stat2",
where="path2",
tags=["tag2"],
severity="low",
active=None,
age=11,
),
Report(
id=["vuln_id"],
date="21022024",
status="stat3",
where="path3",
tags=["tag3"],
severity="info",
active=True,
age=5,
),
]

result = self.handle_filters.filter_tags_days(remote_config, findings)

mock_console().print.assert_called_once()
assert len(result) == 2

def test__get_active_findings(self):
result = self.handle_filters._get_active_findings(self.findings)

Expand Down

0 comments on commit 2b0830a

Please sign in to comment.