コード例 #1
0
def test_sigv4_only_region(tmpdir, monkeypatch):
    monkeypatch.setenv('AWS_REGION', 'eu-central-1')
    sigv4_check_apply()

    bucket_name = bucket_name_mangle('sigv4')
    creds = Credentials(os.getenv('AWS_ACCESS_KEY_ID'),
                        os.getenv('AWS_SECRET_ACCESS_KEY'))
    cinfo = calling_format.from_store_name(bucket_name)
    conn = cinfo.connect(creds)

    try:
        conn.create_bucket(bucket_name, location='eu-central-1')
    except boto.exception.S3CreateError:
        pass

    source = unicode(tmpdir.join('source'))
    contents = 'abcdefghijklmnopqrstuvwxyz\n' * 100
    with open(source, 'wb') as f:
        f.write(contents)

    data_url = 's3://{0}/data'.format(bucket_name)

    with open(source) as f:
        uri_put_file(creds, data_url, f)

    results = uri_get_file(creds, data_url)
    assert contents == results
コード例 #2
0
ファイル: test_s3_util.py プロジェクト: LeoCavaille/wal-e
def test_sigv4_only_region(tmpdir, monkeypatch):
    monkeypatch.setenv('AWS_REGION', 'eu-central-1')
    sigv4_check_apply()

    bucket_name = bucket_name_mangle('sigv4')
    creds = Credentials(os.getenv('AWS_ACCESS_KEY_ID'),
                        os.getenv('AWS_SECRET_ACCESS_KEY'))
    cinfo = calling_format.from_store_name(bucket_name)
    conn = cinfo.connect(creds)

    try:
        conn.create_bucket(bucket_name, location='eu-central-1')
    except boto.exception.S3CreateError:
        pass

    source = unicode(tmpdir.join('source'))
    contents = 'abcdefghijklmnopqrstuvwxyz\n' * 100
    with open(source, 'wb') as f:
        f.write(contents)

    data_url = 's3://{0}/data'.format(bucket_name)

    with open(source) as f:
        uri_put_file(creds, data_url, f)

    results = uri_get_file(creds, data_url)
    assert contents == results
コード例 #3
0
    def load_detail(self, conn):
        if self._details_loaded:
            return

        uri = "{scheme}://{bucket}/{path}".format(
            scheme=self.layout.scheme,
            bucket=self.layout.store_name(),
            path=self.layout.basebackup_sentinel(self))

        data = json.loads(s3.uri_get_file(None, uri, conn=conn))
        for k, v in data.items():
            setattr(self, k, v)

        self._details_loaded = True
コード例 #4
0
    def upload_download():
        """ Test uri_put_file and uri_get_file in eu-central-1"""
        source = str(tmpdir.join('source'))
        contents = b'abcdefghijklmnopqrstuvwxyz\n' * 100
        with open(source, 'wb') as f:
            f.write(contents)

        data_url = 's3://{0}/data'.format(bucket_name)

        with open(source) as f:
            uri_put_file(creds, data_url, f)

        results = uri_get_file(creds, data_url)
        assert contents == results
コード例 #5
0
ファイル: s3_storage.py プロジェクト: DataDog/wal-e
    def load_detail(self, conn):
        if self._details_loaded:
            return

        uri = "{scheme}://{bucket}/{path}".format(
            scheme=self.layout.scheme,
            bucket=self.layout.store_name(),
            path=self.layout.basebackup_sentinel(self))

        data = json.loads(s3.uri_get_file(None, uri, conn=conn))
        for k, v in data.items():
            setattr(self, k, v)

        self._details_loaded = True
コード例 #6
0
ファイル: test_s3_util.py プロジェクト: tenstartups/wal-e
    def upload_download():
        """ Test uri_put_file and uri_get_file in eu-central-1"""
        source = str(tmpdir.join("source"))
        contents = b"abcdefghijklmnopqrstuvwxyz\n" * 100
        with open(source, "wb") as f:
            f.write(contents)

        data_url = "s3://{0}/data".format(bucket_name)

        with open(source) as f:
            uri_put_file(creds, data_url, f)

        results = uri_get_file(creds, data_url)
        assert contents == results