Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.8.x] Refs #24836 -- Reverted "Simplified the lazy CSRF token imple…
…mentation in csrf context processor." This reverts commit 8099d33 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().
- Loading branch information
Showing
3 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"') |