aboutsummaryrefslogtreecommitdiffstats
path: root/test/mitmproxy/addons/test_core.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2017-05-01 18:29:44 +1200
committerGitHub <noreply@github.com>2017-05-01 18:29:44 +1200
commit06c99bffc39383a4197ba87ba9be7c7a24f64e45 (patch)
tree9d13e09204f6c6df3733b34cb6bd0dfa071ba8e6 /test/mitmproxy/addons/test_core.py
parent288448c5755e098a1f632b7ba13c0c62e0e8f0b7 (diff)
parent542a998174106e4ae88c70775bf1205d7bc36ddc (diff)
downloadmitmproxy-06c99bffc39383a4197ba87ba9be7c7a24f64e45.tar.gz
mitmproxy-06c99bffc39383a4197ba87ba9be7c7a24f64e45.tar.bz2
mitmproxy-06c99bffc39383a4197ba87ba9be7c7a24f64e45.zip
Merge pull request #2300 from cortesi/consolerevamp
Console revamp
Diffstat (limited to 'test/mitmproxy/addons/test_core.py')
-rw-r--r--test/mitmproxy/addons/test_core.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/mitmproxy/addons/test_core.py b/test/mitmproxy/addons/test_core.py
index 64d0fa19..302b78ae 100644
--- a/test/mitmproxy/addons/test_core.py
+++ b/test/mitmproxy/addons/test_core.py
@@ -61,3 +61,42 @@ def test_revert():
assert f.modified()
sa.revert([f])
assert not f.modified()
+
+
+def test_flow_set():
+ sa = core.Core()
+ with taddons.context():
+ f = tflow.tflow(resp=True)
+ assert sa.flow_set_options()
+
+ with pytest.raises(exceptions.CommandError):
+ sa.flow_set([f], "flibble", "post")
+
+ assert f.request.method != "post"
+ sa.flow_set([f], "method", "post")
+ assert f.request.method == "POST"
+
+ assert f.request.host != "testhost"
+ sa.flow_set([f], "host", "testhost")
+ assert f.request.host == "testhost"
+
+ assert f.request.path != "/test/path"
+ sa.flow_set([f], "path", "/test/path")
+ assert f.request.path == "/test/path"
+
+ assert f.request.url != "http://foo.com/bar"
+ sa.flow_set([f], "url", "http://foo.com/bar")
+ assert f.request.url == "http://foo.com/bar"
+ with pytest.raises(exceptions.CommandError):
+ sa.flow_set([f], "url", "oink")
+
+ assert f.response.status_code != 404
+ sa.flow_set([f], "status_code", "404")
+ assert f.response.status_code == 404
+ assert f.response.reason == "Not Found"
+ with pytest.raises(exceptions.CommandError):
+ sa.flow_set([f], "status_code", "oink")
+
+ assert f.response.reason != "foo"
+ sa.flow_set([f], "reason", "foo")
+ assert f.response.reason == "foo"