Skip to content

Commit

Permalink
Import History: Adding a few tests (#10235)
Browse files Browse the repository at this point in the history
* Import History: Adding a few tests

* Update tests
  • Loading branch information
Maffooch authored May 28, 2024
1 parent 90a4a17 commit e37781e
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
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

0 comments on commit e37781e

Please sign in to comment.