Commit be4a057c authored by Jeremy Hylton's avatar Jeremy Hylton

Add two tests of bad messages sent over the connection.

parent 86ee748a
...@@ -25,6 +25,7 @@ import zLOG ...@@ -25,6 +25,7 @@ import zLOG
import ZEO.ClientStorage import ZEO.ClientStorage
from ZEO.Exceptions import Disconnected from ZEO.Exceptions import Disconnected
from ZEO.zrpc.marshal import Marshaller
from ZODB.Transaction import get_transaction from ZODB.Transaction import get_transaction
from ZODB.POSException import ReadOnlyError from ZODB.POSException import ReadOnlyError
...@@ -452,3 +453,39 @@ class ConnectionTests(StorageTestBase.StorageTestBase): ...@@ -452,3 +453,39 @@ class ConnectionTests(StorageTestBase.StorageTestBase):
# inherit from POSException. # inherit from POSException.
zLOG.LOG("checkReconnection", zLOG.INFO, "finished") zLOG.LOG("checkReconnection", zLOG.INFO, "finished")
def checkBadMessage1(self):
# not even close to a real message
self._bad_message("salty")
def checkBadMessage2(self):
# just like a real message, but with an unpicklable argument
global Hack
class Hack:
pass
msg = Marshaller().encode(1, 0, "foo", (Hack(),))
self._bad_message(msg)
del Hack
def _bad_message(self, msg):
# Establish a connection, then send the server an ill-formatted
# request. Verify that the connection is closed and that it is
# possible to establish a new connection.
self._storage = self.openClientStorage()
self._dostore()
# break into the internals to send a bogus message
zrpc_conn = self._storage._server.rpc
zrpc_conn.message_output(msg)
try:
self._dostore()
except Disconnected:
pass
else:
self.fail("Server did not disconnect after bogus message")
self._storage = self.openClientStorage()
self._dostore()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment