Add set_management_url to cinderclient.client
set_management_url was used in authenticate method but wasn't defined in the HTTPClient. This commit implements missing method and adds regression unit tests. Change-Id: I605a5d1bcf6cc2dc5720820d8a8122dd17089ffa Closes-Bug: 1418580
This commit is contained in:
parent
f32684747f
commit
95899799da
cinderclient
@ -394,6 +394,9 @@ class HTTPClient(object):
|
||||
return self._extract_service_catalog(url, resp, body,
|
||||
extract_token=False)
|
||||
|
||||
def set_management_url(self, url):
|
||||
self.management_url = url
|
||||
|
||||
def authenticate(self):
|
||||
magic_tuple = urlparse.urlsplit(self.auth_url)
|
||||
scheme, netloc, path, query, frag = magic_tuple
|
||||
|
@ -199,8 +199,9 @@ class DeprecatedAuthPluginTest(utils.TestCase):
|
||||
class AuthPluginTest(utils.TestCase):
|
||||
@mock.patch.object(requests, "request")
|
||||
@mock.patch.object(pkg_resources, "iter_entry_points")
|
||||
def test_auth_system_success(self, mock_iter_entry_points, mock_request):
|
||||
"""Test that we can authenticate using the auth system."""
|
||||
def _test_auth_success(self, mock_iter_entry_points, mock_request,
|
||||
**client_kwargs):
|
||||
"""Generic test that we can authenticate using the auth system."""
|
||||
class MockEntrypoint(pkg_resources.EntryPoint):
|
||||
def load(self):
|
||||
return FakePlugin
|
||||
@ -218,7 +219,7 @@ class AuthPluginTest(utils.TestCase):
|
||||
plugin = auth_plugin.load_plugin("fake")
|
||||
cs = client.Client("username", "password", "project_id",
|
||||
"auth_url/v2.0", auth_system="fake",
|
||||
auth_plugin=plugin)
|
||||
auth_plugin=plugin, **client_kwargs)
|
||||
cs.client.authenticate()
|
||||
|
||||
headers = requested_headers(cs)
|
||||
@ -232,6 +233,29 @@ class AuthPluginTest(utils.TestCase):
|
||||
allow_redirects=True,
|
||||
**self.TEST_REQUEST_BASE)
|
||||
|
||||
return cs.client
|
||||
|
||||
def test_auth_system_success(self):
|
||||
"""Test that we can authenticate using the auth system."""
|
||||
c = self._test_auth_success()
|
||||
self.assertIsNone(c.bypass_url)
|
||||
self.assertIsNone(c.proxy_token)
|
||||
|
||||
def test_auth_bypass_url(self):
|
||||
"""Test that we can authenticate with bypass URL."""
|
||||
c = self._test_auth_success(bypass_url='auth_url2/v2.0')
|
||||
self.assertEqual('auth_url2/v2.0', c.bypass_url)
|
||||
self.assertEqual('auth_url2/v2.0', c.management_url)
|
||||
self.assertIsNone(c.proxy_token)
|
||||
|
||||
def test_auth_bypass_url_proxy_token(self):
|
||||
"""Test that we can authenticate with bypass URL and proxy token."""
|
||||
c = self._test_auth_success(proxy_token='abc',
|
||||
bypass_url='auth_url2/v2.0')
|
||||
self.assertEqual('auth_url2/v2.0', c.bypass_url)
|
||||
self.assertEqual('auth_url2/v2.0', c.management_url)
|
||||
self.assertEqual('abc', c.proxy_token)
|
||||
|
||||
@mock.patch.object(pkg_resources, "iter_entry_points")
|
||||
def test_discover_auth_system_options(self, mock_iter_entry_points):
|
||||
"""Test that we can load the auth system options."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user