Fix exception catch-all in domain scope auth

Previously, the get_domain_scoped_auth plugin method caught any
exceptions found while trying to scope a token and logged the error
without addressing it. This was hiding an error that was occuring in
the unit tests, which was that some of the plugin calls were not being
mocked properly. This patch narrows down the exception handling to the
same exceptions handled in the project scoping case and adds the
necessary mocks to the tests.

Change-Id: I80a085ca731391b3f54a5ef999c92ab8ba3e69a0
This commit is contained in:
Colleen Murphy 2017-01-19 23:54:52 +01:00
parent ea208c774f
commit f3c21575d2
2 changed files with 9 additions and 1 deletions

View File

@ -205,6 +205,7 @@ class BasePlugin(object):
token,
domain_name=domain_name)
domain_auth_ref = domain_auth.get_access(session)
except Exception:
except (keystone_exceptions.ClientException,
keystone_exceptions.AuthorizationFailure):
LOG.debug('Error getting domain scoped token.', exc_info=True)
return domain_auth, domain_auth_ref

View File

@ -478,6 +478,13 @@ class OpenStackAuthTestsV3(OpenStackAuthTestsMixin,
self._mock_unscoped_list_projects_fail(client, user)
def _mock_unscoped_list_projects_fail(self, client, user):
plugin = self._create_token_auth(
project_id=None,
domain_name=DEFAULT_DOMAIN,
token=self.data.unscoped_access_info.auth_token,
url=settings.OPENSTACK_KEYSTONE_URL)
plugin.get_access(mox.IsA(session.Session)).AndReturn(
self.data.domain_scoped_access_info)
client.projects = self.mox.CreateMockAnything()
client.projects.list(user=user.id).AndRaise(
keystone_exceptions.AuthorizationFailure)