add regression test for #1605

This commit is contained in:
Maximilian Hils 2016-10-14 01:22:30 -07:00
parent 5fab94580e
commit e9284ab7ee
1 changed files with 13 additions and 0 deletions

View File

@ -122,3 +122,16 @@ class TestMaster(mastertest.MasterTest):
for i in (1, 2, 3):
self.dummy_cycle(m, 1, b"")
assert len(m.state.flows) == i
def test_intercept(self):
"""regression test for https://github.com/mitmproxy/mitmproxy/issues/1605"""
m = self.mkmaster(intercept="~b bar")
f = tutils.tflow(req=netlib.tutils.treq(content=b"foo"))
m.request(f)
assert not m.state.flows[0].intercepted
f = tutils.tflow(req=netlib.tutils.treq(content=b"bar"))
m.request(f)
assert m.state.flows[1].intercepted
f = tutils.tflow(resp=netlib.tutils.tresp(content=b"bar"))
m.request(f)
assert m.state.flows[2].intercepted