From 102d92fc09849e1a9004dd3f9a14a0ea9ca392cd Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Sat, 19 Dec 2020 14:21:12 +0100 Subject: Refs #32191 -- Added Signer.sign_object()/unsign_object(). Co-authored-by: Craig Smith --- tests/signing/tests.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') 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 = [ -- cgit v1.3