Пример #1
0
    def test_extractCredentials_no_creds(self):

        helper = self._makeOne()
        response = FauxCookieResponse()
        request = FauxRequest(RESPONSE=response)

        self.assertEqual(helper.extractCredentials(request), {})
Пример #2
0
    def test_resetCredentials(self):
        helper = self._makeOne()
        response = FauxCookieResponse()
        request = FauxRequest(RESPONSE=response)

        helper.resetCredentials(request, response)
        self.assertEqual(len(response.cookies), 0)
Пример #3
0
    def test_challenge(self):
        from zExceptions import Unauthorized
        rc, root, folder, object = self._makeTree()
        response = FauxCookieResponse()
        request = FauxRequest(RESPONSE=response)
        root.REQUEST = request

        helper = self._makeOne().__of__(root)

        helper.challenge(request, response)
        self.assertEqual(response.status, 302)
        self.assertEqual(len(response.headers), 1)
Пример #4
0
    def test_challenge(self):
        rc, root, folder, object = self._makeTree()
        response = FauxInlineResponse()
        request = FauxRequest(RESPONSE=response)
        root.REQUEST = request

        helper = self._makeOne().__of__(root)
        helper.body = "Overridden"

        self.assertEqual(response.body, "Should never see this.")
        helper.challenge(request, response)
        self.assertEqual(response.body, "Overridden")
Пример #5
0
    def test_challenge( self ):
        rc, root, folder, object = self._makeTree()
        response = FauxCookieResponse()
        testURL = 'http://test'
        request = FauxRequest(RESPONSE=response, URL=testURL, ACTUAL_URL=testURL)
        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(testURL)))
Пример #6
0
    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)))
Пример #7
0
    def test_challenge(self):
        rc, root, folder, object = self._makeTree()
        response = FauxCookieResponse()
        testURL = 'http://test'
        request = FauxRequest(RESPONSE=response,
                              URL=testURL,
                              ACTUAL_URL=testURL)
        root.REQUEST = request

        helper = self._makeOne().__of__(root)

        helper.challenge(request, response)
        self.assertEqual(response.status, 302)
        self.assertEqual(len(response.headers), 3)
        self.assertTrue(response.headers['Location'].endswith(quote(testURL)))
        self.assertEqual(response.headers['Cache-Control'], 'no-cache')
        self.assertEqual(response.headers['Expires'],
                         'Sat, 01 Jan 2000 00:00:00 GMT')
Пример #8
0
    def test_challenge_with_vhm(self):
        rc, root, folder, object = self._makeTree()
        response = FauxCookieResponse()
        vhm = 'http://localhost/VirtualHostBase/http/test/VirtualHostRoot/xxx'
        actualURL = 'http://test/xxx'

        request = FauxRequest(RESPONSE=response, URL=vhm, 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), 3)
        loc = response.headers['Location']
        self.assertTrue(loc.endswith(quote(actualURL)))
        self.assertFalse(loc.endswith(quote(vhm)))
        self.assertEqual(response.headers['Cache-Control'], 'no-cache')
        self.assertEqual(response.headers['Expires'],
                         'Sat, 01 Jan 2000 00:00:00 GMT')