From 8a07059cf43104636f8f6c6f52854da66a9b9ea8 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 28 Apr 2017 10:41:44 +1200 Subject: commands: add the core command addon, and the command "set" The set command sets an option using the same syntax as commandline --set. --- test/mitmproxy/addons/test_core.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/mitmproxy/addons/test_core.py (limited to 'test') diff --git a/test/mitmproxy/addons/test_core.py b/test/mitmproxy/addons/test_core.py new file mode 100644 index 00000000..99bf3f40 --- /dev/null +++ b/test/mitmproxy/addons/test_core.py @@ -0,0 +1,15 @@ +from mitmproxy.addons import core +from mitmproxy.test import taddons +from mitmproxy import exceptions +import pytest + + +def test_set(): + sa = core.Core() + with taddons.context() as tctx: + assert not tctx.master.options.anticomp + tctx.command(sa.set, "anticomp") + assert tctx.master.options.anticomp + + with pytest.raises(exceptions.CommandError): + tctx.command(sa.set, "nonexistent") -- cgit v1.2.3 From ce01cb9c097614c12113df15e1f35839c1926e4d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 28 Apr 2017 11:24:28 +1200 Subject: command: partials Support partial commands in console.command, use it to keybind "i" for intercept, which prompts the user with ":set intercept=". --- test/mitmproxy/addons/test_core.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test') diff --git a/test/mitmproxy/addons/test_core.py b/test/mitmproxy/addons/test_core.py index 99bf3f40..6ebf4ba9 100644 --- a/test/mitmproxy/addons/test_core.py +++ b/test/mitmproxy/addons/test_core.py @@ -7,6 +7,8 @@ import pytest def test_set(): sa = core.Core() with taddons.context() as tctx: + tctx.master.addons.add(sa) + assert not tctx.master.options.anticomp tctx.command(sa.set, "anticomp") assert tctx.master.options.anticomp -- cgit v1.2.3