mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
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.
This commit is contained in:
parent
8274fa60f8
commit
a8ba76c2d3
4 changed files with 31 additions and 5 deletions
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue