diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-12-29 21:55:41 +0100 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-12-29 22:51:13 +0100 |
commit | 59c277effd016fdf771a65aaaa87526ff5fe869e (patch) | |
tree | e25085b994a4033daad1de32c754f78344de6593 | |
parent | 43c74ff1ef72888f4d12e7c52f3dadee6499fc04 (diff) | |
download | mitmproxy-59c277effd016fdf771a65aaaa87526ff5fe869e.tar.gz mitmproxy-59c277effd016fdf771a65aaaa87526ff5fe869e.tar.bz2 mitmproxy-59c277effd016fdf771a65aaaa87526ff5fe869e.zip |
websocket: add flow kill test
-rw-r--r-- | test/mitmproxy/proxy/protocol/test_websocket.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/mitmproxy/proxy/protocol/test_websocket.py b/test/mitmproxy/proxy/protocol/test_websocket.py index a7acdc4d..490d31a0 100644 --- a/test/mitmproxy/proxy/protocol/test_websocket.py +++ b/test/mitmproxy/proxy/protocol/test_websocket.py @@ -221,6 +221,25 @@ class TestSimple(_WebSocketTest): assert frame.payload == b'foo' +class TestKillFlow(_WebSocketTest): + + @classmethod + def handle_websockets(cls, rfile, wfile): + wfile.write(bytes(websockets.Frame(fin=1, opcode=websockets.OPCODE.TEXT, payload=b'server-foobar'))) + wfile.flush() + + def test_kill(self): + class KillFlow: + def websocket_message(self, f): + f.kill() + + self.master.addons.add(KillFlow()) + self.setup_connection() + + frame = websockets.Frame.from_file(self.client.rfile) + assert frame.payload == b'foo' + + class TestSimpleTLS(_WebSocketTest): ssl = True |