#21448 closed Bug (fixed)
Test Client logout does not work with cookie-based sessions
| Reported by: | Gunnar Scherf | Owned by: | nobody |
|---|---|---|---|
| Component: | Testing framework | Version: | 1.6 |
| Severity: | Release blocker | Keywords: | test client logout cookie session regression |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The test.client.Client.logout does not clear the cookie.
After calling logout the user is still logged in because of the cookie.
A solution would be to clear the cookies in the logout function like in Django 1.5
self.cookies = SimpleCookie()
Change History (7)
comment:1 by , 12 years ago
| Component: | Uncategorized → Testing framework |
|---|
comment:2 by , 12 years ago
| Keywords: | regression added |
|---|---|
| Severity: | Normal → Release blocker |
| Triage Stage: | Unreviewed → Accepted |
comment:3 by , 12 years ago
The commit which introduced this issue is a35ed202419a054a9125ee6205a1a7b4eb3cb46d.
comment:5 by , 12 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:6 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
With that test added:
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index 0f3cba7..ccd3b56 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -356,6 +356,10 @@ class ClientTest(TestCase): response = self.client.get('/test_client/login_protected_view/') self.assertRedirects(response, 'http://testserver/accounts/login/?next=/test_client/login_protected_view/') + @override_settings(SESSION_ENGINE="django.contrib.sessions.backends.signed_cookies") + def test_logout_cookie_sessions(self): + self.test_logout() + def test_view_with_permissions(self): "Request a page that is protected with @permission_required"It fails on 1.6 and pass on 1.5.