diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2016-07-23 11:28:44 +1200 |
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2016-07-23 11:29:13 +1200 |
| commit | 9294d19f908cdde86b390fb2fa93aad422da8522 (patch) | |
| tree | 86e04324017d3c80ba51b1693d4f0a62142963d0 /test | |
| parent | 05caa0a03d118a8f0fdf42bbe34ed74c8940c4a0 (diff) | |
| download | mitmproxy-9294d19f908cdde86b390fb2fa93aad422da8522.tar.gz mitmproxy-9294d19f908cdde86b390fb2fa93aad422da8522.tar.bz2 mitmproxy-9294d19f908cdde86b390fb2fa93aad422da8522.zip | |
scripts: .start can now return an Addon instance
Diffstat (limited to 'test')
| -rw-r--r-- | test/mitmproxy/builtins/test_script.py | 13 | ||||
| -rw-r--r-- | test/mitmproxy/data/addonscripts/addon.py | 22 |
2 files changed, 35 insertions, 0 deletions
diff --git a/test/mitmproxy/builtins/test_script.py b/test/mitmproxy/builtins/test_script.py index 1658088c..3f07b576 100644 --- a/test/mitmproxy/builtins/test_script.py +++ b/test/mitmproxy/builtins/test_script.py @@ -116,6 +116,19 @@ class TestScript(mastertest.MasterTest): assert not fm.state.view[0].request.is_replay assert fm.state.view[1].request.is_replay + def test_addon(self): + s = state.State() + m = master.FlowMaster(options.Options(), None, s) + sc = script.Script( + tutils.test_data.path( + "data/addonscripts/addon.py" + ) + ) + m.addons.add(sc) + assert sc.ns.event_log == [ + 'scriptstart', 'addonstart', 'addonconfigure' + ] + class TestScriptLoader(mastertest.MasterTest): def test_simple(self): diff --git a/test/mitmproxy/data/addonscripts/addon.py b/test/mitmproxy/data/addonscripts/addon.py new file mode 100644 index 00000000..3b09d231 --- /dev/null +++ b/test/mitmproxy/data/addonscripts/addon.py @@ -0,0 +1,22 @@ +event_log = [] + + +class Addon: + @property + def event_log(self): + return event_log + + def start(self): + event_log.append("addonstart") + + def configure(self, options): + event_log.append("addonconfigure") + + +def configure(options): + event_log.append("addonconfigure") + + +def start(): + event_log.append("scriptstart") + return Addon() |
