1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Made CsrfViewMiddlewareTestMixin._get_GET_no_csrf_cookie_request() return GET requests.

This commit is contained in:
Mariusz Felisiak 2021-03-22 08:22:58 +01:00 committed by GitHub
parent d11b9ffcc0
commit 717b5e633a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,9 @@ class CsrfViewMiddlewareTestMixin:
_csrf_id = _csrf_id_cookie = '1bcdefghij2bcdefghij3bcdefghij4bcdefghij5bcdefghij6bcdefghijABCD' _csrf_id = _csrf_id_cookie = '1bcdefghij2bcdefghij3bcdefghij4bcdefghij5bcdefghij6bcdefghijABCD'
def _get_GET_no_csrf_cookie_request(self): def _get_GET_no_csrf_cookie_request(self):
return TestingHttpRequest() req = TestingHttpRequest()
req.method = 'GET'
return req
def _get_GET_csrf_cookie_request(self): def _get_GET_csrf_cookie_request(self):
raise NotImplementedError('This method must be implemented by a subclass.') raise NotImplementedError('This method must be implemented by a subclass.')
@ -308,7 +310,7 @@ class CsrfViewMiddlewareTestMixin:
CsrfViewMiddleware generates a 403 response if it receives an HTTPS CsrfViewMiddleware generates a 403 response if it receives an HTTPS
request with a bad host. request with a bad host.
""" """
req = self._get_GET_no_csrf_cookie_request() req = self._get_POST_no_csrf_cookie_request()
req._is_secure_override = True req._is_secure_override = True
req.META['HTTP_HOST'] = '@malformed' req.META['HTTP_HOST'] = '@malformed'
req.META['HTTP_REFERER'] = 'https://www.evil.org/somepage' req.META['HTTP_REFERER'] = 'https://www.evil.org/somepage'