Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import History: Adding a few tests #10235

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions unittests/scans/generic/test_import_report1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "Unicorn",
"type": "Unicorn",
"findings": [
{
"title": "Henry Smith",
"description": "small",
"severity": "Critical",
"active": false,
"verified": false,
"is_mitigated": true
},
{
"title": "Emma Jones",
"description": "small",
"severity": "Critical",
"active": false,
"verified": false,
"is_mitigated": true
},
{
"title": "Emma Jones",
"description": "small",
"severity": "Critical",
"active": true,
"verified": true,
"is_mitigated": false
},
{
"title": "Emma Jones",
"description": "small",
"severity": "Critical",
"active": false,
"verified": false,
"is_mitigated": true
}
]
}
38 changes: 38 additions & 0 deletions unittests/scans/generic/test_import_report2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "Unicorn",
"type": "Unicorn",
"findings": [
{
"title": "Henry Smith",
"description": "small",
"severity": "Critical",
"active": false,
"verified": false,
"is_mitigated": true
},
{
"title": "Henry Smith",
"description": "small",
"severity": "Critical",
"active": false,
"verified": false,
"is_mitigated": true
},
{
"title": "Henry Smith",
"description": "small",
"severity": "Critical",
"active": false,
"verified": false,
"is_mitigated": true
},
{
"title": "Henry Smith",
"description": "small",
"severity": "Critical",
"active": true,
"verified": true,
"is_mitigated": false
}
]
}
12 changes: 12 additions & 0 deletions unittests/test_import_reimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ def __init__(self, *args, **kwargs):
self.clair_empty = self.scans_path + 'clair/clair_empty.json'
self.scan_type_clair = 'Clair Scan'

self.scan_type_generic = "Generic Findings Import"
self.generic_filename_with_file = self.scans_path + "generic/test_with_image.json"
self.generic_import_1 = self.scans_path + "generic/test_import_report1.json"
self.generic_import_2 = self.scans_path + "generic/test_import_report2.json"

self.aws_prowler_file_name = self.scans_path + 'aws_prowler/many_vuln.json'
self.aws_prowler_file_name_plus_one = self.scans_path + 'aws_prowler/many_vuln_plus_one.json'
Expand Down Expand Up @@ -1445,6 +1448,15 @@ def test_import_reimport_vulnerability_ids(self):
self.assertEqual('GHSA-v6rh-hp5x-86rv', findings[3].vulnerability_ids[0])
self.assertEqual('CVE-2021-44420', findings[3].vulnerability_ids[1])

def test_import_history_reactivated_and_untouched_findings_do_not_mix(self):
import0 = self.import_scan_with_params(self.generic_import_1, scan_type=self.scan_type_generic)
test_id = import0['test']
# reimport the second report
self.reimport_scan_with_params(test_id, self.generic_import_2, scan_type=self.scan_type_generic)
# reimport the first report again
self.reimport_scan_with_params(test_id, self.generic_import_1, scan_type=self.scan_type_generic)
# Passing this test means an exception does not occur


class ImportReimportTestAPI(DojoAPITestCase, ImportReimportMixin):
fixtures = ['dojo_testdata.json']
Expand Down
Loading