def test_get_remote_data_no_entries(mocker): """ Given: - ServiceNow client - arguments: id and LastUpdate(set to lower then the modification time). - ServiceNow ticket - File and comment entries sent from XSOAR. When - running get_remote_data_command. Then - The checked entries was not returned. """ client = Client(server_url='https://server_url.com/', sc_server_url='sc_server_url', username='******', password='******', verify=False, fetch_time='fetch_time', sysparm_query='sysparm_query', sysparm_limit=10, timestamp_field='opened_at', ticket_type='incident', get_attachments=False, incident_name='description') args = {'id': 'sys_id', 'lastUpdate': 0} params = {} mocker.patch.object(client, 'get', return_value=[RESPONSE_TICKET_MIRROR, RESPONSE_ASSIGNMENT_GROUP]) mocker.patch.object(client, 'get_ticket_attachment_entries', return_value=RESPONSE_MIRROR_FILE_ENTRY_FROM_XSOAR) mocker.patch.object(client, 'query', return_value=MIRROR_COMMENTS_RESPONSE_FROM_XSOAR) res = get_remote_data_command(client, args, params) assert 'This is a comment\n\n Mirrored from Cortex XSOAR' not in res assert 'test_mirrored_from_xsoar.txt' not in res
def test_get_remote_data(mocker): """ Given: - ServiceNow client - arguments: id and LastUpdate(set to lower then the modification time). - ServiceNow ticket When - running get_remote_data_command. Then - The ticket was updated with the entries. """ client = Client(server_url='https://server_url.com/', sc_server_url='sc_server_url', username='******', password='******', verify=False, fetch_time='fetch_time', sysparm_query='sysparm_query', sysparm_limit=10, timestamp_field='opened_at', ticket_type='incident', get_attachments=False, incident_name='description') args = {'id': 'sys_id', 'lastUpdate': 0} params = {} mocker.patch.object(client, 'get', return_value=RESPONSE_TICKET_MIRROR) mocker.patch.object(client, 'get_ticket_attachments', return_value=RESPONSE_GET_ATTACHMENT) mocker.patch.object(client, 'get_ticket_attachment_entries', return_value=RESPONSE_MIRROR_FILE_ENTRY) mocker.patch.object(client, 'query', return_value=MIRROR_COMMENTS_RESPONSE) mocker.patch.object(client, 'get', return_value=RESPONSE_ASSIGNMENT_GROUP) res = get_remote_data_command(client, args, params) assert res[1]['File'] == 'test.txt' assert res[2]['Contents'] == 'This is a comment'
def test_get_remote_data_closing_incident(mocker): """ Given: - ServiceNow client - arguments: id and LastUpdate(set to lower then the modification time). - ServiceNow ticket When - running get_remote_data_command. Then - The closed_at field exists in the ticket data. - dbotIncidentClose exists. - Closed notes exists. """ client = Client(server_url='https://server_url.com/', sc_server_url='sc_server_url', username='******', password='******', verify=False, fetch_time='fetch_time', sysparm_query='sysparm_query', sysparm_limit=10, timestamp_field='opened_at', ticket_type='sc_task', get_attachments=False, incident_name='description') args = {'id': 'sys_id', 'lastUpdate': 0} params = {'close_incident': True} mocker.patch.object(client, 'get', return_value=RESPONSE_CLOSING_TICKET_MIRROR) mocker.patch.object(client, 'get_ticket_attachment_entries', return_value=[]) mocker.patch.object(client, 'query', return_value=MIRROR_COMMENTS_RESPONSE) res = get_remote_data_command(client, args, params) assert 'closed_at' in res[0] assert CLOSING_RESPONSE == res[2]['Contents']