Merge "Be more helpful when version discovery fails"
This commit is contained in:
commit
a37d9f6151
@ -138,7 +138,8 @@ class BaseGenericPlugin(base.BaseIdentityPlugin):
|
|||||||
authenticated=False)
|
authenticated=False)
|
||||||
except (exceptions.DiscoveryFailure,
|
except (exceptions.DiscoveryFailure,
|
||||||
exceptions.HttpError,
|
exceptions.HttpError,
|
||||||
exceptions.ConnectionError):
|
exceptions.SSLError,
|
||||||
|
exceptions.ConnectionError) as e:
|
||||||
LOG.warning('Failed to discover available identity versions when '
|
LOG.warning('Failed to discover available identity versions when '
|
||||||
'contacting %s. Attempting to parse version from URL.',
|
'contacting %s. Attempting to parse version from URL.',
|
||||||
self.auth_url)
|
self.auth_url)
|
||||||
@ -153,6 +154,11 @@ class BaseGenericPlugin(base.BaseIdentityPlugin):
|
|||||||
plugin = self.create_plugin(session, (2, 0), self.auth_url)
|
plugin = self.create_plugin(session, (2, 0), self.auth_url)
|
||||||
elif path.startswith('/v3'):
|
elif path.startswith('/v3'):
|
||||||
plugin = self.create_plugin(session, (3, 0), self.auth_url)
|
plugin = self.create_plugin(session, (3, 0), self.auth_url)
|
||||||
|
else:
|
||||||
|
raise exceptions.DiscoveryFailure(
|
||||||
|
'Could not find versioned identity endpoints when '
|
||||||
|
'attempting to authenticate. Please check that your '
|
||||||
|
'auth_url is correct. %s' % e)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# NOTE(jamielennox): version_data is always in oldest to newest
|
# NOTE(jamielennox): version_data is always in oldest to newest
|
||||||
@ -191,8 +197,9 @@ class BaseGenericPlugin(base.BaseIdentityPlugin):
|
|||||||
return plugin
|
return plugin
|
||||||
|
|
||||||
# so there were no URLs that i could use for auth of any version.
|
# so there were no URLs that i could use for auth of any version.
|
||||||
raise exceptions.DiscoveryFailure('Could not determine a suitable URL '
|
raise exceptions.DiscoveryFailure(
|
||||||
'for the plugin')
|
'Could not find versioned identity endpoints when attempting '
|
||||||
|
'to authenticate. Please check that your auth_url is correct.')
|
||||||
|
|
||||||
def get_auth_ref(self, session, **kwargs):
|
def get_auth_ref(self, session, **kwargs):
|
||||||
if not self._plugin:
|
if not self._plugin:
|
||||||
|
@ -1928,3 +1928,27 @@ class GenericAuthPluginTests(utils.TestCase):
|
|||||||
endpoint_filter=self.ENDPOINT_FILTER)
|
endpoint_filter=self.ENDPOINT_FILTER)
|
||||||
|
|
||||||
self.assertIn(name, str(e))
|
self.assertIn(name, str(e))
|
||||||
|
|
||||||
|
|
||||||
|
class DiscoveryFailures(utils.TestCase):
|
||||||
|
TEST_ROOT_URL = 'http://127.0.0.1:5000/'
|
||||||
|
|
||||||
|
def test_connection_error(self):
|
||||||
|
self.requests_mock.get(self.TEST_ROOT_URL,
|
||||||
|
exc=exceptions.ConnectionError)
|
||||||
|
sess = session.Session()
|
||||||
|
p = identity.generic.password.Password(self.TEST_ROOT_URL)
|
||||||
|
self.assertRaises(exceptions.DiscoveryFailure, p.get_auth_ref, sess)
|
||||||
|
|
||||||
|
def test_client_exception(self):
|
||||||
|
self.requests_mock.get(self.TEST_ROOT_URL,
|
||||||
|
exc=exceptions.ClientException)
|
||||||
|
sess = session.Session()
|
||||||
|
p = identity.generic.password.Password(self.TEST_ROOT_URL)
|
||||||
|
self.assertRaises(exceptions.ClientException, p.get_auth_ref, sess)
|
||||||
|
|
||||||
|
def test_ssl_error(self):
|
||||||
|
self.requests_mock.get(self.TEST_ROOT_URL, exc=exceptions.SSLError)
|
||||||
|
sess = session.Session()
|
||||||
|
p = identity.generic.password.Password(self.TEST_ROOT_URL)
|
||||||
|
self.assertRaises(exceptions.DiscoveryFailure, p.get_auth_ref, sess)
|
||||||
|
Loading…
Reference in New Issue
Block a user