aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_utils.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-07-22 17:48:42 +1200
committerAldo Cortesi <aldo@nullcube.com>2011-07-22 17:48:42 +1200
commit1b961fc4adb2ef623747102b1539aa4d46c6e743 (patch)
tree941bda1de0d524508a2bc9bfea711ecee15e84f3 /test/test_utils.py
parent9c24401b187fa2915d8b6cc424fc25f5e51369c8 (diff)
downloadmitmproxy-1b961fc4adb2ef623747102b1539aa4d46c6e743.tar.gz
mitmproxy-1b961fc4adb2ef623747102b1539aa4d46c6e743.tar.bz2
mitmproxy-1b961fc4adb2ef623747102b1539aa4d46c6e743.zip
Add utility functions to search and replace strings in flows
This is a common task in pentesting scenarios. This commit adds the following functions: utils.Headers.replace proxy.Request.replace proxy.Response.replace flow.Flow.replace
Diffstat (limited to 'test/test_utils.py')
-rw-r--r--test/test_utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index 2ff951d4..e22ec039 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -137,6 +137,15 @@ class uHeaders(libpry.AutoTree):
del self.hd["foo"]
assert len(self.hd.lst) == 1
+ def test_replace(self):
+ self.hd.add("one", "two")
+ self.hd.add("two", "one")
+ assert self.hd.replace("one", "vun") == 2
+ assert self.hd.lst == [
+ ["vun", "two"],
+ ["two", "vun"],
+ ]
+
class uisStringLike(libpry.AutoTree):
def test_all(self):