Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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 Gunnar Scherf, 11 years ago

Component: UncategorizedTesting framework

comment:2 by Claude Paroz, 11 years ago

Keywords: regression added
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

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.

comment:3 by Claude Paroz, 11 years ago

The commit which introduced this issue is a35ed202419a054a9125ee6205a1a7b4eb3cb46d.

comment:5 by Tim Graham, 11 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 384816fccb6dfc7fc40f8059811341ba3572d9ff:

Fixed #21448 -- Fixed test client logout with cookie-based sessions

Thanks Gunnar Scherf for the report and the suggested patch.

comment:7 by Claude Paroz <claude@…>, 11 years ago

In 655b8bb10b3c00d6c96e357d085c20b397a2ffa0:

[1.6.x] Fixed #21448 -- Fixed test client logout with cookie-based sessions

Thanks Gunnar Scherf for the report and the suggested patch.
Backport of 384816fcc from master.

Note: See TracTickets for help on using tickets.
Back to Top