|
8 | 8 | from dojo.decorators import dojo_async_task_counter |
9 | 9 | from dojo.importers.default_importer import DefaultImporter |
10 | 10 | from dojo.importers.default_reimporter import DefaultReImporter |
11 | | -from dojo.models import Development_Environment, Dojo_User, Engagement, Product, Product_Type, User |
| 11 | +from dojo.models import ( |
| 12 | + Development_Environment, |
| 13 | + Dojo_User, |
| 14 | + Endpoint, |
| 15 | + Endpoint_Status, |
| 16 | + Engagement, |
| 17 | + Finding, |
| 18 | + Product, |
| 19 | + Product_Type, |
| 20 | + User, |
| 21 | +) |
12 | 22 |
|
13 | 23 | from .dojo_test_case import DojoTestCase, get_unit_tests_scans_path |
14 | 24 |
|
|
18 | 28 | STACK_HAWK_SUBSET_FILENAME = get_unit_tests_scans_path("stackhawk") / "stackhawk_many_vul_without_duplicated_findings_subset.json" |
19 | 29 | STACK_HAWK_SCAN_TYPE = "StackHawk HawkScan" |
20 | 30 |
|
21 | | -NPM_AUDIT_NO_VULN_FILENAME = get_unit_tests_scans_path("npm_audit") / "no_vuln.json" |
| 31 | +NPM_AUDIT_NO_VULN_FILENAME = get_unit_tests_scans_path("npm_audit") / "one_vuln.json" |
22 | 32 | NPM_AUDIT_SCAN_TYPE = "NPM Audit Scan" |
23 | 33 |
|
24 | 34 |
|
@@ -94,6 +104,21 @@ def import_reimport_performance(self, expected_num_queries1, expected_num_async_ |
94 | 104 | importer = DefaultImporter(**import_options) |
95 | 105 | test, _, _len_new_findings, _len_closed_findings, _, _, _ = importer.process_scan(NPM_AUDIT_NO_VULN_FILENAME.open(encoding="utf-8")) |
96 | 106 |
|
| 107 | + # if True: |
| 108 | + # exit(0) # this is to make sure the importers are not run when running the tests in the IDE, as it will take too long |
| 109 | + |
| 110 | + finding = Finding.objects.filter(test=test).first() |
| 111 | + |
| 112 | + endpoint = Endpoint.objects.create(host="foo.bar", product=product) |
| 113 | + Endpoint_Status.objects.create( |
| 114 | + finding=finding, |
| 115 | + endpoint=endpoint, |
| 116 | + ) |
| 117 | + |
| 118 | + finding.endpoints.add(endpoint) |
| 119 | + finding.title = "Dummy finding to ensure audit log is created" |
| 120 | + finding.save() |
| 121 | + |
97 | 122 | # first import the subset which missed one finding and a couple of endpoints on some of the findings |
98 | 123 | with ( |
99 | 124 | self.subTest("import1"), impersonate(Dojo_User.objects.get(username="admin")), |
@@ -160,7 +185,7 @@ def import_reimport_performance(self, expected_num_queries1, expected_num_async_ |
160 | 185 |
|
161 | 186 | def test_import_reimport_reimport_performance(self): |
162 | 187 | self.import_reimport_performance( |
163 | | - expected_num_queries1=605, |
| 188 | + expected_num_queries1=602, |
164 | 189 | expected_num_async_tasks1=15, |
165 | 190 | expected_num_queries2=489, |
166 | 191 | expected_num_async_tasks2=23, |
|
0 commit comments