|
9 | 9 | from django.urls import reverse |
10 | 10 | except ImportError: |
11 | 11 | from django.core.urlresolvers import reverse |
12 | | -from django.test import TestCase |
13 | 12 |
|
14 | | -from oidc_provider.lib.utils.token import ( |
15 | | - create_token, |
16 | | - create_id_token, |
17 | | - encode_id_token, |
18 | | -) |
19 | | -from oidc_provider.tests.app.utils import ( |
20 | | - create_fake_client, |
21 | | - create_fake_user, |
22 | | -) |
23 | 13 | import mock |
| 14 | +from django.test import TestCase |
| 15 | + |
| 16 | +from oidc_provider.lib.utils.token import create_id_token, create_token, encode_id_token |
| 17 | +from oidc_provider.tests.app.utils import create_fake_client, create_fake_user |
24 | 18 |
|
25 | 19 |
|
26 | 20 | class EndSessionTestCase(TestCase): |
@@ -126,12 +120,17 @@ def test_prompt_view_redirecting_to_client_post_logout_since_user_unauthenticate |
126 | 120 | self.assertEqual(response.status_code, 302) |
127 | 121 | self.assertEqual(response.headers["Location"], self.url_logout) |
128 | 122 |
|
129 | | - def test_prompt_view_raising_404_since_user_unauthenticated_and_no_client(self): |
| 123 | + def test_prompt_view_show_completed_since_user_unauthenticated_and_no_client(self): |
130 | 124 | self.client.logout() |
131 | 125 | response = self.client.get(self.url_prompt) |
132 | 126 | # Since user is unauthenticated and no client information is present, we just show |
133 | | - # not found page. |
134 | | - self.assertEqual(response.status_code, 404) |
| 127 | + # a page explaining session is closed already. |
| 128 | + self.assertContains( |
| 129 | + response, |
| 130 | + "You've been logged out.", |
| 131 | + status_code=200, |
| 132 | + html=True, |
| 133 | + ) |
135 | 134 |
|
136 | 135 | def test_prompt_view_displaying_logout_decision_form_to_user(self): |
137 | 136 | query_params = { |
@@ -203,13 +202,18 @@ def test_prompt_view_user_logged_out_after_form_not_allowed(self, after_end_sess |
203 | 202 | self.assertFalse(after_end_session_hook.called) |
204 | 203 |
|
205 | 204 | @mock.patch("oidc_provider.views.after_end_session_hook") |
206 | | - def test_prompt_view_user_not_logged_out_after_form_not_allowed_no_client( |
| 205 | + def test_prompt_view_user_still_logged_in_after_form_not_allowed_no_client( |
207 | 206 | self, after_end_session_hook |
208 | 207 | ): |
209 | 208 | self.assertIn("_auth_user_id", self.client.session) |
210 | 209 | response = self.client.post(self.url_prompt) # No data. |
211 | 210 | # Ensure user is still logged in and 404 NOT FOUND was raised. |
212 | 211 | self.assertIn("_auth_user_id", self.client.session) |
213 | | - self.assertEqual(response.status_code, 404) |
| 212 | + self.assertContains( |
| 213 | + response, |
| 214 | + "You can now close this window.", |
| 215 | + status_code=200, |
| 216 | + html=True, |
| 217 | + ) |
214 | 218 | # End session hook should not be called. |
215 | 219 | self.assertFalse(after_end_session_hook.called) |
0 commit comments