mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-24 04:14:57 +08:00
remove option argument for addons.add (#1576)
This commit is contained in:
@@ -11,7 +11,7 @@ class TestAntiCache(mastertest.MasterTest):
|
||||
o = options.Options(anticache = True)
|
||||
m = master.FlowMaster(o, None, s)
|
||||
sa = anticache.AntiCache()
|
||||
m.addons.add(o, sa)
|
||||
m.addons.add(sa)
|
||||
|
||||
f = tutils.tflow(resp=True)
|
||||
m.request(f)
|
||||
|
||||
@@ -11,7 +11,7 @@ class TestAntiComp(mastertest.MasterTest):
|
||||
o = options.Options(anticomp = True)
|
||||
m = master.FlowMaster(o, None, s)
|
||||
sa = anticomp.AntiComp()
|
||||
m.addons.add(o, sa)
|
||||
m.addons.add(sa)
|
||||
|
||||
f = tutils.tflow(resp=True)
|
||||
m.request(f)
|
||||
|
||||
@@ -79,6 +79,6 @@ class TestContentView(mastertest.MasterTest):
|
||||
)
|
||||
m = mastertest.RecordingMaster(o, None, s)
|
||||
d = dumper.Dumper()
|
||||
m.addons.add(o, d)
|
||||
m.addons.add(d)
|
||||
m.response(tutils.tflow())
|
||||
assert "Content viewer failed" in m.event_log[0][1]
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestStream(mastertest.MasterTest):
|
||||
m = master.FlowMaster(o, None, s)
|
||||
sa = filestreamer.FileStreamer()
|
||||
|
||||
m.addons.add(o, sa)
|
||||
m.addons.add(sa)
|
||||
f = tutils.tflow(resp=True)
|
||||
m.request(f)
|
||||
m.response(f)
|
||||
@@ -36,7 +36,7 @@ class TestStream(mastertest.MasterTest):
|
||||
|
||||
m.options.outfile = (p, "ab")
|
||||
|
||||
m.addons.add(o, sa)
|
||||
m.addons.add(sa)
|
||||
f = tutils.tflow()
|
||||
m.request(f)
|
||||
m.addons.remove(sa)
|
||||
|
||||
@@ -39,7 +39,7 @@ class TestReplace(mastertest.MasterTest):
|
||||
)
|
||||
m = master.FlowMaster(o, None, s)
|
||||
sa = replace.Replace()
|
||||
m.addons.add(o, sa)
|
||||
m.addons.add(sa)
|
||||
|
||||
f = tutils.tflow()
|
||||
f.request.content = b"foo"
|
||||
|
||||
@@ -63,7 +63,7 @@ class TestScript(mastertest.MasterTest):
|
||||
"data/addonscripts/recorder.py"
|
||||
)
|
||||
)
|
||||
m.addons.add(o, sc)
|
||||
m.addons.add(sc)
|
||||
assert sc.ns.call_log == [
|
||||
("solo", "start", (), {}),
|
||||
("solo", "configure", (o, o.keys()), {})
|
||||
@@ -84,7 +84,7 @@ class TestScript(mastertest.MasterTest):
|
||||
with open("foo.py", "w"):
|
||||
pass
|
||||
sc = script.Script("foo.py")
|
||||
m.addons.add(o, sc)
|
||||
m.addons.add(sc)
|
||||
|
||||
for _ in range(100):
|
||||
with open("foo.py", "a") as f:
|
||||
@@ -102,7 +102,7 @@ class TestScript(mastertest.MasterTest):
|
||||
sc = script.Script(
|
||||
tutils.test_data.path("data/addonscripts/error.py")
|
||||
)
|
||||
m.addons.add(o, sc)
|
||||
m.addons.add(sc)
|
||||
f = tutils.tflow(resp=True)
|
||||
m.request(f)
|
||||
assert m.event_log[0][0] == "error"
|
||||
@@ -116,7 +116,6 @@ class TestScript(mastertest.MasterTest):
|
||||
o = options.Options()
|
||||
fm = master.FlowMaster(o, None, s)
|
||||
fm.addons.add(
|
||||
o,
|
||||
script.Script(
|
||||
tutils.test_data.path("data/addonscripts/duplicate_flow.py")
|
||||
)
|
||||
@@ -136,7 +135,7 @@ class TestScript(mastertest.MasterTest):
|
||||
"data/addonscripts/addon.py"
|
||||
)
|
||||
)
|
||||
m.addons.add(o, sc)
|
||||
m.addons.add(sc)
|
||||
assert sc.ns.event_log == [
|
||||
'scriptstart', 'addonstart', 'addonconfigure'
|
||||
]
|
||||
@@ -166,7 +165,7 @@ class TestScriptLoader(mastertest.MasterTest):
|
||||
o = options.Options(scripts=[])
|
||||
m = master.FlowMaster(o, None, s)
|
||||
sl = script.ScriptLoader()
|
||||
m.addons.add(o, sl)
|
||||
m.addons.add(sl)
|
||||
|
||||
f = tutils.tflow(resp=True)
|
||||
with m.handlecontext():
|
||||
@@ -191,7 +190,7 @@ class TestScriptLoader(mastertest.MasterTest):
|
||||
o = options.Options(scripts=[])
|
||||
m = master.FlowMaster(o, None, s)
|
||||
sc = script.ScriptLoader()
|
||||
m.addons.add(o, sc)
|
||||
m.addons.add(sc)
|
||||
assert len(m.addons) == 1
|
||||
o.update(
|
||||
scripts = [
|
||||
@@ -222,7 +221,7 @@ class TestScriptLoader(mastertest.MasterTest):
|
||||
)
|
||||
m = mastertest.RecordingMaster(o, None, s)
|
||||
sc = script.ScriptLoader()
|
||||
m.addons.add(o, sc)
|
||||
m.addons.add(sc)
|
||||
|
||||
debug = [(i[0], i[1]) for i in m.event_log if i[0] == "debug"]
|
||||
assert debug == [
|
||||
|
||||
@@ -242,7 +242,7 @@ class TestServerPlayback:
|
||||
s = serverplayback.ServerPlayback()
|
||||
o = options.Options(refresh_server_playback = True, keepserving=False)
|
||||
m = mastertest.RecordingMaster(o, None, state)
|
||||
m.addons.add(o, s)
|
||||
m.addons.add(s)
|
||||
|
||||
f = tutils.tflow()
|
||||
f.response = netlib.tutils.tresp(content=f.request.content)
|
||||
@@ -272,7 +272,7 @@ class TestServerPlayback:
|
||||
s = serverplayback.ServerPlayback()
|
||||
o = options.Options(refresh_server_playback = True, replay_kill_extra=True)
|
||||
m = mastertest.RecordingMaster(o, None, state)
|
||||
m.addons.add(o, s)
|
||||
m.addons.add(s)
|
||||
|
||||
f = tutils.tflow()
|
||||
f.response = netlib.tutils.tresp(content=f.request.content)
|
||||
|
||||
@@ -11,7 +11,7 @@ class TestSetHeaders(mastertest.MasterTest):
|
||||
o = options.Options(**opts)
|
||||
m = mastertest.RecordingMaster(o, None, s)
|
||||
sh = setheaders.SetHeaders()
|
||||
m.addons.add(o, sh)
|
||||
m.addons.add(sh)
|
||||
return m, sh
|
||||
|
||||
def test_configure(self):
|
||||
|
||||
@@ -11,7 +11,7 @@ class TestStickyAuth(mastertest.MasterTest):
|
||||
o = options.Options(stickyauth = ".*")
|
||||
m = master.FlowMaster(o, None, s)
|
||||
sa = stickyauth.StickyAuth()
|
||||
m.addons.add(o, sa)
|
||||
m.addons.add(sa)
|
||||
|
||||
f = tutils.tflow(resp=True)
|
||||
f.request.headers["authorization"] = "foo"
|
||||
|
||||
@@ -17,7 +17,7 @@ class TestStickyCookie(mastertest.MasterTest):
|
||||
o = options.Options(stickycookie = ".*")
|
||||
m = master.FlowMaster(o, None, s)
|
||||
sc = stickycookie.StickyCookie()
|
||||
m.addons.add(o, sc)
|
||||
m.addons.add(sc)
|
||||
return s, m, sc
|
||||
|
||||
def test_config(self):
|
||||
@@ -30,7 +30,7 @@ class TestStickyCookie(mastertest.MasterTest):
|
||||
|
||||
def test_simple(self):
|
||||
s, m, sc = self.mk()
|
||||
m.addons.add(m.options, sc)
|
||||
m.addons.add(sc)
|
||||
|
||||
f = tutils.tflow(resp=True)
|
||||
f.response.headers["set-cookie"] = "foo=bar"
|
||||
|
||||
@@ -23,7 +23,7 @@ class TestConcurrent(mastertest.MasterTest):
|
||||
"data/addonscripts/concurrent_decorator.py"
|
||||
)
|
||||
)
|
||||
m.addons.add(m.options, sc)
|
||||
m.addons.add(sc)
|
||||
f1, f2 = tutils.tflow(), tutils.tflow()
|
||||
m.request(f1)
|
||||
m.request(f2)
|
||||
|
||||
@@ -35,7 +35,7 @@ def tscript(cmd, args=""):
|
||||
cmd = example_dir.path(cmd) + " " + args
|
||||
m = RaiseMaster(o, None, state.State())
|
||||
sc = script.Script(cmd)
|
||||
m.addons.add(o, sc)
|
||||
m.addons.add(sc)
|
||||
return m, sc
|
||||
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ class TestHTTP(tservers.HTTPProxyTest, CommonMixin, AppMixin):
|
||||
s = script.Script(
|
||||
tutils.test_data.path("data/addonscripts/stream_modify.py")
|
||||
)
|
||||
self.master.addons.add(self.master.options, s)
|
||||
self.master.addons.add(s)
|
||||
d = self.pathod('200:b"foo"')
|
||||
assert d.content == b"bar"
|
||||
self.master.addons.remove(s)
|
||||
@@ -572,7 +572,7 @@ class TestTransparent(tservers.TransparentProxyTest, CommonMixin, TcpMixin):
|
||||
s = script.Script(
|
||||
tutils.test_data.path("data/addonscripts/tcp_stream_modify.py")
|
||||
)
|
||||
self.master.addons.add(self.master.options, s)
|
||||
self.master.addons.add(s)
|
||||
self._tcpproxy_on()
|
||||
d = self.pathod('200:b"foo"')
|
||||
self._tcpproxy_off()
|
||||
|
||||
@@ -36,7 +36,7 @@ class TestMaster(flow.FlowMaster):
|
||||
s = ProxyServer(config)
|
||||
state = flow.State()
|
||||
flow.FlowMaster.__init__(self, opts, s, state)
|
||||
self.addons.add(opts, *builtins.default_addons())
|
||||
self.addons.add(*builtins.default_addons())
|
||||
self.apps.add(testapp, "testapp", 80)
|
||||
self.apps.add(errapp, "errapp", 80)
|
||||
self.clear_log()
|
||||
|
||||
Reference in New Issue
Block a user