aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2018-02-25 10:15:21 +1300
committerGitHub <noreply@github.com>2018-02-25 10:15:21 +1300
commit6b5b71aefaffebeea9eb0003a25f039686c5b785 (patch)
treed7646ee769029b72d27783c6b265f66541c6e5d9 /test
parentfecdd77a077f23f866a09732ce62ea170707c3e0 (diff)
parent6ea81a96d49c06e2877b727ee7c2d350d3e1a167 (diff)
downloadmitmproxy-6b5b71aefaffebeea9eb0003a25f039686c5b785.tar.gz
mitmproxy-6b5b71aefaffebeea9eb0003a25f039686c5b785.tar.bz2
mitmproxy-6b5b71aefaffebeea9eb0003a25f039686c5b785.zip
Merge pull request #2907 from cortesi/optionscomp
Start moving more complicated options over to /addons
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_allowremote.py5
-rw-r--r--test/mitmproxy/addons/test_dumper.py14
-rw-r--r--test/mitmproxy/addons/test_intercept.py2
-rw-r--r--test/mitmproxy/addons/test_proxyauth.py10
-rw-r--r--test/mitmproxy/tools/console/test_master.py15
-rw-r--r--test/mitmproxy/tools/console/test_statusbar.py2
-rw-r--r--test/mitmproxy/tools/test_dump.py2
7 files changed, 18 insertions, 32 deletions
diff --git a/test/mitmproxy/addons/test_allowremote.py b/test/mitmproxy/addons/test_allowremote.py
index 52dae68d..69019726 100644
--- a/test/mitmproxy/addons/test_allowremote.py
+++ b/test/mitmproxy/addons/test_allowremote.py
@@ -1,7 +1,7 @@
from unittest import mock
import pytest
-from mitmproxy.addons import allowremote
+from mitmproxy.addons import allowremote, proxyauth
from mitmproxy.test import taddons
@@ -19,7 +19,8 @@ from mitmproxy.test import taddons
])
def test_allowremote(allow_remote, ip, should_be_killed):
ar = allowremote.AllowRemote()
- with taddons.context(ar) as tctx:
+ up = proxyauth.ProxyAuth()
+ with taddons.context(ar, up) as tctx:
tctx.options.allow_remote = allow_remote
with mock.patch('mitmproxy.proxy.protocol.base.Layer') as layer:
diff --git a/test/mitmproxy/addons/test_dumper.py b/test/mitmproxy/addons/test_dumper.py
index 9774e131..ead6b7e7 100644
--- a/test/mitmproxy/addons/test_dumper.py
+++ b/test/mitmproxy/addons/test_dumper.py
@@ -14,7 +14,7 @@ from mitmproxy import http
def test_configure():
d = dumper.Dumper()
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, view_filter="~b foo")
assert d.filter
@@ -33,7 +33,7 @@ def test_configure():
def test_simple():
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=0)
d.response(tflow.tflow(resp=True))
assert not sio.getvalue()
@@ -101,7 +101,7 @@ def test_echo_body():
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=3)
d._echo_message(f.response)
t = sio.getvalue()
@@ -111,7 +111,7 @@ def test_echo_body():
def test_echo_request_line():
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=3, showhost=True)
f = tflow.tflow(client_conn=None, server_conn=True, resp=True)
f.request.is_replay = True
@@ -146,7 +146,7 @@ class TestContentView:
view_auto.side_effect = exceptions.ContentViewException("")
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=4, verbosity='debug')
d.response(tflow.tflow())
assert ctx.master.has_log("content viewer failed")
@@ -155,7 +155,7 @@ class TestContentView:
def test_tcp():
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=3, showhost=True)
f = tflow.ttcpflow()
d.tcp_message(f)
@@ -170,7 +170,7 @@ def test_tcp():
def test_websocket():
sio = io.StringIO()
d = dumper.Dumper(sio)
- with taddons.context() as ctx:
+ with taddons.context(d) as ctx:
ctx.configure(d, flow_detail=3, showhost=True)
f = tflow.twebsocketflow()
d.websocket_message(f)
diff --git a/test/mitmproxy/addons/test_intercept.py b/test/mitmproxy/addons/test_intercept.py
index d9598101..b3d24626 100644
--- a/test/mitmproxy/addons/test_intercept.py
+++ b/test/mitmproxy/addons/test_intercept.py
@@ -8,7 +8,7 @@ from mitmproxy.test import tflow
def test_simple():
r = intercept.Intercept()
- with taddons.context() as tctx:
+ with taddons.context(r) as tctx:
assert not r.filt
tctx.configure(r, intercept="~q")
assert r.filt
diff --git a/test/mitmproxy/addons/test_proxyauth.py b/test/mitmproxy/addons/test_proxyauth.py
index 97259d1c..9e2365cf 100644
--- a/test/mitmproxy/addons/test_proxyauth.py
+++ b/test/mitmproxy/addons/test_proxyauth.py
@@ -49,7 +49,7 @@ class TestProxyAuth:
])
def test_is_proxy_auth(self, mode, expected):
up = proxyauth.ProxyAuth()
- with taddons.context() as ctx:
+ with taddons.context(up) as ctx:
ctx.options.mode = mode
assert up.is_proxy_auth() is expected
@@ -75,7 +75,7 @@ class TestProxyAuth:
def test_check(self):
up = proxyauth.ProxyAuth()
- with taddons.context() as ctx:
+ with taddons.context(up) as ctx:
ctx.configure(up, proxyauth="any", mode="regular")
f = tflow.tflow()
assert not up.check(f)
@@ -133,7 +133,7 @@ class TestProxyAuth:
def test_authenticate(self):
up = proxyauth.ProxyAuth()
- with taddons.context() as ctx:
+ with taddons.context(up) as ctx:
ctx.configure(up, proxyauth="any", mode="regular")
f = tflow.tflow()
@@ -165,7 +165,7 @@ class TestProxyAuth:
def test_configure(self):
up = proxyauth.ProxyAuth()
- with taddons.context() as ctx:
+ with taddons.context(up) as ctx:
with pytest.raises(exceptions.OptionsError):
ctx.configure(up, proxyauth="foo")
@@ -223,7 +223,7 @@ class TestProxyAuth:
def test_handlers(self):
up = proxyauth.ProxyAuth()
- with taddons.context() as ctx:
+ with taddons.context(up) as ctx:
ctx.configure(up, proxyauth="any", mode="regular")
f = tflow.tflow()
diff --git a/test/mitmproxy/tools/console/test_master.py b/test/mitmproxy/tools/console/test_master.py
index 6ea61991..5be035e8 100644
--- a/test/mitmproxy/tools/console/test_master.py
+++ b/test/mitmproxy/tools/console/test_master.py
@@ -1,8 +1,6 @@
import urwid
from mitmproxy import options
-from mitmproxy.test import tflow
-from mitmproxy.test import tutils
from mitmproxy.tools import console
from ... import tservers
@@ -24,16 +22,3 @@ class TestMaster(tservers.MasterTest):
except urwid.ExitMainLoop:
pass
assert len(m.view) == i
-
- def test_intercept(self):
- """regression test for https://github.com/mitmproxy/mitmproxy/issues/1605"""
- m = self.mkmaster(intercept="~b bar")
- f = tflow.tflow(req=tutils.treq(content=b"foo"))
- m.addons.handle_lifecycle("request", f)
- assert not m.view[0].intercepted
- f = tflow.tflow(req=tutils.treq(content=b"bar"))
- m.addons.handle_lifecycle("request", f)
- assert m.view[1].intercepted
- f = tflow.tflow(resp=tutils.tresp(content=b"bar"))
- m.addons.handle_lifecycle("request", f)
- assert m.view[2].intercepted
diff --git a/test/mitmproxy/tools/console/test_statusbar.py b/test/mitmproxy/tools/console/test_statusbar.py
index ac17c5c0..db8a63a7 100644
--- a/test/mitmproxy/tools/console/test_statusbar.py
+++ b/test/mitmproxy/tools/console/test_statusbar.py
@@ -14,7 +14,7 @@ def test_statusbar(monkeypatch):
view_filter="~dst example.com",
stickycookie="~dst example.com",
stickyauth="~dst example.com",
- default_contentview="javascript",
+ console_default_contentview="javascript",
anticache=True,
anticomp=True,
showhost=True,
diff --git a/test/mitmproxy/tools/test_dump.py b/test/mitmproxy/tools/test_dump.py
index 952c3f4f..f303c808 100644
--- a/test/mitmproxy/tools/test_dump.py
+++ b/test/mitmproxy/tools/test_dump.py
@@ -11,7 +11,7 @@ from .. import tservers
class TestDumpMaster(tservers.MasterTest):
def mkmaster(self, flt, **opts):
- o = options.Options(view_filter=flt, verbosity='error', flow_detail=0, **opts)
+ o = options.Options(view_filter=flt, verbosity='error', **opts)
m = dump.DumpMaster(o, with_termlog=False, with_dumper=False)
return m