aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2017-03-06 20:58:51 +1300
committerAldo Cortesi <aldo@nullcube.com>2017-03-06 20:58:51 +1300
commitedfd62e42af921d0031ff95b7cf41ab1b6608a47 (patch)
tree014725daf8c9e648fa37d6588da2c8bc3e8a1144 /test
parent82163a1e680d608cdf2fb33f30dfcc6e142547a7 (diff)
downloadmitmproxy-edfd62e42af921d0031ff95b7cf41ab1b6608a47.tar.gz
mitmproxy-edfd62e42af921d0031ff95b7cf41ab1b6608a47.tar.bz2
mitmproxy-edfd62e42af921d0031ff95b7cf41ab1b6608a47.zip
Replacements and setheaders are always strings
Instead of having two representations we have one canonical specification. Fixing the editor in console is left ot a further patch.
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_replace.py24
-rw-r--r--test/mitmproxy/addons/test_setheaders.py14
2 files changed, 19 insertions, 19 deletions
diff --git a/test/mitmproxy/addons/test_replace.py b/test/mitmproxy/addons/test_replace.py
index 126c6e3d..8c280c51 100644
--- a/test/mitmproxy/addons/test_replace.py
+++ b/test/mitmproxy/addons/test_replace.py
@@ -22,11 +22,11 @@ class TestReplace:
def test_configure(self):
r = replace.Replace()
with taddons.context() as tctx:
- tctx.configure(r, replacements=[("one", "two", "three")])
+ tctx.configure(r, replacements=["one/two/three"])
with pytest.raises(Exception, match="Invalid filter pattern"):
- tctx.configure(r, replacements=[("~b", "two", "three")])
+ tctx.configure(r, replacements=["/~b/two/three"])
with pytest.raises(Exception, match="Invalid regular expression"):
- tctx.configure(r, replacements=[("foo", "+", "three")])
+ tctx.configure(r, replacements=["/foo/+/three"])
tctx.configure(r, replacements=["/a/b/c/"])
def test_simple(self):
@@ -35,8 +35,8 @@ class TestReplace:
tctx.configure(
r,
replacements = [
- ("~q", "foo", "bar"),
- ("~s", "foo", "bar"),
+ "/~q/foo/bar",
+ "/~s/foo/bar",
]
)
f = tflow.tflow()
@@ -58,10 +58,10 @@ class TestUpstreamProxy(tservers.HTTPUpstreamProxyTest):
self.proxy.tmaster.addons.add(sa)
self.proxy.tmaster.options.replacements = [
- ("~q", "foo", "bar"),
- ("~q", "bar", "baz"),
- ("~q", "foo", "oh noes!"),
- ("~s", "baz", "ORLY")
+ "/~q/foo/bar",
+ "/~q/bar/baz",
+ "/~q/foo/oh noes!",
+ "/~s/baz/ORLY"
]
p = self.pathoc()
with p.connect():
@@ -81,9 +81,9 @@ class TestReplaceFile:
tctx.configure(
r,
replacement_files = [
- ("~q", "foo", rp),
- ("~s", "foo", rp),
- ("~b nonexistent", "nonexistent", "nonexistent"),
+ "/~q/foo/" + rp,
+ "/~s/foo/" + rp,
+ "/~b nonexistent/nonexistent/nonexistent",
]
)
f = tflow.tflow()
diff --git a/test/mitmproxy/addons/test_setheaders.py b/test/mitmproxy/addons/test_setheaders.py
index 6355f2be..3aaee7f4 100644
--- a/test/mitmproxy/addons/test_setheaders.py
+++ b/test/mitmproxy/addons/test_setheaders.py
@@ -21,7 +21,7 @@ class TestSetHeaders:
sh = setheaders.SetHeaders()
with taddons.context() as tctx:
with pytest.raises(Exception, match="Invalid setheader filter pattern"):
- tctx.configure(sh, setheaders = [("~b", "one", "two")])
+ tctx.configure(sh, setheaders = ["/~b/one/two"])
tctx.configure(sh, setheaders = ["/foo/bar/voing"])
def test_setheaders(self):
@@ -30,8 +30,8 @@ class TestSetHeaders:
tctx.configure(
sh,
setheaders = [
- ("~q", "one", "two"),
- ("~s", "one", "three")
+ "/~q/one/two",
+ "/~s/one/three"
]
)
f = tflow.tflow()
@@ -47,8 +47,8 @@ class TestSetHeaders:
tctx.configure(
sh,
setheaders = [
- ("~s", "one", "two"),
- ("~s", "one", "three")
+ "/~s/one/two",
+ "/~s/one/three"
]
)
f = tflow.tflow(resp=True)
@@ -60,8 +60,8 @@ class TestSetHeaders:
tctx.configure(
sh,
setheaders = [
- ("~q", "one", "two"),
- ("~q", "one", "three")
+ "/~q/one/two",
+ "/~q/one/three"
]
)
f = tflow.tflow()