@@ -872,108 +872,118 @@ def test_events_messages(self, mock):
872872 })
873873
874874 with self .subTest ("scan_added" ):
875+ new_finding = Finding .objects .create (test = test , title = "New Finding" , severity = "Critical" )
876+ mitigated_finding = Finding .objects .create (test = test , title = "Mitigated Finding" , severity = "Medium" )
877+ reactivated_finding = Finding .objects .create (test = test , title = "Reactivated Finding" , severity = "Low" )
878+ untouched_finding = Finding .objects .create (test = test , title = "Untouched Finding" , severity = "Info" )
879+
875880 BaseImporter (
876881 environment = Development_Environment .objects .get_or_create (name = "Development" )[0 ],
877882 scan_type = "ZAP Scan" ,
878883 ).notify_scan_added (
879884 test ,
880885 updated_count = 4 ,
881886 new_findings = [
882- Finding . objects . create ( test = test , title = "New Finding" , severity = "Critical" ) ,
887+ new_finding ,
883888 ],
884889 findings_mitigated = [
885- Finding . objects . create ( test = test , title = "Mitigated Finding" , severity = "Medium" ) ,
890+ mitigated_finding ,
886891 ],
887892 findings_reactivated = [
888- Finding . objects . create ( test = test , title = "Reactivated Finding" , severity = "Low" ) ,
893+ reactivated_finding ,
889894 ],
890895 findings_untouched = [
891- Finding . objects . create ( test = test , title = "Untouched Finding" , severity = "Info" ) ,
896+ untouched_finding ,
892897 ],
893898 )
894899 self .assertEqual (mock .call_args .kwargs ["headers" ]["X-DefectDojo-Event" ], "scan_added" )
895900 self .maxDiff = None
896901 self .assertEqual (mock .call_args .kwargs ["json" ]["findings" ], {
897902 "new" : [{
898- "id" : 232 ,
903+ "id" : new_finding . id ,
899904 "title" : "New Finding" ,
900905 "severity" : "Critical" ,
901- "url_api" : "http://localhost:8080/api/v2/findings/232 /" ,
902- "url_ui" : "http://localhost:8080/finding/232 " ,
906+ "url_api" : f "http://localhost:8080/api/v2/findings/{ new_finding . id } /" ,
907+ "url_ui" : f "http://localhost:8080/finding/{ new_finding . id } " ,
903908 }],
904909 "mitigated" : [{
905- "id" : 233 ,
910+ "id" : mitigated_finding . id ,
906911 "title" : "Mitigated Finding" ,
907912 "severity" : "Medium" ,
908- "url_api" : "http://localhost:8080/api/v2/findings/233 /" ,
909- "url_ui" : "http://localhost:8080/finding/233 " ,
913+ "url_api" : f "http://localhost:8080/api/v2/findings/{ mitigated_finding . id } /" ,
914+ "url_ui" : f "http://localhost:8080/finding/{ mitigated_finding . id } " ,
910915 }],
911916 "reactivated" : [{
912- "id" : 234 ,
917+ "id" : reactivated_finding . id ,
913918 "title" : "Reactivated Finding" ,
914919 "severity" : "Low" ,
915- "url_api" : "http://localhost:8080/api/v2/findings/234 /" ,
916- "url_ui" : "http://localhost:8080/finding/234 " ,
920+ "url_api" : f "http://localhost:8080/api/v2/findings/{ reactivated_finding . id } /" ,
921+ "url_ui" : f "http://localhost:8080/finding/{ reactivated_finding . id } " ,
917922 }],
918923 "untouched" : [{
919- "id" : 235 ,
924+ "id" : untouched_finding . id ,
920925 "title" : "Untouched Finding" ,
921926 "severity" : "Info" ,
922- "url_api" : "http://localhost:8080/api/v2/findings/235 /" ,
923- "url_ui" : "http://localhost:8080/finding/235 " ,
927+ "url_api" : f "http://localhost:8080/api/v2/findings/{ untouched_finding . id } /" ,
928+ "url_ui" : f "http://localhost:8080/finding/{ untouched_finding . id } " ,
924929 }],
925930 })
926931
927932 with self .subTest ("scan_added problematic titles" ):
933+ colon_new_finding = Finding .objects .create (test = test , title = "Colon: New Finding" , severity = "Critical" )
934+ brackets_mitigated_finding = Finding .objects .create (test = test , title = "[Brackets] Mitigated Finding" , severity = "Medium" )
935+ quotation1_reactivated_finding = Finding .objects .create (test = test , title = '"Quotation1" Reactivated Finding' , severity = "Low" )
936+ quotation2_untouched_finding = Finding .objects .create (test = test , title = "'Quotation2' Untouched Finding" , severity = "Info" )
937+
928938 BaseImporter (
929939 environment = Development_Environment .objects .get_or_create (name = "Development" )[0 ],
930940 scan_type = "ZAP Scan" ,
931941 ).notify_scan_added (
932942 test ,
933943 updated_count = 4 ,
934944 new_findings = [
935- Finding . objects . create ( test = test , title = "Colon: New Finding" , severity = "Critical" ) ,
945+ colon_new_finding ,
936946 ],
937947 findings_mitigated = [
938- Finding . objects . create ( test = test , title = "[Brackets] Mitigated Finding" , severity = "Medium" ) ,
948+ brackets_mitigated_finding ,
939949 ],
940950 findings_reactivated = [
941- Finding . objects . create ( test = test , title = '"Quotation1" Reactivated Finding' , severity = "Low" ) ,
951+ quotation1_reactivated_finding ,
942952 ],
943953 findings_untouched = [
944- Finding . objects . create ( test = test , title = "'Quotation2' Untouched Finding" , severity = "Info" ) ,
954+ quotation2_untouched_finding ,
945955 ],
946956 )
947957 self .assertEqual (mock .call_args .kwargs ["headers" ]["X-DefectDojo-Event" ], "scan_added" )
948958 self .maxDiff = None
949959 self .assertEqual (mock .call_args .kwargs ["json" ]["findings" ], {
950960 "new" : [{
951- "id" : 236 ,
961+ "id" : colon_new_finding . id ,
952962 "title" : "Colon: New Finding" ,
953963 "severity" : "Critical" ,
954- "url_api" : "http://localhost:8080/api/v2/findings/236 /" ,
955- "url_ui" : "http://localhost:8080/finding/236 " ,
964+ "url_api" : f "http://localhost:8080/api/v2/findings/{ colon_new_finding . id } /" ,
965+ "url_ui" : f "http://localhost:8080/finding/{ colon_new_finding . id } " ,
956966 }],
957967 "mitigated" : [{
958- "id" : 237 ,
968+ "id" : brackets_mitigated_finding . id ,
959969 "title" : "[Brackets] Mitigated Finding" ,
960970 "severity" : "Medium" ,
961- "url_api" : "http://localhost:8080/api/v2/findings/237 /" ,
962- "url_ui" : "http://localhost:8080/finding/237 " ,
971+ "url_api" : f "http://localhost:8080/api/v2/findings/{ brackets_mitigated_finding . id } /" ,
972+ "url_ui" : f "http://localhost:8080/finding/{ brackets_mitigated_finding . id } " ,
963973 }],
964974 "reactivated" : [{
965- "id" : 238 ,
975+ "id" : quotation1_reactivated_finding . id ,
966976 "title" : '"Quotation1" Reactivated Finding' ,
967977 "severity" : "Low" ,
968- "url_api" : "http://localhost:8080/api/v2/findings/238 /" ,
969- "url_ui" : "http://localhost:8080/finding/238 " ,
978+ "url_api" : f "http://localhost:8080/api/v2/findings/{ quotation1_reactivated_finding . id } /" ,
979+ "url_ui" : f "http://localhost:8080/finding/{ quotation1_reactivated_finding . id } " ,
970980 }],
971981 "untouched" : [{
972- "id" : 239 ,
982+ "id" : quotation2_untouched_finding . id ,
973983 "title" : "'Quotation2' Untouched Finding" ,
974984 "severity" : "Info" ,
975- "url_api" : "http://localhost:8080/api/v2/findings/239 /" ,
976- "url_ui" : "http://localhost:8080/finding/239 " ,
985+ "url_api" : f "http://localhost:8080/api/v2/findings/{ quotation2_untouched_finding . id } /" ,
986+ "url_ui" : f "http://localhost:8080/finding/{ quotation2_untouched_finding . id } " ,
977987 }],
978988 })
979989
0 commit comments