diff options
author | Alexandre Arents <alexandre.arents@corp.ovh.com> | 2021-02-19 09:52:00 +0000 |
---|---|---|
committer | Alexandre Arents <alexandre.arents@corp.ovh.com> | 2021-03-01 16:10:37 +0000 |
commit | 16924dbe51c8e3d26c9dda49d6007b73a9869337 (patch) | |
tree | c79bae5b0981a74977ab0a29aac6ccd0901d4ba2 /glance_store/tests | |
parent | bfbea18d8774cb99a9d0a8949b962190c74aa9ad (diff) | |
download | glance_store-16924dbe51c8e3d26c9dda49d6007b73a9869337.tar.gz |
swift: Take into account swift_store_endpoint
In SingleTenant authv3 context, connection manager does not evaluate
swift_store_endpoint and always takes endpoint from catalog.
The change ensures CONF.glance_store.swift_store_endpoint
will take over catalog value also in that case.
Closes-Bug: #1885651
Change-Id: Ib18ff19cd539e0117909f849672036b8c9e5f049
Diffstat (limited to 'glance_store/tests')
-rw-r--r-- | glance_store/tests/unit/test_connection_manager.py | 1 | ||||
-rw-r--r-- | glance_store/tests/unit/test_swift_store.py | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/glance_store/tests/unit/test_connection_manager.py b/glance_store/tests/unit/test_connection_manager.py index 20be2fd..ac1ab91 100644 --- a/glance_store/tests/unit/test_connection_manager.py +++ b/glance_store/tests/unit/test_connection_manager.py @@ -46,6 +46,7 @@ class TestConnectionManager(base.StoreBaseTest): auth_version='3') store.backend_group = None + store.conf_endpoint = None store.init_client.return_value = self.client return store diff --git a/glance_store/tests/unit/test_swift_store.py b/glance_store/tests/unit/test_swift_store.py index 809d50e..6b5d659 100644 --- a/glance_store/tests/unit/test_swift_store.py +++ b/glance_store/tests/unit/test_swift_store.py @@ -1534,6 +1534,31 @@ class TestSingleTenantStoreConnections(base.StoreBaseTest): 'endpoint_type': 'publicURL'}, 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): self.location.auth_or_store_url = 'example.com/v2' connection = self.store.get_connection(self.location) |