Merge "Add set_management_url to cinderclient.client"

This commit is contained in:
Jenkins 2015-07-07 19:16:37 +00:00 committed by Gerrit Code Review
commit b7d62d0558
2 changed files with 30 additions and 3 deletions

View File

@ -373,6 +373,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

View File

@ -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."""