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