Merge "swift: Take into account swift_store_endpoint"
This commit is contained in:
commit
108947320d
|
@ -143,11 +143,16 @@ class SingleTenantConnectionManager(SwiftConnectionManager):
|
||||||
def _get_storage_url(self):
|
def _get_storage_url(self):
|
||||||
"""Get swift endpoint from keystone
|
"""Get swift endpoint from keystone
|
||||||
|
|
||||||
Return endpoint for swift from service catalog. The method works only
|
Return endpoint for swift from service catalog if not overridden in
|
||||||
Keystone v3. If you are using different version (1 or 2)
|
store configuration. The method works only Keystone v3.
|
||||||
|
If you are using different version (1 or 2)
|
||||||
it returns None.
|
it returns None.
|
||||||
:return: swift endpoint
|
:return: swift endpoint
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self.store.conf_endpoint:
|
||||||
|
return self.store.conf_endpoint
|
||||||
|
|
||||||
if self.store.auth_version == '3':
|
if self.store.auth_version == '3':
|
||||||
try:
|
try:
|
||||||
return self.client.session.get_endpoint(
|
return self.client.session.get_endpoint(
|
||||||
|
|
|
@ -46,6 +46,7 @@ class TestConnectionManager(base.StoreBaseTest):
|
||||||
auth_version='3')
|
auth_version='3')
|
||||||
|
|
||||||
store.backend_group = None
|
store.backend_group = None
|
||||||
|
store.conf_endpoint = None
|
||||||
store.init_client.return_value = self.client
|
store.init_client.return_value = self.client
|
||||||
return store
|
return store
|
||||||
|
|
||||||
|
|
|
@ -1534,6 +1534,31 @@ class TestSingleTenantStoreConnections(base.StoreBaseTest):
|
||||||
'endpoint_type': 'publicURL'},
|
'endpoint_type': 'publicURL'},
|
||||||
connection.os_options)
|
connection.os_options)
|
||||||
|
|
||||||
|
@mock.patch("keystoneauth1.session.Session.get_endpoint")
|
||||||
|
@mock.patch("keystoneauth1.session.Session.get_auth_headers",
|
||||||
|
new=mock.Mock())
|
||||||
|
def _test_connection_manager_authv3_conf_endpoint(
|
||||||
|
self, mock_ep, expected_endpoint="https://from-catalog.com"):
|
||||||
|
self.config(swift_store_auth_version='3')
|
||||||
|
mock_ep.return_value = "https://from-catalog.com"
|
||||||
|
ctx = mock.MagicMock()
|
||||||
|
self.store.configure()
|
||||||
|
connection_manager = manager.SingleTenantConnectionManager(
|
||||||
|
store=self.store,
|
||||||
|
store_location=self.location,
|
||||||
|
context=ctx
|
||||||
|
)
|
||||||
|
conn = connection_manager._init_connection()
|
||||||
|
self.assertEqual(expected_endpoint, conn.preauthurl)
|
||||||
|
|
||||||
|
def test_connection_manager_authv3_without_conf_endpoint(self):
|
||||||
|
self._test_connection_manager_authv3_conf_endpoint()
|
||||||
|
|
||||||
|
def test_connection_manager_authv3_with_conf_endpoint(self):
|
||||||
|
self.config(swift_store_endpoint='http://localhost')
|
||||||
|
self._test_connection_manager_authv3_conf_endpoint(
|
||||||
|
expected_endpoint='http://localhost')
|
||||||
|
|
||||||
def test_connection_with_no_trailing_slash(self):
|
def test_connection_with_no_trailing_slash(self):
|
||||||
self.location.auth_or_store_url = 'example.com/v2'
|
self.location.auth_or_store_url = 'example.com/v2'
|
||||||
connection = self.store.get_connection(self.location)
|
connection = self.store.get_connection(self.location)
|
||||||
|
|
Loading…
Reference in New Issue