@@ -639,3 +639,31 @@ def test_webhook_update_no_jira_issue_at_all(self):
639639 content_type = "application/json" )
640640
641641 self .assertEqual (200 , response .status_code , response .content [:1000 ])
642+
643+ def test_webhook_issue_updated_extracts_comment (self ):
644+ self .system_settings (enable_jira = True , enable_jira_web_hook = True , disable_jira_webhook_secret = False , jira_webhook_secret = self .correct_secret )
645+
646+ # finding 5 has a JIRA issue in the initial fixture for unit tests with id=2
647+ jira_issue = JIRA_Issue .objects .get (jira_id = 2 )
648+ finding = jira_issue .finding
649+ notes_count_before = finding .notes .count ()
650+
651+ body = json .loads (self .jira_issue_update_template_string )
652+ # Ensure we're targeting the linked issue id
653+ body ["issue" ]["id" ] = 2
654+
655+ response = self .client .post (
656+ reverse ("jira_web_hook_secret" , args = (self .correct_secret , )),
657+ body ,
658+ content_type = "application/json" ,
659+ )
660+
661+ jira_issue .refresh_from_db ()
662+ finding = jira_issue .finding
663+ self .assertEqual (200 , response .status_code , response .content [:1000 ])
664+ self .assertEqual (finding .notes .count (), notes_count_before + 1 )
665+
666+ # Verify the created note content matches expected extraction format
667+ last_note = finding .notes .order_by ("-id" ).first ()
668+ self .assertIsNotNone (last_note )
669+ self .assertEqual (last_note .entry , "(Valentijn Scholten (valentijn)): test2" )
0 commit comments