mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Added tests for signing non-string values and updated docs.
This commit is contained in:
committed by
Mariusz Felisiak
parent
579f33eb79
commit
8c0c0235b6
@@ -49,6 +49,21 @@ class TestSigner(SimpleTestCase):
|
||||
self.assertNotEqual(example, signed)
|
||||
self.assertEqual(example, signer.unsign(signed))
|
||||
|
||||
def test_sign_unsign_non_string(self):
|
||||
signer = signing.Signer('predictable-secret')
|
||||
values = [
|
||||
123,
|
||||
1.23,
|
||||
True,
|
||||
datetime.date.today(),
|
||||
]
|
||||
for value in values:
|
||||
with self.subTest(value):
|
||||
signed = signer.sign(value)
|
||||
self.assertIsInstance(signed, str)
|
||||
self.assertNotEqual(signed, value)
|
||||
self.assertEqual(signer.unsign(signed), str(value))
|
||||
|
||||
def test_unsign_detects_tampering(self):
|
||||
"unsign should raise an exception if the value has been tampered with"
|
||||
signer = signing.Signer('predictable-secret')
|
||||
|
||||
Reference in New Issue
Block a user