mirror of
https://github.com/django/django.git
synced 2025-11-25 21:22:14 +00:00
Refs #32800 -- Avoided use of _does_token_match() in some CSRF tests.
This commit is contained in:
parent
0820175d81
commit
3f0025c18a
3 changed files with 17 additions and 9 deletions
|
|
@ -1,14 +1,15 @@
|
|||
from django.http import HttpRequest
|
||||
from django.middleware.csrf import _does_token_match as equivalent_tokens
|
||||
from django.template.context_processors import csrf
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
from .tests import CsrfFunctionTestMixin
|
||||
|
||||
class TestContextProcessor(SimpleTestCase):
|
||||
|
||||
class TestContextProcessor(CsrfFunctionTestMixin, SimpleTestCase):
|
||||
|
||||
def test_force_token_to_string(self):
|
||||
request = HttpRequest()
|
||||
test_token = '1bcdefghij2bcdefghij3bcdefghij4bcdefghij5bcdefghij6bcdefghijABCD'
|
||||
request.META['CSRF_COOKIE'] = test_token
|
||||
token = csrf(request).get('csrf_token')
|
||||
self.assertTrue(equivalent_tokens(str(token), test_token))
|
||||
self.assertMaskedSecretCorrect(token, 'lcccccccX2kcccccccY2jcccccccssIC')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue