def test_image_get_with_proxy(self): """Test s3 get with proxy connection.""" self.config(s3_store_enable_proxy=True) proxy_host = '127.0.0.1' self.config(s3_store_proxy_host=proxy_host) with mock.patch.object(boto.s3.connection, 'S3Connection') as m: cf = s3.get_calling_format(bucket_format=None, s3_store_bucket_url_format='subdomain') with mock.patch.object(s3, 'get_calling_format') as gcf: gcf.return_value = cf loc = location.get_location_from_uri( "s3://user:key@auth_address/glance/%s" % FAKE_UUID, conf=self.conf) self.store.get(loc) accesskey = S3_CONF['s3_store_access_key'] secretkey = S3_CONF['s3_store_secret_key'] proxy_port = S3_CONF['s3_store_proxy_port'] proxy_pass = S3_CONF['s3_store_proxy_password'] proxy_user = S3_CONF['s3_store_proxy_user'] m.assert_called_with(accesskey, secretkey, calling_format=cf, is_secure=False, proxy=proxy_host, proxy_pass=proxy_pass, proxy_port=proxy_port, proxy_user=proxy_user)
def test_calling_format_default(self): self.assertIsInstance(s3.get_calling_format(), boto.s3.connection.SubdomainCallingFormat)
def test_calling_format_subdomain(self): cf = s3.get_calling_format(s3_store_bucket_url_format='subdomain') self.assertIsInstance(cf, boto.s3.connection.SubdomainCallingFormat)
def test_calling_format_path(self): cf = s3.get_calling_format(s3_store_bucket_url_format='path') self.assertIsInstance(cf, boto.s3.connection.OrdinaryCallingFormat)