aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2018-02-24 14:53:54 +1300
committerAldo Cortesi <aldo@nullcube.com>2018-02-24 14:53:54 +1300
commit74a0230788f1e3a1800d8125fca274cda402c769 (patch)
tree71096b0c704fa5ff80c01a0f11c5f9a5c6c91fa0 /test
parenta12d1492308f281ae599f1142104eb62d924f3f1 (diff)
downloadmitmproxy-74a0230788f1e3a1800d8125fca274cda402c769.tar.gz
mitmproxy-74a0230788f1e3a1800d8125fca274cda402c769.tar.bz2
mitmproxy-74a0230788f1e3a1800d8125fca274cda402c769.zip
addon options: shift keepserving and onboarding options
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_keepserving.py3
-rw-r--r--test/mitmproxy/addons/test_onboarding.py18
-rw-r--r--test/mitmproxy/tservers.py4
3 files changed, 13 insertions, 12 deletions
diff --git a/test/mitmproxy/addons/test_keepserving.py b/test/mitmproxy/addons/test_keepserving.py
index 70f7e1e6..2869d097 100644
--- a/test/mitmproxy/addons/test_keepserving.py
+++ b/test/mitmproxy/addons/test_keepserving.py
@@ -4,7 +4,6 @@ from mitmproxy.test import taddons
def test_keepserving():
ks = keepserving.KeepServing()
-
- with taddons.context() as tctx:
+ with taddons.context(ks) as tctx:
ks.event_processing_complete()
assert tctx.master.should_exit.is_set()
diff --git a/test/mitmproxy/addons/test_onboarding.py b/test/mitmproxy/addons/test_onboarding.py
index 474e6c3c..810ddef1 100644
--- a/test/mitmproxy/addons/test_onboarding.py
+++ b/test/mitmproxy/addons/test_onboarding.py
@@ -2,7 +2,6 @@ import pytest
from mitmproxy.addons import onboarding
from mitmproxy.test import taddons
-from mitmproxy import options
from .. import tservers
@@ -11,25 +10,28 @@ class TestApp(tservers.HTTPProxyTest):
return [onboarding.Onboarding()]
def test_basic(self):
- with taddons.context() as tctx:
- tctx.configure(self.addons()[0])
+ ob = onboarding.Onboarding()
+ with taddons.context(ob) as tctx:
+ tctx.configure(ob)
assert self.app("/").status_code == 200
@pytest.mark.parametrize("ext", ["pem", "p12"])
def test_cert(self, ext):
- with taddons.context() as tctx:
- tctx.configure(self.addons()[0])
+ ob = onboarding.Onboarding()
+ with taddons.context(ob) as tctx:
+ tctx.configure(ob)
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])
+ ob = onboarding.Onboarding()
+ with taddons.context(ob) as tctx:
+ tctx.configure(ob)
p = self.pathoc()
with p.connect():
- resp = p.request("head:'http://%s/cert/%s'" % (options.APP_HOST, ext))
+ resp = p.request("head:'http://%s/cert/%s'" % (tctx.options.onboarding_host, ext))
assert resp.status_code == 200
assert "Content-Length" in resp.headers
assert not resp.content
diff --git a/test/mitmproxy/tservers.py b/test/mitmproxy/tservers.py
index dd5bb327..4363931f 100644
--- a/test/mitmproxy/tservers.py
+++ b/test/mitmproxy/tservers.py
@@ -222,12 +222,12 @@ class HTTPProxyTest(ProxyTestBase):
p = pathod.pathoc.Pathoc(
("127.0.0.1", self.proxy.port), True, fp=None
)
- with p.connect((options.APP_HOST, options.APP_PORT)):
+ with p.connect((self.master.options.onboarding_host, self.master.options.onbarding_port)):
return p.request("get:'%s'" % page)
else:
p = self.pathoc()
with p.connect():
- return p.request("get:'http://%s%s'" % (options.APP_HOST, page))
+ return p.request("get:'http://%s%s'" % (self.master.options.onboarding_host, page))
class TransparentProxyTest(ProxyTestBase):