def topic(self, callback): conf = Config(TC_AWS_ENDPOINT_URL='http://test.example.com:9000', TC_AWS_CONFIG={ 's3': { 'addressing_style': 'path' }, 'signature_version': 's3v4' }) context = Context(config=conf) presigning_loader._generate_presigned_url(context, "bucket-name", "some-s3-key", callback)
def should_generate_presigned_urls(self, topic): url = presigning_loader._generate_presigned_url( topic, "bucket-name", "some-s3-key") url = urlparse(url) expect(url.scheme).to_equal('https') expect(url.hostname).to_equal('bucket-name.s3.amazonaws.com') expect(url.path).to_equal('/some-s3-key') url_params = parse_qs(url.query) # We can't test Expires & Signature values as they vary depending on the TZ expect(url_params).to_include('Expires') expect(url_params).to_include('Signature') expect(url_params['AWSAccessKeyId'][0]).to_equal('test-key') expect(url_params['x-amz-security-token'][0]).to_equal('test-session-token')
def test_can_build_presigned_url(self): context = Context(config=(Config())) url = yield presigning_loader._generate_presigned_url( context, "bucket-name", "some-s3-key") url = urlparse(url) self.assertEqual(url.scheme[0:4], 'http') self.assertEqual(url.path, '/bucket-name/some-s3-key') url_params = parse_qs(url.query) # We can't test Expires & Signature values as they vary depending on the TZ self.assertIn('Expires', url_params) self.assertIn('Signature', url_params) self.assertDictContainsSubset( { 'AWSAccessKeyId': ['test-key'], 'x-amz-security-token': ['test-session-token'] }, url_params)
def topic(self, callback): conf = Config() context = Context(config=conf) presigning_loader._generate_presigned_url(context, "bucket-name", "some-s3-key", callback)
def topic(self, callback): os.environ['AWS_SHARED_CREDENTIALS_FILE'] = '' conf = Config() context = Context(config=conf) presigning_loader._generate_presigned_url(context, "bucket-name", "some-s3-key", callback)
def topic(self, callback): conf = Config() context = Context(config=conf) presigning_loader._generate_presigned_url(context, "bucket-name", "some-s3-key", callback)
def topic(self, callback): os.environ['AWS_SHARED_CREDENTIALS_FILE'] = '' conf = Config() context = Context(config=conf) presigning_loader._generate_presigned_url(context, "bucket-name", "some-s3-key", callback)