diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/scripts/a | 8 | ||||
-rwxr-xr-x | test/scripts/err_data | 2 | ||||
-rwxr-xr-x | test/scripts/err_return | 5 | ||||
-rw-r--r-- | test/scripts/nonexecutable | 0 | ||||
-rw-r--r-- | test/test_flow.py | 16 |
5 files changed, 31 insertions, 0 deletions
diff --git a/test/scripts/a b/test/scripts/a new file mode 100755 index 00000000..6973a44f --- /dev/null +++ b/test/scripts/a @@ -0,0 +1,8 @@ +#!/usr/bin/env python +import sys +sys.path.insert(0, "..") +from libmproxy import script + +f = script.load_flow() +f.request.host = "TESTOK" +script.return_flow(f) diff --git a/test/scripts/err_data b/test/scripts/err_data new file mode 100755 index 00000000..4bb1b1ba --- /dev/null +++ b/test/scripts/err_data @@ -0,0 +1,2 @@ +#!/usr/bin/env python +print "NONSENSE" diff --git a/test/scripts/err_return b/test/scripts/err_return new file mode 100755 index 00000000..a45926b5 --- /dev/null +++ b/test/scripts/err_return @@ -0,0 +1,5 @@ +#!/usr/bin/env python +import sys +sys.path.insert(0, "..") +sys.exit(1) + diff --git a/test/scripts/nonexecutable b/test/scripts/nonexecutable new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/scripts/nonexecutable 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() |