From e517810e5a3b1826e8ec1f53160345b8847c0a18 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Fri, 15 Feb 2019 12:18:28 +0000 Subject: [PATCH] tests: ensure serialization restrictions are in effect --- tests/serialization_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/serialization_test.py b/tests/serialization_test.py index 23c4a2d9..6cf5f8b7 100644 --- a/tests/serialization_test.py +++ b/tests/serialization_test.py @@ -8,11 +8,23 @@ from mitogen.core import b import testlib +class EvilObject(object): + pass + + def roundtrip(v): msg = mitogen.core.Message.pickled(v) return mitogen.core.Message(data=msg.data).unpickle() +class EvilObjectTest(testlib.TestCase): + def test_deserialization_fails(self): + msg = mitogen.core.Message.pickled(EvilObject()) + e = self.assertRaises(mitogen.core.StreamError, + lambda: msg.unpickle() + ) + + class BlobTest(testlib.TestCase): klass = mitogen.core.Blob