aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_flow.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-01-31 13:26:56 +1300
committerAldo Cortesi <aldo@nullcube.com>2011-01-31 13:26:56 +1300
commitb886f808beaba097066a1b82fe560b1e70099df0 (patch)
treee1ca2132627d0e24d29a2223403a67e36d40c72a /test/test_flow.py
parentedb8228dd27c3050f45b536b761eab46672f8eb3 (diff)
downloadmitmproxy-b886f808beaba097066a1b82fe560b1e70099df0.tar.gz
mitmproxy-b886f808beaba097066a1b82fe560b1e70099df0.tar.bz2
mitmproxy-b886f808beaba097066a1b82fe560b1e70099df0.zip
Add an external script API.
External scripts can read a flow, modify it, and then return it to mitmproxy using a simple API. The "|" keyboard shortcut within mitmproxy prompts the user for a script.
Diffstat (limited to 'test/test_flow.py')
-rw-r--r--test/test_flow.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/test_flow.py b/test/test_flow.py
index 1867616e..c97cc030 100644
--- a/test/test_flow.py
+++ b/test/test_flow.py
@@ -3,6 +3,22 @@ import utils
import libpry
class uFlow(libpry.AutoTree):
+ def test_run_script(self):
+ f = utils.tflow()
+ f.response = utils.tresp()
+ f.request = f.response.request
+ f = f.run_script("scripts/a")
+ assert f.request.host == "TESTOK"
+
+ def test_run_script_err(self):
+ f = utils.tflow()
+ f.response = utils.tresp()
+ f.request = f.response.request
+ libpry.raises("returned error", f.run_script,"scripts/err_return")
+ libpry.raises("invalid response", f.run_script,"scripts/err_data")
+ libpry.raises("no such file", f.run_script,"nonexistent")
+ libpry.raises("permission denied", f.run_script,"scripts/nonexecutable")
+
def test_match(self):
f = utils.tflow()
f.response = utils.tresp()