JiraChangeStatus
This script changes the status field of a Jira incident. It gets the new Jira status of the remote Jira issue and updates the Cortex XSOAR incident status.
python · Atlassian Jira
Details
| ID | JiraChangeStatus |
|---|---|
| Language | python |
| From Version | 6.8.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Tags | field-change-triggered |
README
This script changes the status field of a Jira incident. It gets the new Jira status of the remote Jira issue and updates the Cortex XSOAR incident status.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | field-change-triggered |
| Cortex XSOAR Version | 5.0.0 |
Inputs
There are no inputs for this script.
Outputs
There are no outputs for this script.
from unittest.mock import MagicMock import demistomock as demisto import pytest from CommonServerPython import * def test_change_jira_status(): """Tests the order of the demisto.executeCommand, and checks if it was run with the correct arguments.""" from ScriptJiraChangeStatus import apply_status demisto.incidents = MagicMock(return_value=[{"dbotMirrorId": "1234", "CustomFields": {"jirav3status": "New Status"}}]) execute_command_mocker = demisto.executeCommand = MagicMock( side_effect=[ None, [{"Type": 1, "Contents": {"fields": {"status": {"name": "New Status"}, "updated": "2023-01-01"}}}], None, None, ] ) apply_status() call_args_list = execute_command_mocker.call_args_list assert call_args_list[0][0] == ("jira-edit-issue", {"issueId": "1234", "status": "New Status", "issue_id": "1234"}) assert call_args_list[1][0] == ("jira-get-issue", {"issueId": "1234", "issue_id": "1234"}) assert call_args_list[2][0] == ("setIncident", {"jirav3status": "New Status"}) assert call_args_list[3][0] == ("setIncident", {"lastupdatetime": "2023-01-01"}) def test_new_status_not_found_error(): """Tests that an error is returned when the new status cannot be extracted after executing the command !jira-get-issue. """ from ScriptJiraChangeStatus import apply_status demisto.incidents = MagicMock(return_value=[{"dbotMirrorId": "1234", "CustomFields": {"jirav3status": "New Status"}}]) demisto.executeCommand = MagicMock( side_effect=[ None, [{"Type": 1, "Contents": {"fields": {"status": {"dummy_key": "dummy value"}, "updated": "2023-01-01"}}}], None, None, ] ) with pytest.raises(DemistoException) as e: apply_status() assert "Could not find: the issue's status name" in str(e) def test_new_updated_time_not_found_error(): """Tests that an error is returned when the new updated time cannot be extracted after executing the command !jira-get-issue. """ from ScriptJiraChangeStatus import apply_status demisto.incidents = MagicMock(return_value=[{"dbotMirrorId": "1234", "CustomFields": {"jirav3status": "New Status"}}]) demisto.executeCommand = MagicMock( side_effect=[None, [{"Type": 1, "Contents": {"fields": {"status": {"name": "New Status"}}}}], None, None, None] ) with pytest.raises(DemistoException) as e: apply_status() assert "could not find the issue's updated time" in str(e)