mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Add tests for modify_response_body example
This commit is contained in:
parent
c378fe2199
commit
5eca2223d5
@ -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"
|
Loading…
Reference in New Issue
Block a user