2015-05-26 22:46:13 +02:00
|
|
|
from django.http import HttpRequest
|
|
|
|
from django.template.context_processors import csrf
|
|
|
|
from django.test import SimpleTestCase
|
|
|
|
|
2021-08-17 22:43:17 +02:00
|
|
|
from .tests import CsrfFunctionTestMixin
|
2015-05-26 22:46:13 +02:00
|
|
|
|
2021-08-17 22:43:17 +02:00
|
|
|
|
|
|
|
class TestContextProcessor(CsrfFunctionTestMixin, SimpleTestCase):
|
2017-01-24 12:22:42 +01:00
|
|
|
def test_force_token_to_string(self):
|
2015-05-26 22:46:13 +02:00
|
|
|
request = HttpRequest()
|
2021-08-17 15:13:13 +02:00
|
|
|
test_secret = 32 * "a"
|
|
|
|
request.META["CSRF_COOKIE"] = test_secret
|
2015-05-26 22:46:13 +02:00
|
|
|
token = csrf(request).get("csrf_token")
|
2021-08-17 15:13:13 +02:00
|
|
|
self.assertMaskedSecretCorrect(token, test_secret)
|