def test_test_module_error(mocker):
    """
    Tests, Handle any other exception received while list_objects from s3..
    """
    from SecurityIntelligenceServicesFeed import test_module
    mocker.patch('botocore.client.BaseClient._make_api_call',
                 side_effect=Exception(''))
    with pytest.raises(ValueError) as v_error:
        test_module(CLIENT, 'domain')
    assert str(v_error.value.args[0]) == MESSAGES['ERROR']
示例#2
0
def test_test_module_proxy_error(mocker):
    """
    Tests, Handle proxy error received while list_objects from build iterator s3.
    """
    from SecurityIntelligenceServicesFeed import test_module
    mocker.patch('botocore.client.BaseClient._make_api_call',
                 side_effect=botocore.exceptions.ProxyConnectionError(proxy_url='proxy_url'))
    with pytest.raises(ValueError) as v_error:
        test_module(CLIENT, 'domain')
    assert str(v_error.value.args[0]) == MESSAGES['PROXY_ERROR'] + 'Failed to connect to proxy URL: "proxy_url"'
def test_test_module_http_client_error(mocker):
    """
    When any parameter is invalid and HTTPClientException occurs.
    Tests, Handle HTTPClientException received while list_objects from build iterator s3.
    """
    from SecurityIntelligenceServicesFeed import test_module
    mocker.patch('botocore.client.BaseClient._make_api_call',
                 side_effect=botocore.exceptions.HTTPClientError(error=''))
    with pytest.raises(ValueError) as v_error:
        test_module(CLIENT, 'domain')
    assert str(v_error.value.args[0]) == MESSAGES[
        'HTTP_CLIENT_ERROR'] + 'An HTTP Client raised an unhandled exception: '
示例#4
0
def test_test_module_client_error(mocker):
    """
    Tests, Handle error occur during extracting feeds.
    """
    from SecurityIntelligenceServicesFeed import test_module
    with open('./TestData/response_list_object.json') as f:
        expected_response = json.load(f)
    expected_response['ResponseMetadata']['HTTPStatusCode'] = 400
    mocker.patch('botocore.client.BaseClient._make_api_call',
                 side_effect=botocore.exceptions.ClientError(expected_response, ''))
    with pytest.raises(ValueError) as v_error:
        test_module(CLIENT, 'domain')
    assert str(v_error.value.args[0]) == MESSAGES['BAD_REQUEST_ERROR']