diff options
author | Florian Apolloner <florian@apolloner.eu> | 2020-12-19 14:21:12 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-01-06 20:16:47 +0100 |
commit | 102d92fc09849e1a9004dd3f9a14a0ea9ca392cd (patch) | |
tree | d1ac6b18640fc755d9248851aba16edb19e2f30e /tests/signing | |
parent | 5bcba16c0120d4a1bb661f0a495dc47f5ed5465d (diff) | |
download | django-102d92fc09849e1a9004dd3f9a14a0ea9ca392cd.tar.gz |
Refs #32191 -- Added Signer.sign_object()/unsign_object().
Co-authored-by: Craig Smith <hello@craigiansmith.com.au>
Diffstat (limited to 'tests/signing')
-rw-r--r-- | tests/signing/tests.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/signing/tests.py b/tests/signing/tests.py index 835ca4d6b2..50b2b0d9bb 100644 --- a/tests/signing/tests.py +++ b/tests/signing/tests.py @@ -122,6 +122,22 @@ class TestSigner(SimpleTestCase): with self.assertRaises(signing.BadSignature): signer.unsign(transform(signed_value)) + def test_sign_unsign_object(self): + signer = signing.Signer('predictable-secret') + tests = [ + ['a', 'list'], + 'a string \u2019', + {'a': 'dictionary'}, + ] + for obj in tests: + with self.subTest(obj=obj): + signed_obj = signer.sign_object(obj) + self.assertNotEqual(obj, signed_obj) + self.assertEqual(obj, signer.unsign_object(signed_obj)) + signed_obj = signer.sign_object(obj, compress=True) + self.assertNotEqual(obj, signed_obj) + self.assertEqual(obj, signer.unsign_object(signed_obj)) + def test_dumps_loads(self): "dumps and loads be reversible for any JSON serializable object" objects = [ |