Opened 10 years ago

Closed 9 years ago

#3331 closed (wontfix)

Client.login() fails when URL contains character requiring urlencoding

Reported by: Morgan Collett <morgan.collett@…> Owned by: Adrian Holovaty
Component: Testing framework Version: master
Severity: Keywords: unittest urlencode
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I wrote a unittest using the Test Client. It was failing to log in to a page protected by @login_required, using the login() method. My path for the login method is '/video/+sub/'. The login() method was returning False, signifying login not possible, even though the username and password were correct.

The reason for the login() failure is that the URL '/video/+sub/' becomes urlencoded as '/video/%2Bsub/' in the redirect to the login form, and the resulting redirect fails. (Why?)

Workarounds are:

  • use a url without a '+' (not optimal in my application)
  • call login() on a different page first, then get() on my page with '+' in the url
  • Perhaps the handling of the urlencoded value is failing when it should succeed? That's beyond my current debugging experience.
  • change as in the attached patch - a one line change to use the non-urlencoded value in path instead of the value passed through in next.

Attachments (1) (393 bytes) - added by Morgan Collett <morgan.collett@…> 10 years ago.
Patch for django/test/

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by Morgan Collett <morgan.collett@…>

Attachment: added

Patch for django/test/

comment:1 Changed 10 years ago by Simon G. <dev@…>

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 9 years ago by Russell Keith-Magee

Resolution: wontfix
Status: newclosed

The test client login() mechanism has been modified to be authentication based, rather than URL based, so this problem has gone away.

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