aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorUjjwal Verma <ujjwalverma1111@gmail.com>2017-05-09 23:38:43 +0530
committerThomas Kriechbaumer <Kriechi@users.noreply.github.com>2017-05-09 20:08:42 +0200
commit3e85dfd24227b65762a7f7ca4758dc72ed7e3d91 (patch)
treefefa326b0ee6100f0e22591a25421d76f31733f6 /test
parent81d68aa564d640a64c5394c0fcd648433e100090 (diff)
downloadmitmproxy-3e85dfd24227b65762a7f7ca4758dc72ed7e3d91.tar.gz
mitmproxy-3e85dfd24227b65762a7f7ca4758dc72ed7e3d91.tar.bz2
mitmproxy-3e85dfd24227b65762a7f7ca4758dc72ed7e3d91.zip
Handle head request on onboarding app: Fix #2324 (#2325)
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_onboarding.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/test/mitmproxy/addons/test_onboarding.py b/test/mitmproxy/addons/test_onboarding.py
index 42a3b574..474e6c3c 100644
--- a/test/mitmproxy/addons/test_onboarding.py
+++ b/test/mitmproxy/addons/test_onboarding.py
@@ -1,5 +1,8 @@
+import pytest
+
from mitmproxy.addons import onboarding
from mitmproxy.test import taddons
+from mitmproxy import options
from .. import tservers
@@ -12,10 +15,21 @@ class TestApp(tservers.HTTPProxyTest):
tctx.configure(self.addons()[0])
assert self.app("/").status_code == 200
- def test_cert(self):
+ @pytest.mark.parametrize("ext", ["pem", "p12"])
+ def test_cert(self, ext):
+ with taddons.context() as tctx:
+ tctx.configure(self.addons()[0])
+ resp = self.app("/cert/%s" % ext)
+ assert resp.status_code == 200
+ assert resp.content
+
+ @pytest.mark.parametrize("ext", ["pem", "p12"])
+ def test_head(self, ext):
with taddons.context() as tctx:
tctx.configure(self.addons()[0])
- for ext in ["pem", "p12"]:
- resp = self.app("/cert/%s" % ext)
+ p = self.pathoc()
+ with p.connect():
+ resp = p.request("head:'http://%s/cert/%s'" % (options.APP_HOST, ext))
assert resp.status_code == 200
- assert resp.content
+ assert "Content-Length" in resp.headers
+ assert not resp.content