def test_parse_error_response_connection(demisto_client_configure, mocker): """ Given - An API exception raised by connection failure When - Parsing error response Then - Ensure a error message is parsed successfully - Verify connection error message printed as expected """ file_type = "widget" file_name = "SomeWidgetName.json" api_exception = ApiException(reason="Failed to establish a new connection:") error_message = parse_error_response(error=api_exception, file_type=file_type, file_name=file_name) assert error_message == 'Failed to establish a new connection: Connection refused.\n' \ 'Try checking your BASE url configuration.'
def test_parse_error_response_ssl(demisto_client_configure, mocker): """ Given - An API exception raised by SSL failure When - Parsing error response Then - Ensure a error message is parsed successfully - Verify SSL error message printed as expected """ file_type = "playbook" file_name = "SomePlaybookName.yml" api_exception = ApiException(reason="[SSL: CERTIFICATE_VERIFY_FAILED]") message = parse_error_response(error=api_exception, file_type=file_type, file_name=file_name) assert message == '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate.\n' \ 'Try running the command with --insecure flag.'
def test_parse_error_response_forbidden(demisto_client_configure, mocker): """ Given - An API exception raised by forbidden failure When - Parsing error response Then - Ensure a error message is parsed successfully - Verify forbidden error message printed as expected """ file_type = "incident field" file_name = "SomeIncidentFieldName.json" api_exception = ApiException(reason="Forbidden", ) api_exception.body = json.dumps({"status": 403, "error": "Error message"}) message = parse_error_response(error=api_exception, file_type=file_type, file_name=file_name) assert message == "Error message\nTry checking your API key configuration."