test disable_h2c_upgrade addon

This commit is contained in:
Thomas Kriechbaumer 2017-01-23 18:28:57 +01:00
parent d674de298c
commit 5792e2c483
3 changed files with 19 additions and 0 deletions

View File

@ -27,6 +27,7 @@ def ttcpflow(client_conn=True, server_conn=True, messages=True, err=None):
f.reply = controller.DummyReply()
return f
def twebsocketflow(client_conn=True, server_conn=True, messages=True, err=None, handshake_flow=True):
if client_conn is True:

View File

@ -0,0 +1,17 @@
from mitmproxy.addons import disable_h2c_upgrade
from mitmproxy.test import tflow
class TestTermLog:
def test_simple(self):
a = disable_h2c_upgrade.DisableH2CleartextUpgrade()
f = tflow.tflow()
f.request.headers['upgrade'] = 'h2c'
f.request.headers['connection'] = 'foo'
f.request.headers['http2-settings'] = 'bar'
a.request(f)
assert 'upgrade' not in f.request.headers
assert 'connection' not in f.request.headers
assert 'http2-settings' not in f.request.headers

View File

@ -166,6 +166,7 @@ def test_tcp():
d.tcp_error(f)
assert "Error in TCP" in sio.getvalue()
def test_websocket():
sio = io.StringIO()
d = dumper.Dumper(sio)