diff options
| author | Radomir Dopieralski <openstack@sheep.art.pl> | 2019-07-23 17:11:58 +0200 |
|---|---|---|
| committer | Radomir Dopieralski <openstack@sheep.art.pl> | 2019-09-16 12:45:23 +0200 |
| commit | 9d98a0c24d9a8c2541f820d24c0fc20fb7b4b3f5 (patch) | |
| tree | 7cf9a3b70487c98125a9fa9cc2dc9001a1d6a8af /openstack_auth/tests | |
| parent | 1208919617255eaf3adba1c14320ffc3e4d08d8b (diff) | |
| download | horizon-9d98a0c24d9a8c2541f820d24c0fc20fb7b4b3f5.tar.gz | |
Automatically redirect to the password change when it's expired
Unfortunately the only way we can know the user_id at this point is
by parsing the error message.
I also refactored the exceptions in openstack_auth to make them use
different classes (but one common superclass).
Partially implements blueprint: allow-users-change-expired-password
Change-Id: Ieceee09db21040b96577db19bd195dc3799e3892
Diffstat (limited to 'openstack_auth/tests')
| -rw-r--r-- | openstack_auth/tests/unit/test_auth.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/openstack_auth/tests/unit/test_auth.py b/openstack_auth/tests/unit/test_auth.py index 386f3181b..a668f2a7f 100644 --- a/openstack_auth/tests/unit/test_auth.py +++ b/openstack_auth/tests/unit/test_auth.py @@ -772,6 +772,35 @@ class OpenStackAuthTestsV3(OpenStackAuthTestsMixin, self.assertContains(response, 'option value="Default"') settings.OPENSTACK_KEYSTONE_DOMAIN_DROPDOWN = False + def test_password_expired(self): + user = self.data.user + form_data = self.get_form_data(user) + + class ExpiredException(keystone_exceptions.Unauthorized): + http_status = 401 + message = ("The password is expired and needs to be changed" + " for user: %s." % user.id) + + exc = ExpiredException() + self._mock_client_password_auth_failure(user.name, user.password, exc) + self.mox.ReplayAll() + + url = reverse('login') + + # GET the page to set the test cookie. + response = self.client.get(url, form_data) + self.assertEqual(response.status_code, 200) + + # POST to the page to log in. + response = self.client.post(url, form_data) + + # This fails with TemplateDoesNotExist for some reason. + # self.assertRedirects(response, reverse('password', args=[user.id])) + # so instead we check for the redirect manually: + + self.assertEqual(response.status_code, 302) + self.assertEqual(response.url, "/password/%s/" % user.id) + class OpenStackAuthTestsWebSSO(OpenStackAuthTestsMixin, OpenStackAuthFederatedTestsMixin, |
