diff options
author | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2017-03-10 19:30:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-10 19:30:13 +0100 |
commit | c39b65c06b263e7ed5686df511efb04bd0232c95 (patch) | |
tree | cdcbf0208a3a6096949346dc6b610a4b2b200090 /test | |
parent | db40bdca15780e4c417c819a18ba3b4bcc684c68 (diff) | |
parent | 45bf1ff64d0609a8550d901f731fc21502ad39e9 (diff) | |
download | mitmproxy-c39b65c06b263e7ed5686df511efb04bd0232c95.tar.gz mitmproxy-c39b65c06b263e7ed5686df511efb04bd0232c95.tar.bz2 mitmproxy-c39b65c06b263e7ed5686df511efb04bd0232c95.zip |
Merge pull request #2128 from Kriechi/disable-more-h2c
disable h2c prior knowledge connections
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_disable_h2c.py | 39 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_disable_h2c_upgrade.py | 17 |
2 files changed, 39 insertions, 17 deletions
diff --git a/test/mitmproxy/addons/test_disable_h2c.py b/test/mitmproxy/addons/test_disable_h2c.py new file mode 100644 index 00000000..d4df8390 --- /dev/null +++ b/test/mitmproxy/addons/test_disable_h2c.py @@ -0,0 +1,39 @@ +import io +from mitmproxy import http +from mitmproxy.addons import disable_h2c +from mitmproxy.net.http import http1 +from mitmproxy.exceptions import Kill +from mitmproxy.test import tflow +from mitmproxy.test import taddons + + +class TestDisableH2CleartextUpgrade: + def test_upgrade(self): + with taddons.context() as tctx: + a = disable_h2c.DisableH2C() + tctx.configure(a) + + 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 + + def test_prior_knowledge(self): + with taddons.context() as tctx: + a = disable_h2c.DisableH2C() + tctx.configure(a) + + b = io.BytesIO(b"PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n") + f = tflow.tflow() + f.request = http.HTTPRequest.wrap(http1.read_request(b)) + f.reply.handle() + f.intercept() + + a.request(f) + assert not f.killable + assert f.reply.value == Kill diff --git a/test/mitmproxy/addons/test_disable_h2c_upgrade.py b/test/mitmproxy/addons/test_disable_h2c_upgrade.py deleted file mode 100644 index 6cab713d..00000000 --- a/test/mitmproxy/addons/test_disable_h2c_upgrade.py +++ /dev/null @@ -1,17 +0,0 @@ -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 |