mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #14565 - No csrf_token on 404 page.
This solution doesn't have the negative side-effects of [14356]. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14377 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
144ab8877f
commit
90ac02300e
5 changed files with 67 additions and 20 deletions
|
@ -4,7 +4,7 @@ import warnings
|
|||
from django.test import TestCase
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.middleware.csrf import CsrfMiddleware, CsrfViewMiddleware
|
||||
from django.views.decorators.csrf import csrf_exempt, csrf_view_exempt
|
||||
from django.views.decorators.csrf import csrf_exempt, csrf_view_exempt, requires_csrf_token
|
||||
from django.core.context_processors import csrf
|
||||
from django.contrib.sessions.middleware import SessionMiddleware
|
||||
from django.utils.importlib import import_module
|
||||
|
@ -331,6 +331,14 @@ class CsrfMiddlewareTest(TestCase):
|
|||
resp = token_view(req)
|
||||
self._check_token_present(resp)
|
||||
|
||||
def test_get_token_for_requires_csrf_token_view(self):
|
||||
"""
|
||||
Check that get_token works for a view decorated solely with requires_csrf_token
|
||||
"""
|
||||
req = self._get_GET_csrf_cookie_request()
|
||||
resp = requires_csrf_token(token_view)(req)
|
||||
self._check_token_present(resp)
|
||||
|
||||
def test_token_node_with_new_csrf_cookie(self):
|
||||
"""
|
||||
Check that CsrfTokenNode works when a CSRF cookie is created by
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue