diff options
author | MattBlack85 <promat85@gmail.com> | 2014-02-16 14:47:51 +0100 |
---|---|---|
committer | Honza Král <honza.kral@gmail.com> | 2014-02-16 16:50:50 +0100 |
commit | a8ba76c2d3ad95595590af31c5cda123dc3868b7 (patch) | |
tree | a4946df9c6c1ef13d49fe2b142141cba99b2278f /tests/signed_cookies_tests | |
parent | 8274fa60f88607eb0e81908f049c391455956dd8 (diff) | |
download | django-a8ba76c2d3ad95595590af31c5cda123dc3868b7.tar.gz |
Fixed #19980: Signer broken for binary keys (with non-ASCII chars).
With this pull request, request #878 should considered closed.
Thanks to nvie for the patch.
Diffstat (limited to 'tests/signed_cookies_tests')
-rw-r--r-- | tests/signed_cookies_tests/tests.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/signed_cookies_tests/tests.py b/tests/signed_cookies_tests/tests.py index 6878a3c54f..67f5a2665f 100644 --- a/tests/signed_cookies_tests/tests.py +++ b/tests/signed_cookies_tests/tests.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import time +from django.conf import settings from django.core import signing from django.http import HttpRequest, HttpResponse from django.test import TestCase @@ -62,3 +63,18 @@ class SignedCookieTest(TestCase): request.get_signed_cookie, 'c', max_age=10) finally: time.time = _time + + def test_signed_cookies_with_binary_key(self): + def restore_secret_key(prev): + settings.SECRET_KEY = prev + + self.addCleanup(restore_secret_key, settings.SECRET_KEY) + + settings.SECRET_KEY = b'\xe7' + + response = HttpResponse() + response.set_signed_cookie('c', 'hello') + + request = HttpRequest() + request.COOKIES['c'] = response.cookies['c'].value + self.assertEqual(request.get_signed_cookie('c'), 'hello') |