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