Merge "Corrects a flaw in the treatment of swift endpoints"
This commit is contained in:
commit
668929eb40
@ -79,8 +79,8 @@ class _Base(plugin.CentralPollster):
|
||||
def _neaten_url(endpoint, tenant_id):
|
||||
"""Transform the registered url to standard and valid format.
|
||||
"""
|
||||
return urlparse.urljoin(endpoint,
|
||||
'/v1/' + cfg.CONF.reseller_prefix + tenant_id)
|
||||
return urlparse.urljoin(endpoint.split('/v1')[0].rstrip('/') + '/',
|
||||
'v1/' + cfg.CONF.reseller_prefix + tenant_id)
|
||||
|
||||
|
||||
class ObjectsPollster(_Base):
|
||||
|
@ -131,22 +131,21 @@ class TestSwiftPollster(testscenarios.testcase.WithScenarios,
|
||||
self.assertEqual(self.ACCOUNTS[0][0], data[0][0])
|
||||
|
||||
def test_neaten_url(self):
|
||||
test_endpoint = 'http://127.0.0.1:8080'
|
||||
test_endpoints = ['http://127.0.0.1:8080',
|
||||
'http://127.0.0.1:8080/swift']
|
||||
test_tenant_id = 'a7fd1695fa154486a647e44aa99a1b9b'
|
||||
standard_url = test_endpoint + '/v1/' + 'AUTH_' + test_tenant_id
|
||||
for test_endpoint in test_endpoints:
|
||||
standard_url = test_endpoint + '/v1/AUTH_' + test_tenant_id
|
||||
|
||||
self.assertEqual(standard_url,
|
||||
swift._Base._neaten_url(test_endpoint,
|
||||
test_tenant_id))
|
||||
self.assertEqual(standard_url,
|
||||
swift._Base._neaten_url(test_endpoint + '/',
|
||||
test_tenant_id))
|
||||
self.assertEqual(standard_url,
|
||||
swift._Base._neaten_url(test_endpoint + '/v1',
|
||||
test_tenant_id))
|
||||
self.assertEqual(standard_url,
|
||||
swift._Base._neaten_url(standard_url,
|
||||
test_tenant_id))
|
||||
url = swift._Base._neaten_url(test_endpoint, test_tenant_id)
|
||||
self.assertEqual(standard_url, url)
|
||||
url = swift._Base._neaten_url(test_endpoint + '/', test_tenant_id)
|
||||
self.assertEqual(standard_url, url)
|
||||
url = swift._Base._neaten_url(test_endpoint + '/v1',
|
||||
test_tenant_id)
|
||||
self.assertEqual(standard_url, url)
|
||||
url = swift._Base._neaten_url(standard_url, test_tenant_id)
|
||||
self.assertEqual(standard_url, url)
|
||||
|
||||
def test_metering(self):
|
||||
with PatchObject(self.factory, '_iter_accounts',
|
||||
|
Loading…
Reference in New Issue
Block a user