diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-01-23 15:45:53 +0100 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-01-23 15:45:53 +0100 |
commit | d674de298cbaef2eb5348ed65ef51775edadb89b (patch) | |
tree | bfa1157741a776a09b3e36df9779c26958a385ed /test | |
parent | 86174eb6adfb83de6ba4dfbcff73ee9cb18ac4aa (diff) | |
download | mitmproxy-d674de298cbaef2eb5348ed65ef51775edadb89b.tar.gz mitmproxy-d674de298cbaef2eb5348ed65ef51775edadb89b.tar.bz2 mitmproxy-d674de298cbaef2eb5348ed65ef51775edadb89b.zip |
test websocket addon
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_dumper.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/mitmproxy/addons/test_dumper.py b/test/mitmproxy/addons/test_dumper.py index 7ac17a7c..1a2639a2 100644 --- a/test/mitmproxy/addons/test_dumper.py +++ b/test/mitmproxy/addons/test_dumper.py @@ -157,7 +157,7 @@ def test_tcp(): d = dumper.Dumper(sio) with taddons.context(options=dump.Options()) as ctx: ctx.configure(d, flow_detail=3, showhost=True) - f = tflow.ttcpflow(client_conn=True, server_conn=True) + f = tflow.ttcpflow() d.tcp_message(f) assert "it's me" in sio.getvalue() sio.truncate(0) @@ -165,3 +165,20 @@ def test_tcp(): f = tflow.ttcpflow(client_conn=True, err=True) d.tcp_error(f) assert "Error in TCP" in sio.getvalue() + +def test_websocket(): + sio = io.StringIO() + d = dumper.Dumper(sio) + with taddons.context(options=dump.Options()) as ctx: + ctx.configure(d, flow_detail=3, showhost=True) + f = tflow.twebsocketflow() + d.websocket_message(f) + assert "hello text" in sio.getvalue() + sio.truncate(0) + + d.websocket_end(f) + assert "WebSocket connection closed by" in sio.getvalue() + + f = tflow.twebsocketflow(client_conn=True, err=True) + d.websocket_error(f) + assert "Error in WebSocket" in sio.getvalue() |