tests: ensure serialization restrictions are in effect

This commit is contained in:
David Wilson 2019-02-15 12:18:28 +00:00
parent ffdf31edd7
commit e517810e5a
1 changed files with 12 additions and 0 deletions

View File

@ -8,11 +8,23 @@ from mitogen.core import b
import testlib import testlib
class EvilObject(object):
pass
def roundtrip(v): def roundtrip(v):
msg = mitogen.core.Message.pickled(v) msg = mitogen.core.Message.pickled(v)
return mitogen.core.Message(data=msg.data).unpickle() 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): class BlobTest(testlib.TestCase):
klass = mitogen.core.Blob klass = mitogen.core.Blob