77from rest_framework .test import APIClient
88
99from dojo .importers .default_importer import DefaultImporter
10+ from dojo .importers .default_reimporter import DefaultReImporter
1011from dojo .models import (
1112 Development_Environment ,
1213 Engagement ,
@@ -562,16 +563,15 @@ def create_default_data(self):
562563 "scan_type" : NPM_AUDIT_SCAN_TYPE ,
563564 }
564565
565- @patch ("dojo.importers.base_importer.Vulnerability_Id" , autospec = True )
566- def test_handle_vulnerability_ids_references_and_cve (self , mock ):
566+ def test_handle_vulnerability_ids_references_and_cve (self ):
567567 # Why doesn't this test use the test db and query for one?
568568 vulnerability_ids = ["CVE" , "REF-1" , "REF-2" ]
569569 finding = Finding ()
570570 finding .unsaved_vulnerability_ids = vulnerability_ids
571571 finding .test = self .test
572572 finding .reporter = self .testuser
573573 finding .save ()
574- DefaultImporter (** self .importer_data ).process_vulnerability_ids (finding )
574+ DefaultImporter (** self .importer_data ).store_vulnerability_ids (finding )
575575
576576 self .assertEqual ("CVE" , finding .vulnerability_ids [0 ])
577577 self .assertEqual ("CVE" , finding .cve )
@@ -580,45 +580,42 @@ def test_handle_vulnerability_ids_references_and_cve(self, mock):
580580 self .assertEqual ("REF-2" , finding .vulnerability_ids [2 ])
581581 finding .delete ()
582582
583- @patch ("dojo.importers.base_importer.Vulnerability_Id" , autospec = True )
584- def test_handle_no_vulnerability_ids_references_and_cve (self , mock ):
583+ def test_handle_no_vulnerability_ids_references_and_cve (self ):
585584 vulnerability_ids = ["CVE" ]
586585 finding = Finding ()
587586 finding .test = self .test
588587 finding .reporter = self .testuser
589588 finding .save ()
590589 finding .unsaved_vulnerability_ids = vulnerability_ids
591590
592- DefaultImporter (** self .importer_data ).process_vulnerability_ids (finding )
591+ DefaultImporter (** self .importer_data ).store_vulnerability_ids (finding )
593592
594593 self .assertEqual ("CVE" , finding .vulnerability_ids [0 ])
595594 self .assertEqual ("CVE" , finding .cve )
596595 self .assertEqual (vulnerability_ids , finding .unsaved_vulnerability_ids )
597596 finding .delete ()
598597
599- @patch ("dojo.importers.base_importer.Vulnerability_Id" , autospec = True )
600- def test_handle_vulnerability_ids_references_and_no_cve (self , mock ):
598+ def test_handle_vulnerability_ids_references_and_no_cve (self ):
601599 vulnerability_ids = ["REF-1" , "REF-2" ]
602600 finding = Finding ()
603601 finding .test = self .test
604602 finding .reporter = self .testuser
605603 finding .save ()
606604 finding .unsaved_vulnerability_ids = vulnerability_ids
607- DefaultImporter (** self .importer_data ).process_vulnerability_ids (finding )
605+ DefaultImporter (** self .importer_data ).store_vulnerability_ids (finding )
608606
609607 self .assertEqual ("REF-1" , finding .vulnerability_ids [0 ])
610608 self .assertEqual ("REF-1" , finding .cve )
611609 self .assertEqual (vulnerability_ids , finding .unsaved_vulnerability_ids )
612610 self .assertEqual ("REF-2" , finding .vulnerability_ids [1 ])
613611 finding .delete ()
614612
615- @patch ("dojo.importers.base_importer.Vulnerability_Id" , autospec = True )
616- def test_no_handle_vulnerability_ids_references_and_no_cve (self , mock ):
613+ def test_no_handle_vulnerability_ids_references_and_no_cve (self ):
617614 finding = Finding ()
618615 finding .test = self .test
619616 finding .reporter = self .testuser
620617 finding .save ()
621- DefaultImporter (** self .importer_data ).process_vulnerability_ids (finding )
618+ DefaultImporter (** self .importer_data ).store_vulnerability_ids (finding )
622619 self .assertEqual (finding .cve , None )
623620 self .assertEqual (finding .unsaved_vulnerability_ids , None )
624621 self .assertEqual (finding .vulnerability_ids , [])
@@ -644,7 +641,7 @@ def test_clear_vulnerability_ids_on_empty_list(self):
644641
645642 # Process with empty list - should clear all IDs
646643 finding .unsaved_vulnerability_ids = []
647- DefaultImporter ( ** self .importer_data ). process_vulnerability_ids (finding )
644+ DefaultReImporter ( test = self .test , environment = self . importer_data [ "environment" ], scan_type = self . importer_data [ "scan_type" ]). reconcile_vulnerability_ids (finding )
648645 # Save the finding to persist the cve=None change
649646 finding .save ()
650647
@@ -681,7 +678,7 @@ def test_change_vulnerability_ids_on_reimport(self):
681678 # Process with different IDs - should replace old IDs
682679 new_vulnerability_ids = ["CVE-2021-9999" , "GHSA-xxxx-yyyy" ]
683680 finding .unsaved_vulnerability_ids = new_vulnerability_ids
684- DefaultImporter ( ** self .importer_data ). process_vulnerability_ids (finding )
681+ DefaultReImporter ( test = self .test , environment = self . importer_data [ "environment" ], scan_type = self . importer_data [ "scan_type" ]). reconcile_vulnerability_ids (finding )
685682 # Save the finding to persist the cve change
686683 finding .save ()
687684
0 commit comments