1 From cdf4d30db30bffa44095b07f761183c10316e659 Mon Sep 17 00:00:00 2001
2 From: Doug Fish <drfish@us.ibm.com>
3 Date: Wed, 6 May 2015 05:42:22 -0500
4 Subject: [PATCH] Add missing _ import to plugin/base.py
6 Change-Id: I790246d8c5c8702a6d8b5a3abb07cd46297e051a
8 (cherry picked from commit 8aa02932c3efff3a2f17db474d0f024dbfc38bda)
9 (cherry picked from commit 124a35baea01ea9c81a268d0c3bd09932b4e00cd)
11 openstack_auth/plugin/base.py | 1 +
12 openstack_auth/tests/tests.py | 28 ++++++++++++++++++++++++++++
13 2 files changed, 29 insertions(+)
15 diff --git a/openstack_auth/plugin/base.py b/openstack_auth/plugin/base.py
16 index a2fc755..e3bd802 100644
17 --- a/openstack_auth/plugin/base.py
18 +++ b/openstack_auth/plugin/base.py
23 +from django.utils.translation import ugettext_lazy as _
24 from keystoneclient import exceptions as keystone_exceptions
25 from keystoneclient.v2_0 import client as v2_client
26 from keystoneclient.v3 import client as v3_client
27 diff --git a/openstack_auth/tests/tests.py b/openstack_auth/tests/tests.py
28 index 29bfa3d..09bdc76 100644
29 --- a/openstack_auth/tests/tests.py
30 +++ b/openstack_auth/tests/tests.py
31 @@ -474,6 +474,15 @@ class OpenStackAuthTestsV3(OpenStackAuthTestsMixin, test.TestCase):
32 client.projects = self.mox.CreateMockAnything()
33 client.projects.list(user=user.id).AndReturn(projects)
35 + def _mock_unscoped_client_list_projects_fail(self, user):
36 + client = self._mock_unscoped_client(user)
37 + self._mock_unscoped_list_projects_fail(client, user)
39 + def _mock_unscoped_list_projects_fail(self, client, user):
40 + client.projects = self.mox.CreateMockAnything()
41 + client.projects.list(user=user.id).AndRaise(
42 + keystone_exceptions.AuthorizationFailure)
44 def _create_password_auth(self, username=None, password=None, url=None):
46 username = self.data.user.name
47 @@ -607,6 +616,25 @@ class OpenStackAuthTestsV3(OpenStackAuthTestsMixin, test.TestCase):
48 self.assertContains(response,
49 'You are not authorized for any projects.')
51 + def test_fail_projects(self):
52 + user = self.data.user
54 + form_data = self.get_form_data(user)
55 + self._mock_unscoped_client_list_projects_fail(user)
56 + self.mox.ReplayAll()
58 + url = reverse('login')
60 + # GET the page to set the test cookie.
61 + response = self.client.get(url, form_data)
62 + self.assertEqual(response.status_code, 200)
64 + # POST to the page to log in.
65 + response = self.client.post(url, form_data)
66 + self.assertTemplateUsed(response, 'auth/login.html')
67 + self.assertContains(response,
68 + 'Unable to retrieve authorized projects.')
70 def test_invalid_credentials(self):