summaryrefslogtreecommitdiff
path: root/tests/csrf_tests/test_context_processor.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-05-27 09:19:19 -0400
committerTim Graham <timograham@gmail.com>2015-05-27 09:29:45 -0400
commitb16f84f15b1344d2a3df8149565cfc8de803eb77 (patch)
tree82d61d75b5730cd70fb4867a36391c23398bf71e /tests/csrf_tests/test_context_processor.py
parent1e3741b8a3d35e46b50d6490e0d7f5048de0dc86 (diff)
[1.8.x] Refs #24836 -- Reverted "Simplified the lazy CSRF token implementation in csrf context processor."
This reverts commit 8099d33b6553c9ee7de779ae9d191a1bf22adbda as it caused a regression that cannot be solved without changing force_text() which has a small risk of introducing regressions. This change will remain in master along with an update to force_text().
Diffstat (limited to 'tests/csrf_tests/test_context_processor.py')
-rw-r--r--tests/csrf_tests/test_context_processor.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/csrf_tests/test_context_processor.py b/tests/csrf_tests/test_context_processor.py
new file mode 100644
index 0000000000..270b3e4771
--- /dev/null
+++ b/tests/csrf_tests/test_context_processor.py
@@ -0,0 +1,15 @@
+import json
+
+from django.http import HttpRequest
+from django.template.context_processors import csrf
+from django.test import SimpleTestCase
+from django.utils.encoding import force_text
+
+
+class TestContextProcessor(SimpleTestCase):
+
+ def test_force_text_on_token(self):
+ request = HttpRequest()
+ request.META['CSRF_COOKIE'] = 'test-token'
+ token = csrf(request).get('csrf_token')
+ self.assertEqual(json.dumps(force_text(token)), '"test-token"')