tests/csrf_tests/test_context_processor.py
raw| 1 | from django.http import HttpRequest |
| 2 | from django.template.context_processors import csrf |
| 3 | from django.test import SimpleTestCase |
| 4 | |
| 5 | from .tests import CsrfFunctionTestMixin |
| 6 | |
| 7 | |
| 8 | class TestContextProcessor(CsrfFunctionTestMixin, SimpleTestCase): |
| 9 | def test_force_token_to_string(self): |
| 10 | request = HttpRequest() |
| 11 | test_secret = 32 * "a" |
| 12 | request.META["CSRF_COOKIE"] = test_secret |
| 13 | token = csrf(request).get("csrf_token") |
| 14 | self.assertMaskedSecretCorrect(token, test_secret) |