diff options
| author | Shadab Zafar <dufferzafar0@gmail.com> | 2016-03-07 09:28:09 +0530 |
|---|---|---|
| committer | Shadab Zafar <dufferzafar0@gmail.com> | 2016-03-11 17:57:57 +0530 |
| commit | 5eca2223d538752721ead11c63118df7689bb52d (patch) | |
| tree | 5c64095d2612752b415174caef0d862b66fa2c7c | |
| parent | c378fe21996d2f5dd4ac435f4c765e336d4c656d (diff) | |
| download | mitmproxy-5eca2223d538752721ead11c63118df7689bb52d.tar.gz mitmproxy-5eca2223d538752721ead11c63118df7689bb52d.tar.bz2 mitmproxy-5eca2223d538752721ead11c63118df7689bb52d.zip | |
Add tests for modify_response_body example
| -rw-r--r-- | test/mitmproxy/test_examples.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py index 88bd90bf..c7fa90c8 100644 --- a/test/mitmproxy/test_examples.py +++ b/test/mitmproxy/test_examples.py @@ -10,9 +10,14 @@ from examples import ( add_header, modify_form, modify_querystring, + modify_response_body, ) +class DummyContext(object): + pass + + def test_load_scripts(): example_dir = utils.Data(__name__).path("../../examples") scripts = glob.glob("%s/*.py" % example_dir) @@ -57,3 +62,14 @@ def test_modify_querystring(): modify_querystring.request({}, flow) assert flow.request.query["mitmproxy"] == ["rocks"] + +def test_modify_response_body(): + ctx = DummyContext() + tutils.raises(ValueError, modify_response_body.start, ctx, []) + + modify_response_body.start(ctx, ["modify-response-body.py", "mitmproxy", "rocks"]) + assert ctx.old == "mitmproxy" and ctx.new == "rocks" + + flow = tutils.tflow(resp=netutils.tresp(content="I <3 mitmproxy")) + modify_response_body.response(ctx, flow) + assert flow.response.content == "I <3 rocks"
\ No newline at end of file |
