Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #3210 -- Modified test Client.login() to use urlparse, allowing…

… absolute URLs in the Location header. Thanks, Ben Dean Kawamura.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4540 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 895633a80d04ba95b2efdb3e32ddf560c0693339 1 parent 2fe6476
Russell Keith-Magee authored February 18, 2007
1  AUTHORS
@@ -104,6 +104,7 @@ answer newbie questions, and generally made Django that much better:
104 104
     Michael Josephson <http://www.sdjournal.com/>
105 105
     jpellerin@gmail.com
106 106
     junzhang.jn@gmail.com
  107
+    Ben Dean Kawamura <ben.dean.kawamura@gmail.com>
107 108
     Garth Kidd <http://www.deadlybloodyserious.com/>
108 109
     kilian <kilian.cavalotti@lip6.fr>
109 110
     Sune Kirkeby <http://ibofobi.dk/>
6  django/test/client.py
... ...
@@ -1,5 +1,6 @@
1 1
 import sys
2 2
 from cStringIO import StringIO
  3
+from urlparse import urlparse
3 4
 from django.conf import settings
4 5
 from django.core.handlers.base import BaseHandler
5 6
 from django.core.handlers.wsgi import WSGIRequest
@@ -222,7 +223,7 @@ def login(self, path, username, password, **extra):
222 223
         if response.status_code != 302:
223 224
             return False
224 225
 
225  
-        login_path, data = response['Location'].split('?')
  226
+        _, _, login_path, _, data, _= urlparse(response['Location'])
226 227
         next = data.split('=')[1]
227 228
 
228 229
         # Second, GET the login page; required to set up cookies
@@ -239,7 +240,8 @@ def login(self, path, username, password, **extra):
239 240
         response = self.post(login_path, data=form_data, **extra)
240 241
 
241 242
         # Login page should 302 redirect to the originally requested page
242  
-        if response.status_code != 302 or response['Location'] != path:
  243
+        if (response.status_code != 302 or 
  244
+                urlparse(response['Location'])[2] != path):
243 245
             return False
244 246
 
245 247
         # Since we are logged in, request the actual page again

0 notes on commit 895633a

Please sign in to comment.
Something went wrong with that request. Please try again.