Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RTIR issue #27360

Merged
merged 4 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Packs/RTIR/Integrations/RTIR/RTIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import re
import urllib3
import urllib

urllib3.disable_warnings()

Expand Down Expand Up @@ -855,12 +856,10 @@ def add_reply_request(ticket_id, encoded):
def add_reply():
ticket_id = demisto.args().get('ticket-id')
content = 'Action: comment\n'
text = demisto.args().get('text')
if text:
content += '\nText: ' + text.encode('utf-8')
cc = demisto.args().get('cc')
if cc:
content += '\nCc: ' + cc
if (text := demisto.args().get('text')):
content += f'\nText: {text}'
if (cc := demisto.args().get('cc')):
content += f'\nCc: {cc}'
try:
encoded = "content=" + urllib.parse.quote_plus(content)
added_reply = add_reply_request(ticket_id, encoded)
Expand Down
2 changes: 1 addition & 1 deletion Packs/RTIR/Integrations/RTIR/RTIR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ script:
script: '-'
type: python
subtype: python3
dockerimage: demisto/python3:3.10.11.54132
dockerimage: demisto/python3:3.10.12.62631
tests:
- RTIR Test
fromversion: 5.0.0
49 changes: 49 additions & 0 deletions Packs/RTIR/Integrations/RTIR/RTIR_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,52 @@ def test_parse_attachment_content():
response = parse_attachment_content('1234', RAW_ATTACHMENT_CONTENT)
expected = 'some multiline\nattachment content'
assert response == expected


def test_add_reply(mocker):
"""
Test sending a reply from an existing ticket to the user.

Given:
- Valid ticket id and text
- Valid response

When:
- Sending a reply to the user

Then:
- Ensure the reply is sent successfully
"""
from RTIR import add_reply
mocker.patch.object(demisto, 'args', return_value={'ticket-id': '1234', 'text': 'some text'})
mocked_response = requests.Response()
mocked_response._content = b'200'
mocked_response.status_code = 200
mocker.patch('RTIR.add_reply_request', return_value=mocked_response)
mocked_demisto_results = mocker.patch.object(demisto, 'results')
add_reply()
mocked_demisto_results.assert_called_with('Replied successfully to ticket 1234.')


def test_add_reply_fail(mocker):
"""
Test failure in sending a reply from an existing ticket to the user.

Given:
- Invalid response

When:
- Sending a reply to the user

Then:
- Ensure the reply fails with an error message.
"""
from RTIR import add_reply
mocker.patch.object(demisto, 'args', return_value={'ticket-id': '1234', 'text': 'some text'})
mocked_response = requests.Response()
mocked_response._content = b'400'
mocked_response.status_code = 400
mocker.patch('RTIR.add_reply_request', return_value=mocked_response)
mocked_demisto_results = mocker.patch('RTIR.return_error')
add_reply()
mocked_demisto_results.assert_called_with('Failed to reply')
6 changes: 6 additions & 0 deletions Packs/RTIR/ReleaseNotes/1_0_15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### RTIR

- Fixed an issue where `!rtir-add-reply` or `!rtir-add-comment` would fail when provided with the `text` argument.
2 changes: 1 addition & 1 deletion Packs/RTIR/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "RTIR",
"description": "Request Tracker for Incident Response is a ticketing system which provides pre-configured queues and workflows designed for incident response teams.",
"support": "xsoar",
"currentVersion": "1.0.14",
"currentVersion": "1.0.15",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down