From 3e85dfd24227b65762a7f7ca4758dc72ed7e3d91 Mon Sep 17 00:00:00 2001 From: Ujjwal Verma Date: Tue, 9 May 2017 23:38:43 +0530 Subject: Handle head request on onboarding app: Fix #2324 (#2325) --- test/mitmproxy/addons/test_onboarding.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'test') 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 -- cgit v1.2.3