Make sure --bypass-url honored if specified
Currently SessionClient ignored --bypass-url which is only used with HTTPClient. This change force to use HTTPClient if bypass-url specified. Change-Id: I03d1eec8cfda81efce409399b8d6ca91b779840b Closes-Bug: #1467577
This commit is contained in:
parent
3d06d358ad
commit
03e041a3cd
cinderclient
@ -547,8 +547,8 @@ def _construct_http_client(username=None, password=None, project_id=None,
|
|||||||
auth=None, api_version=None,
|
auth=None, api_version=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
|
||||||
# Don't use sessions if third party plugin is used
|
# Don't use sessions if third party plugin or bypass_url being used
|
||||||
if session and not auth_plugin:
|
if session and not auth_plugin and not bypass_url:
|
||||||
kwargs.setdefault('user_agent', 'python-cinderclient')
|
kwargs.setdefault('user_agent', 'python-cinderclient')
|
||||||
kwargs.setdefault('interface', endpoint_type)
|
kwargs.setdefault('interface', endpoint_type)
|
||||||
return SessionClient(session=session,
|
return SessionClient(session=session,
|
||||||
|
@ -40,6 +40,19 @@ class ClientTest(utils.TestCase):
|
|||||||
self.assertRaises(cinderclient.exceptions.UnsupportedVersion,
|
self.assertRaises(cinderclient.exceptions.UnsupportedVersion,
|
||||||
cinderclient.client.get_client_class, '0')
|
cinderclient.client.get_client_class, '0')
|
||||||
|
|
||||||
|
@mock.patch.object(cinderclient.client.HTTPClient, '__init__')
|
||||||
|
@mock.patch('cinderclient.client.SessionClient')
|
||||||
|
def test_construct_http_client_bypass_url(
|
||||||
|
self, session_mock, httpclient_mock):
|
||||||
|
bypass_url = 'http://example.com/'
|
||||||
|
httpclient_mock.return_value = None
|
||||||
|
cinderclient.client._construct_http_client(
|
||||||
|
bypass_url=bypass_url)
|
||||||
|
self.assertTrue(httpclient_mock.called)
|
||||||
|
self.assertEqual(bypass_url,
|
||||||
|
httpclient_mock.call_args[1].get('bypass_url'))
|
||||||
|
session_mock.assert_not_called()
|
||||||
|
|
||||||
def test_log_req(self):
|
def test_log_req(self):
|
||||||
self.logger = self.useFixture(
|
self.logger = self.useFixture(
|
||||||
fixtures.FakeLogger(
|
fixtures.FakeLogger(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user