diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2011-07-22 17:48:42 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2011-07-22 17:48:42 +1200 |
commit | 1b961fc4adb2ef623747102b1539aa4d46c6e743 (patch) | |
tree | 941bda1de0d524508a2bc9bfea711ecee15e84f3 /test/test_flow.py | |
parent | 9c24401b187fa2915d8b6cc424fc25f5e51369c8 (diff) | |
download | mitmproxy-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_flow.py')
-rw-r--r-- | test/test_flow.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/test_flow.py b/test/test_flow.py index 365b6c58..ba276248 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -219,6 +219,21 @@ class uFlow(libpry.AutoTree): f = flow.Flow(None) f.request = tutils.treq() + def test_replace(self): + f = tutils.tflow_full() + f.request.headers["foo"] = ["foo"] + f.request.content = "afoob" + + f.response.headers["foo"] = ["foo"] + f.response.content = "afoob" + + assert f.replace("foo", "bar") == 6 + + assert f.request.headers["bar"] == ["bar"] + assert f.request.content == "abarb" + assert f.response.headers["bar"] == ["bar"] + assert f.response.content == "abarb" + class uState(libpry.AutoTree): def test_backup(self): |