Opened 16 months ago

Closed 15 months ago

Last modified 15 months ago

#21448 closed Bug (fixed)

Test Client logout does not work with cookie-based sessions

Reported by: GunnarScherf 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 Changed 16 months ago by GunnarScherf

  • Component changed from Uncategorized to Testing framework
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 16 months ago by claudep

  • Keywords regression added
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 16 months ago by claudep

The commit which introduced this issue is a35ed202419a054a9125ee6205a1a7b4eb3cb46d.

comment:5 Changed 16 months ago by timo

  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 15 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 384816fccb6dfc7fc40f8059811341ba3572d9ff:

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

Thanks Gunnar Scherf for the report and the suggested patch.

comment:7 Changed 15 months ago by Claude Paroz <claude@…>

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