@@ -15,8 +15,8 @@ class TagTests(DojoAPITestCase):
1515 def setUp (self , * args , ** kwargs ):
1616 super ().setUp ()
1717 self .login_as_admin ()
18- self .scans_path = get_unit_tests_scans_path ("zap" )
19- self .zap_sample5_filename = self . scans_path / "5_zap_sample_one.xml "
18+ self .zap_sample5_filename = get_unit_tests_scans_path ("zap" ) / "5_zap_sample_one.xml"
19+ self .generic_sample_with_tags_filename = get_unit_tests_scans_path ( "generic" ) / "generic_report1.json "
2020
2121 def test_create_product_with_tags (self , expected_status_code : int = 201 ):
2222 product_id = Product .objects .all ().first ().id
@@ -285,6 +285,22 @@ def test_import_multipart_tags(self):
285285 for tag in success_tags :
286286 self .assertIn (tag , response ["tags" ])
287287
288+ def test_import_report_with_tags (self ):
289+ def assert_tags_in_findings (findings : list [dict ], expected_finding_count : int , desired_tags : list [str ]) -> None :
290+ self .assertEqual (expected_finding_count , len (findings ))
291+ for finding in findings :
292+ self .assertEqual (len (desired_tags ), len (finding .get ("tags" )))
293+ for tag in desired_tags :
294+ self .assertIn (tag , finding ["tags" ])
295+
296+ # Import a report with findings that have tags
297+ import0 = self .import_scan_with_params (self .generic_sample_with_tags_filename , scan_type = "Generic Findings Import" )
298+ test_id = import0 ["test" ]
299+ response = self .get_test_findings_api (test_id )
300+ findings = response ["results" ]
301+ # Make sure we have what we are looking for
302+ assert_tags_in_findings (findings , 2 , ["security" , "network" ])
303+
288304
289305class InheritedTagsTests (DojoAPITestCase ):
290306 fixtures = ["dojo_testdata.json" ]
0 commit comments