[Checkins] SVN: PluggableAuthService/trunk/plugins/ use ACTUAL_URL for redirection instead of URL : needed when vhm enters the dance; corresponding test

Godefroid Chapelle gotcha at bubblenet.be
Fri Jun 29 09:47:46 EDT 2007


Log message for revision 77244:
  use ACTUAL_URL for redirection instead of URL : needed when vhm enters the dance; corresponding test

Changed:
  U   PluggableAuthService/trunk/plugins/CookieAuthHelper.py
  U   PluggableAuthService/trunk/plugins/tests/test_CookieAuthHelper.py

-=-
Modified: PluggableAuthService/trunk/plugins/CookieAuthHelper.py
===================================================================
--- PluggableAuthService/trunk/plugins/CookieAuthHelper.py	2007-06-29 13:38:57 UTC (rev 77243)
+++ PluggableAuthService/trunk/plugins/CookieAuthHelper.py	2007-06-29 13:47:46 UTC (rev 77244)
@@ -187,7 +187,7 @@
             came_from = req.get('came_from', None)
 
             if came_from is None:
-                came_from = req.get('URL', '')
+                came_from = req.get('ACTUAL_URL', '')
                 query = req.get('QUERY_STRING')
                 if query:
                     if not query.startswith('?'):
@@ -198,7 +198,7 @@
                 # must be coming through here a second time
                 # Reasons could be typos when providing credentials
                 # or a redirect loop (see below)
-                req_url = req.get('URL', '')
+                req_url = req.get('ACTUAL_URL', '')
 
                 if req_url and req_url == url:
                     # Oops... The login_form cannot be reached by the user -

Modified: PluggableAuthService/trunk/plugins/tests/test_CookieAuthHelper.py
===================================================================
--- PluggableAuthService/trunk/plugins/tests/test_CookieAuthHelper.py	2007-06-29 13:38:57 UTC (rev 77243)
+++ PluggableAuthService/trunk/plugins/tests/test_CookieAuthHelper.py	2007-06-29 13:47:46 UTC (rev 77244)
@@ -12,15 +12,13 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-import unittest
+import unittest, urllib
 
 from Products.PluggableAuthService.tests.conformance \
      import ILoginPasswordHostExtractionPlugin_conformance
 from Products.PluggableAuthService.tests.conformance \
      import IChallengePlugin_conformance
 from Products.PluggableAuthService.tests.conformance \
-     import ICredentialsUpdatePlugin_conformance
-from Products.PluggableAuthService.tests.conformance \
      import ICredentialsResetPlugin_conformance
 
 from Products.PluggableAuthService.tests.test_PluggableAuthService \
@@ -117,10 +115,10 @@
         self.assertEqual(helper.extractCredentials(request), {})
 
     def test_challenge( self ):
-        from zExceptions import Unauthorized
         rc, root, folder, object = self._makeTree()
         response = FauxCookieResponse()
-        request = FauxRequest(RESPONSE=response)
+        testURL = 'http://test'
+        request = FauxRequest(RESPONSE=response, URL=testURL, ACTUAL_URL=testURL)
         root.REQUEST = request
 
         helper = self._makeOne().__of__(root)
@@ -128,8 +126,26 @@
         helper.challenge(request, response)
         self.assertEqual(response.status, 302)
         self.assertEqual(len(response.headers), 1)
+        self.failUnless(response.headers['Location'].endswith(urllib.quote(testURL)))
 
+    def test_challenge_with_vhm( self ):
+        rc, root, folder, object = self._makeTree()
+        response = FauxCookieResponse()
+        vhmURL = 'http://localhost/VirtualHostBase/http/test/VirtualHostRoot/xxx'
+        actualURL = 'http://test/xxx'
 
+
+        request = FauxRequest(RESPONSE=response, URL=vhmURL, ACTUAL_URL=actualURL)
+        root.REQUEST = request
+
+        helper = self._makeOne().__of__(root)
+
+        helper.challenge(request, response)
+        self.assertEqual(response.status, 302)
+        self.assertEqual(len(response.headers), 1)
+        self.failUnless(response.headers['Location'].endswith(urllib.quote(actualURL)))
+        self.failIf(response.headers['Location'].endswith(urllib.quote(vhmURL)))
+
     def test_resetCredentials( self ):
         helper = self._makeOne()
         response = FauxCookieResponse()



More information about the Checkins mailing list