def test_bogus_proto_message(self, docker_env): with docker_env.devconnect.get_websocket() as ws: prot = protomsg.ProtoMsg(12345) prot.clear() prot.setTyp(proto_shell.MSG_TYPE_SPAWN_SHELL) msg = prot.encode(b"") ws.send(msg) data = ws.recv() rsp = protomsg.ProtoMsg(0xFFFF) rsp.decode(data) assert rsp.typ == "error" body = rsp.body assert isinstance(body.get("err"), str) and len(body.get("err")) > 0
def get_cmd(ws, timeout=1): pmsg = protomsg.ProtoMsg(proto_shell.PROTO_TYPE_SHELL) body = b"" try: while True: msg = ws.recv(timeout) b = pmsg.decode(msg) if pmsg.typ == proto_shell.MSG_TYPE_SHELL_COMMAND: body += b except TimeoutError: return body
def test_bogus_proto_message(self, docker_env): with docker_env.devconnect.get_websocket() as ws: prot = protomsg.ProtoMsg(12345) prot.clear() prot.setTyp(proto_shell.MSG_TYPE_SPAWN_SHELL) msg = prot.encode(b"") ws.send(msg) msg = ws.recv() body = prot.decode(msg) assert prot.props["status"] == protomsg.PROP_STATUS_ERROR assert prot.protoType == 12345 assert prot.typ == proto_shell.MSG_TYPE_SPAWN_SHELL
def test_bogus_shell_message(self, docker_env): self.assert_env(docker_env) with docker_env.devconnect.get_websocket() as ws: prot = protomsg.ProtoMsg(proto_shell.PROTO_TYPE_SHELL) prot.clear() prot.setTyp("bogusmessage") msg = prot.encode(b"") ws.send(msg) msg = ws.recv() prot.decode(msg) assert prot.props["status"] == protomsg.PROP_STATUS_ERROR assert prot.protoType == proto_shell.PROTO_TYPE_SHELL assert prot.typ == "bogusmessage"
def test_bogus_proto_message( self, class_persistent_standard_setup_one_client_bootstrapped): with devconnect.get_websocket() as ws: prot = protomsg.ProtoMsg(12345) prot.clear() prot.setTyp(proto_shell.MSG_TYPE_SPAWN_SHELL) msg = prot.encode(b"") ws.send(msg) msg = ws.recv() body = prot.decode(msg) assert prot.props["status"] == protomsg.PROP_STATUS_ERROR assert prot.protoType == 12345 assert prot.typ == proto_shell.MSG_TYPE_SPAWN_SHELL