Merge "Use non-versioned auth_url for keystone"

This commit is contained in:
Jenkins 2015-05-06 14:27:25 +00:00 committed by Gerrit Code Review
commit eefebd7682
2 changed files with 13 additions and 1 deletions

View File

@ -56,7 +56,8 @@ class Keystone(object):
self.project_id = project_id
self._client = None
try:
discover = ks_discover.Discover(auth_url=auth_url)
auth_url_noneversion = auth_url.replace('/v2.0', '/')
discover = ks_discover.Discover(auth_url=auth_url_noneversion)
v3_auth_url = discover.url_for('3.0')
if v3_auth_url:
self.auth_url = v3_auth_url

View File

@ -62,6 +62,17 @@ class KeystoneTest(testtools.TestCase):
test_heat.FakeKeystoneClient(self))
self.assertEqual(ks.auth_url, 'http://server.test:5000/v3')
@mock.patch.object(ks_discover.Discover, '__init__')
@mock.patch.object(ks_discover.Discover, 'url_for')
def test_discover_v3_unsupported(self, mock_url_for, mock___init__):
mock___init__.return_value = None
mock_url_for.return_value = None
ks = keystone.Keystone(
'http://server.test:5000/v2.0', 'auser', 'apassword', 'aproject',
test_heat.FakeKeystoneClient(self))
self.assertEqual(ks.auth_url, 'http://server.test:5000/v2.0')
mock___init__.assert_called_with(auth_url='http://server.test:5000/')
@mock.patch.object(ks_discover.Discover, '__init__')
@mock.patch.object(ks_discover.Discover, 'url_for')
def test_cache_is_created(self, mock_url_for, mock___init__):