Example #1
0
def test_s3_endpoint_for_uri_fail():
    'Connection exceptions in s3_endpoint_for_uri should fail gracefully.'
    uri = 's3://invalid_bucket'
    # Fall back to the default S3 endpoint.
    # Cause failure by passing in an invalid connection object.
    expected = 's3.amazonaws.com'
    result = s3_worker.s3_endpoint_for_uri(uri, connection=object())
    assert result == expected
Example #2
0
 def test_s3_endpoint_for_uri_fail(self):
     'Connection exceptions in s3_endpoint_for_uri should fail gracefully.'
     uri = 's3://invalid_bucket'
     # Fall back to the default S3 endpoint.
     # Cause failure by passing in an invalid connection object.
     self.assertEqual('s3.amazonaws.com',
                      s3_worker.s3_endpoint_for_uri(uri,
                                                    connection=object()))
Example #3
0
def test_s3_endpoint_for_uri_fail():
    "Connection exceptions in s3_endpoint_for_uri should fail gracefully."
    uri = "s3://invalid_bucket"
    # Fall back to the default S3 endpoint.
    # Cause failure by passing in an invalid connection object.
    expected = "s3.amazonaws.com"
    result = s3_worker.s3_endpoint_for_uri(uri, connection=object())
    assert result == expected
Example #4
0
def test_ordinary_calling_format_upcase():
    """Some bucket names have to switch to an older calling format.

    This case tests upper case names -- which are not allowed -- only.
    """

    uri = "s3://InvalidBucket"
    expected = "s3.amazonaws.com"
    result = s3_worker.s3_endpoint_for_uri(uri)
    assert result == expected
Example #5
0
    def test_s3_endpoint_for_uri(self):
        import boto.s3.connection

        aws_access_key = os.getenv('AWS_ACCESS_KEY_ID')
        bucket_name = 'wal-e-test-' + aws_access_key.lower()
        uri = 's3://{b}'.format(b=bucket_name)

        try:
            conn = boto.s3.connection.S3Connection()
            bucket = conn.create_bucket(bucket_name, location='us-west-1')
            self.assertEqual('s3-us-west-1.amazonaws.com',
                             s3_worker.s3_endpoint_for_uri(uri))
        finally:
            conn.delete_bucket(bucket_name)
Example #6
0
    def new_connection(self):
        from boto.s3.connection import OrdinaryCallingFormat
        from boto.s3.connection import S3Connection

        # Work around boto/443 (https://github.com/boto/boto/issues/443)
        if not hasattr(self, 's3_host'):
            connection_args = (
                self.aws_access_key_id,
                self.aws_secret_access_key,
            )
            self.s3_host = s3_worker.s3_endpoint_for_uri(self.s3_prefix,
                                                         connection_args)
        return S3Connection(self.aws_access_key_id,
                            self.aws_secret_access_key,
                            host=self.s3_host,
                            calling_format=OrdinaryCallingFormat())
Example #7
0
    def new_connection(self):
        from boto.s3.connection import OrdinaryCallingFormat
        from boto.s3.connection import S3Connection

        # Work around boto/443 (https://github.com/boto/boto/issues/443)
        if not hasattr(self, 's3_host'):
            connection_args = (
                self.aws_access_key_id,
                self.aws_secret_access_key,
            )
            self.s3_host = s3_worker.s3_endpoint_for_uri(self.s3_prefix,
                                                         connection_args)
        return S3Connection(self.aws_access_key_id,
                            self.aws_secret_access_key,
                            host=self.s3_host,
                            calling_format=OrdinaryCallingFormat())
Example #8
0
def test_s3_endpoint_for_uri():
    """Integration test for bucket naming issues

    AWS credentials and WALE_S3_INTEGRATION_TESTS must be set to run
    this test.
    """
    import boto.s3.connection

    aws_access_key = os.getenv('AWS_ACCESS_KEY_ID')
    bucket_name = 'wal-e-test-' + aws_access_key.lower()
    uri = 's3://{b}'.format(b=bucket_name)

    try:
        conn = boto.s3.connection.S3Connection()
        conn.create_bucket(bucket_name, location='us-west-1')

        expected = 's3-us-west-1.amazonaws.com'
        result = s3_worker.s3_endpoint_for_uri(uri)

        assert result == expected
    finally:
        conn.delete_bucket(bucket_name)
Example #9
0
def test_s3_endpoint_for_upcase_bucket():
    """Integration test for bucket naming issues

    AWS credentials and WALE_S3_INTEGRATION_TESTS must be set to run
    this test.
    """
    import boto.s3.connection

    aws_access_key = os.getenv("AWS_ACCESS_KEY_ID")
    bucket_name = "wal-e-test-" + aws_access_key.upper()
    uri = "s3://{b}".format(b=bucket_name)

    try:
        conn = boto.s3.connection.S3Connection()
        conn.create_bucket(bucket_name)

        expected = "s3.amazonaws.com"
        result = s3_worker.s3_endpoint_for_uri(uri)

        assert result == expected
    finally:
        conn.delete_bucket(bucket_name)