test_context_processor.py 501 B

123456789101112131415
  1. from django.http import HttpRequest
  2. from django.template.context_processors import csrf
  3. from django.test import SimpleTestCase
  4. from .tests import CsrfFunctionTestMixin
  5. class TestContextProcessor(CsrfFunctionTestMixin, SimpleTestCase):
  6. def test_force_token_to_string(self):
  7. request = HttpRequest()
  8. test_secret = 32 * 'a'
  9. request.META['CSRF_COOKIE'] = test_secret
  10. token = csrf(request).get('csrf_token')
  11. self.assertMaskedSecretCorrect(token, test_secret)