Example #1
0
 def test_doesnt_set_csrf_exception_if_session_cookie(self):
     middleware = CSRFHelperMiddleware()
     cookies = {settings.SESSION_COOKIE_NAME: factory.make_name('session')}
     request = factory.make_fake_request(factory.make_string(),
                                         'GET',
                                         cookies=cookies)
     self.assertIsNone(middleware.process_request(request))
     self.assertIsNone(getattr(request, 'csrf_processing_done', None))
Example #2
0
 def test_sets_csrf_exception_if_no_session_cookie(self):
     middleware = CSRFHelperMiddleware()
     cookies = {}
     request = factory.make_fake_request(factory.make_string(),
                                         'GET',
                                         cookies=cookies)
     self.assertIsNone(middleware.process_request(request))
     self.assertTrue(getattr(request, 'csrf_processing_done', None))
Example #3
0
    def process_request(self, request):
        def get_response(request):
            return None

        middleware = CSRFHelperMiddleware(get_response)
        return middleware(request)