def test_running_polling_command_new_search_for_file(mocker): """ Given: An upload request of a file using the polling flow, that was already initiated priorly and is not completed yet. When: When, while in the polling flow, we are checking the status of on an upload that was initiated earlier and is not complete yet. Then: Return a command results object, with scheduling a new command. """ args = SEND_UPLOADED_FILE_TO_SENDBOX_ANALYSIS_ARGS_POLLING mocker.patch('CommonServerPython.ScheduledCommand.raise_error_if_not_supported') mocker.patch.object(Client, '_generate_token') client = Client(server_url="https://api.crowdstrike.com/", username="******", password="******", use_ssl=False, proxy=False, reliability=DBotScoreReliability.B) mocker.patch.object(Client, 'send_uploaded_file_to_sandbox_analysis', return_value=SEND_UPLOADED_FILE_TO_SANDBOX_ANALYSIS_HTTP_RESPONSE) mocker.patch.object(Client, 'get_full_report', return_value=GET_FULL_REPORT_HTTP_RESPONSE) expected_outputs = SEND_UPLOADED_FILE_TO_SENDBOX_ANALYSIS_CONTEXT command_results = run_polling_command(client, args, 'cs-fx-submit-uploaded-file', send_uploaded_file_to_sandbox_analysis_command, get_full_report_command, 'FILE') assert command_results.outputs == expected_outputs assert command_results.scheduled_command is not None
def test_running_polling_command_success_for_file(mocker): """ Given: An upload request of a url or a file using the polling flow, that was already initiated priorly and is now complete. When: When, while in the polling flow, we are checking the status of on an upload that was initiated earlier and is already complete. Then: Return a command results object, without scheduling a new command. """ args = {'ids': "1234", "extended_data": "true"} mocker.patch('CommonServerPython.ScheduledCommand.raise_error_if_not_supported') mocker.patch.object(Client, '_generate_token') client = Client(server_url="https://api.crowdstrike.com/", username="******", password="******", use_ssl=False, proxy=False, reliability=DBotScoreReliability.B) mocker.patch.object(Client, 'send_url_to_sandbox_analysis', return_value=SEND_URL_TO_SANDBOX_ANALYSIS_HTTP_RESPONSE) mocker.patch.object(Client, 'get_full_report', return_value=GET_FULL_REPORT_HTTP_RESPONSE) expected_outputs = GET_FULL_REPORT_CONTEXT_EXTENDED command_results = run_polling_command(client, args, 'cs-fx-submit-uploaded-file', send_uploaded_file_to_sandbox_analysis_command, get_full_report_command, 'FILE') assert isinstance(command_results, list) and len(command_results) == 1 assert command_results[0].outputs == expected_outputs assert command_results[0].scheduled_command is None