diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-09-24 18:21:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-24 18:21:12 -0700 |
commit | 0a643ad20fa45c2fbd8a9de16aa7d632bd89d190 (patch) | |
tree | 13f1880af20c9144afa4edbb215a3771b6b246d8 | |
parent | 92dd030c22a48f8e65638e8cbac633318f203132 (diff) | |
download | mitmproxy-0a643ad20fa45c2fbd8a9de16aa7d632bd89d190.tar.gz mitmproxy-0a643ad20fa45c2fbd8a9de16aa7d632bd89d190.tar.bz2 mitmproxy-0a643ad20fa45c2fbd8a9de16aa7d632bd89d190.zip |
remove option argument for addons.add (#1576)
-rw-r--r-- | mitmproxy/addons.py | 6 | ||||
-rw-r--r-- | mitmproxy/builtins/script.py | 2 | ||||
-rw-r--r-- | mitmproxy/console/master.py | 2 | ||||
-rw-r--r-- | mitmproxy/dump.py | 4 | ||||
-rw-r--r-- | mitmproxy/web/master.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/builtins/test_anticache.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/builtins/test_anticomp.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/builtins/test_dumper.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/builtins/test_filestreamer.py | 4 | ||||
-rw-r--r-- | test/mitmproxy/builtins/test_replace.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/builtins/test_script.py | 15 | ||||
-rw-r--r-- | test/mitmproxy/builtins/test_serverplayback.py | 4 | ||||
-rw-r--r-- | test/mitmproxy/builtins/test_setheaders.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/builtins/test_stickyauth.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/builtins/test_stickycookie.py | 4 | ||||
-rw-r--r-- | test/mitmproxy/script/test_concurrent.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/test_examples.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/test_server.py | 4 | ||||
-rw-r--r-- | test/mitmproxy/tservers.py | 2 |
19 files changed, 32 insertions, 33 deletions
diff --git a/mitmproxy/addons.py b/mitmproxy/addons.py index 2658c0af..db126dd9 100644 --- a/mitmproxy/addons.py +++ b/mitmproxy/addons.py @@ -11,7 +11,7 @@ class Addons(object): def __init__(self, master): self.chain = [] self.master = master - master.options.changed.connect(self.options_update) + master.options.changed.connect(self._options_update) def get(self, name): """ @@ -23,12 +23,12 @@ class Addons(object): if name == _get_name(i): return i - def options_update(self, options, updated): + def _options_update(self, options, updated): for i in self.chain: with self.master.handlecontext(): i.configure(options, updated) - def add(self, options, *addons): + def add(self, *addons): if not addons: raise ValueError("No addons specified.") self.chain.extend(addons) diff --git a/mitmproxy/builtins/script.py b/mitmproxy/builtins/script.py index ba62d416..bbefc5c7 100644 --- a/mitmproxy/builtins/script.py +++ b/mitmproxy/builtins/script.py @@ -249,4 +249,4 @@ class ScriptLoader(): else: ctx.log.info("Loading script: %s" % s) sc = Script(s) - ctx.master.addons.add(options, sc) + ctx.master.addons.add(sc) diff --git a/mitmproxy/console/master.py b/mitmproxy/console/master.py index 8ded1ea1..febf46c5 100644 --- a/mitmproxy/console/master.py +++ b/mitmproxy/console/master.py @@ -256,7 +256,7 @@ class ConsoleMaster(flow.FlowMaster): signals.replace_view_state.connect(self.sig_replace_view_state) signals.push_view_state.connect(self.sig_push_view_state) signals.sig_add_log.connect(self.sig_add_log) - self.addons.add(options, *builtins.default_addons()) + self.addons.add(*builtins.default_addons()) def __setattr__(self, name, value): self.__dict__[name] = value diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py index 778968b9..e894dd36 100644 --- a/mitmproxy/dump.py +++ b/mitmproxy/dump.py @@ -42,8 +42,8 @@ class DumpMaster(flow.FlowMaster): def __init__(self, server, options): flow.FlowMaster.__init__(self, options, server, flow.State()) self.has_errored = False - self.addons.add(options, *builtins.default_addons()) - self.addons.add(options, dumper.Dumper()) + self.addons.add(*builtins.default_addons()) + self.addons.add(dumper.Dumper()) # This line is just for type hinting self.options = self.options # type: Options self.set_stream_large_bodies(options.stream_large_bodies) diff --git a/mitmproxy/web/master.py b/mitmproxy/web/master.py index 5751c9dd..8ea9065b 100644 --- a/mitmproxy/web/master.py +++ b/mitmproxy/web/master.py @@ -136,7 +136,7 @@ class WebMaster(flow.FlowMaster): def __init__(self, server, options): super(WebMaster, self).__init__(options, server, WebState()) - self.addons.add(options, *builtins.default_addons()) + self.addons.add(*builtins.default_addons()) self.app = app.Application( self, self.options.wdebug, self.options.wauthenticator ) diff --git a/test/mitmproxy/builtins/test_anticache.py b/test/mitmproxy/builtins/test_anticache.py index 8897de52..81041e73 100644 --- a/test/mitmproxy/builtins/test_anticache.py +++ b/test/mitmproxy/builtins/test_anticache.py @@ -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) diff --git a/test/mitmproxy/builtins/test_anticomp.py b/test/mitmproxy/builtins/test_anticomp.py index af9e4a6a..f866f33f 100644 --- a/test/mitmproxy/builtins/test_anticomp.py +++ b/test/mitmproxy/builtins/test_anticomp.py @@ -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) diff --git a/test/mitmproxy/builtins/test_dumper.py b/test/mitmproxy/builtins/test_dumper.py index 9b518b53..9df187a5 100644 --- a/test/mitmproxy/builtins/test_dumper.py +++ b/test/mitmproxy/builtins/test_dumper.py @@ -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] diff --git a/test/mitmproxy/builtins/test_filestreamer.py b/test/mitmproxy/builtins/test_filestreamer.py index 94d68813..7964c69a 100644 --- a/test/mitmproxy/builtins/test_filestreamer.py +++ b/test/mitmproxy/builtins/test_filestreamer.py @@ -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) diff --git a/test/mitmproxy/builtins/test_replace.py b/test/mitmproxy/builtins/test_replace.py index 07abcda4..e9869ab7 100644 --- a/test/mitmproxy/builtins/test_replace.py +++ b/test/mitmproxy/builtins/test_replace.py @@ -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" diff --git a/test/mitmproxy/builtins/test_script.py b/test/mitmproxy/builtins/test_script.py index 24337760..f92765ee 100644 --- a/test/mitmproxy/builtins/test_script.py +++ b/test/mitmproxy/builtins/test_script.py @@ -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 == [ diff --git a/test/mitmproxy/builtins/test_serverplayback.py b/test/mitmproxy/builtins/test_serverplayback.py index 4db509da..55ce9350 100644 --- a/test/mitmproxy/builtins/test_serverplayback.py +++ b/test/mitmproxy/builtins/test_serverplayback.py @@ -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) diff --git a/test/mitmproxy/builtins/test_setheaders.py b/test/mitmproxy/builtins/test_setheaders.py index 63685177..d148234d 100644 --- a/test/mitmproxy/builtins/test_setheaders.py +++ b/test/mitmproxy/builtins/test_setheaders.py @@ -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): diff --git a/test/mitmproxy/builtins/test_stickyauth.py b/test/mitmproxy/builtins/test_stickyauth.py index 00b12072..8b939c24 100644 --- a/test/mitmproxy/builtins/test_stickyauth.py +++ b/test/mitmproxy/builtins/test_stickyauth.py @@ -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" diff --git a/test/mitmproxy/builtins/test_stickycookie.py b/test/mitmproxy/builtins/test_stickycookie.py index 13cea6a2..ed92013d 100644 --- a/test/mitmproxy/builtins/test_stickycookie.py +++ b/test/mitmproxy/builtins/test_stickycookie.py @@ -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" diff --git a/test/mitmproxy/script/test_concurrent.py b/test/mitmproxy/script/test_concurrent.py index c4f1e9ae..5f943aeb 100644 --- a/test/mitmproxy/script/test_concurrent.py +++ b/test/mitmproxy/script/test_concurrent.py @@ -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) diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py index 83a37a36..1ba7ba7a 100644 --- a/test/mitmproxy/test_examples.py +++ b/test/mitmproxy/test_examples.py @@ -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 diff --git a/test/mitmproxy/test_server.py b/test/mitmproxy/test_server.py index c5a5bb71..d1886b97 100644 --- a/test/mitmproxy/test_server.py +++ b/test/mitmproxy/test_server.py @@ -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() diff --git a/test/mitmproxy/tservers.py b/test/mitmproxy/tservers.py index 4291f743..119c2cae 100644 --- a/test/mitmproxy/tservers.py +++ b/test/mitmproxy/tservers.py @@ -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() |