def test_list_entries_delete_command(requests_mock): """ Given: Arguments for command - list_entries_add. When: The API gives us results according to the arguments we sent. Then: We check that what is in context (outputs, outputs_prefix) is what should be according to the arguments we sent to the API. """ from CiscoEmailSecurity import list_entries_delete_command requests_mock.post("https://ciscoemailsecurity/sma/api/v2.0/login", json=test_data['data_for_login']) requests_mock.delete( "https://ciscoemailsecurity/sma/api/v2.0/quarantine/safelist", json=test_data['delete_list_entries_response']) client = Client({ "credentials": { "identifier": "a", "password": "******" }, "base_url": "https://ciscoemailsecurity/", "insecure": False, "proxy": False }) res = list_entries_delete_command(client, { "list_type": "safelist", "sender_list": "acme.com", "view_by": "recipient" }) assert res.readable_output == test_data['delete_list_entries_context'] assert res.outputs_prefix == 'CiscoEmailSecurity.listEntry.Safelist' assert res.outputs_key_field == 'acme.com'
def test_list_release_quarantine_messages_command(requests_mock): """ Given: Arguments for command - release_quarantine_messages. When: The API gives us results according to the arguments we sent. Then: We check that what is in context (readable_output, outputs_prefix) is what should be according to the arguments we sent to the API. """ from CiscoEmailSecurity import list_release_quarantine_messages_command requests_mock.post("https://ciscoemailsecurity/sma/api/v2.0/login", json=test_data['data_for_login']) requests_mock.post( "https://ciscoemailsecurity/sma/api/v2.0/quarantine/messages", json=test_data['quarantine_release_message_response_data']) client = Client({ "credentials": { "identifier": "a", "password": "******" }, "base_url": "https://ciscoemailsecurity/", "insecure": False, "proxy": False }) res = list_release_quarantine_messages_command(client, {"messages_ids": "1234"}) assert res.readable_output == test_data[ 'quarantine_release_message_response_data']
def test_list_search_messages_command(requests_mock): """ Given: Arguments for command - list_search_messages. When: The API gives us results according to the arguments we sent. Then: We check that what is in context (outputs, outputs_prefix, outputs_key_field) is what should be according to the arguments we sent to the API. """ from CiscoEmailSecurity import list_search_messages_command requests_mock.post("https://ciscoemailsecurity/sma/api/v2.0/login", json=test_data['data_for_login']) requests_mock.get( "https://ciscoemailsecurity/sma/api/v2.0/message-tracking/messages?" "startDate=2017-02-14T09:51:46.000-0600.000Z&endDate=2017-02-14T09:51:46.000-0600.000Z" "&searchOption=messages&ciscoHost=All_Hosts&offset=0&limit=20", json=test_data['search_messages_response_data']) client = Client({ "credentials": { "identifier": "a", "password": "******" }, "base_url": "https://ciscoemailsecurity/", "insecure": False, "proxy": False, "timeout": "2000" }) res = list_search_messages_command( client, { "start_date": "2017-02-14T09:51:46.000-0600", "end_date": "2017-02-14T09:51:46.000-0600" }) assert res.outputs == test_data['search_messages_context'] assert res.outputs_prefix == 'CiscoEmailSecurity.Message' assert res.outputs_key_field == 'attributes.mid'
def test_list_get_quarantine_message_details_command(requests_mock): """ Given: Arguments for command - get_quarantine_message_details. When: The API gives us results according to the arguments we sent. Then: We check that what is in context (outputs, outputs_prefix, outputs_key_field) is what should be according to the arguments we sent to the API. """ from CiscoEmailSecurity import list_get_quarantine_message_details_command requests_mock.post("https://ciscoemailsecurity/sma/api/v2.0/login", json=test_data['data_for_login']) requests_mock.get( "https://ciscoemailsecurity/sma/api/v2.0/quarantine/messages/details?mid=None" "&quarantineType=spam", json=test_data['quarantine_message_details_response_data']) client = Client({ "credentials": { "identifier": "a", "password": "******" }, "base_url": "https://ciscoemailsecurity/", "insecure": False, "proxy": False, "timeout": "2000" }) res = list_get_quarantine_message_details_command( client, { "start_date": "2017-02-14T09:51:46.000-0600", "end_date": "2017-02-14T09:51:46.000-0600" }) assert res.outputs == test_data['quarantine_message_details_context'] assert res.outputs_prefix == 'CiscoEmailSecurity.QuarantineMessageDetail' assert res.outputs_key_field == 'mid'