diff --git a/rest_framework/authentication.py b/rest_framework/authentication.py index a2ba53480..9111007c0 100644 --- a/rest_framework/authentication.py +++ b/rest_framework/authentication.py @@ -136,7 +136,10 @@ class SessionAuthentication(BaseAuthentication): """ Enforce CSRF validation for session based authentication. """ - check = CSRFCheck() + def dummy_get_response(request): # pragma: no cover + return None + + check = CSRFCheck(dummy_get_response) # populates request.META['CSRF_COOKIE'], which is used in process_view() check.process_request(request) reason = check.process_view(request, None, (), {}) diff --git a/tests/test_request.py b/tests/test_request.py index 4425c020f..8f55d00ed 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -205,8 +205,12 @@ class TestUserSetter(TestCase): # available to login and logout functions self.wrapped_request = factory.get('/') self.request = Request(self.wrapped_request) - SessionMiddleware().process_request(self.wrapped_request) - AuthenticationMiddleware().process_request(self.wrapped_request) + + def dummy_get_response(request): # pragma: no cover + return None + + SessionMiddleware(dummy_get_response).process_request(self.wrapped_request) + AuthenticationMiddleware(dummy_get_response).process_request(self.wrapped_request) User.objects.create_user('ringo', 'starr@thebeatles.com', 'yellow') self.user = authenticate(username='ringo', password='yellow')