diff options
author | Colleen Murphy <colleen@gazlene.net> | 2017-01-19 23:54:52 +0100 |
---|---|---|
committer | Colleen Murphy <colleen@gazlene.net> | 2017-01-20 15:22:00 +0100 |
commit | f3c21575d2a3effe1a82a8f22110ea542cb9c9dc (patch) | |
tree | 895cc4c5630d90875ebf9cd62e29e5f96452f021 | |
parent | ea208c774f6707d50b72a72c14d76a5ed0177bc9 (diff) | |
download | django_openstack_auth-f3c21575d2a3effe1a82a8f22110ea542cb9c9dc.tar.gz |
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
-rw-r--r-- | openstack_auth/plugin/base.py | 3 | ||||
-rw-r--r-- | openstack_auth/tests/tests.py | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/openstack_auth/plugin/base.py b/openstack_auth/plugin/base.py index 7170421..5172329 100644 --- a/openstack_auth/plugin/base.py +++ b/openstack_auth/plugin/base.py @@ -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 diff --git a/openstack_auth/tests/tests.py b/openstack_auth/tests/tests.py index 6016d73..45adf2e 100644 --- a/openstack_auth/tests/tests.py +++ b/openstack_auth/tests/tests.py @@ -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) |