aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-11-03 12:44:19 +1300
committerAldo Cortesi <aldo@nullcube.com>2016-11-03 12:44:19 +1300
commitfbdce4b629fe0e626818aafe81dc247f746d70cd (patch)
treef62b84d064924cb36c4872d0c69c6b8f4a8931f2 /test
parent5109fd8ecb3e2b6b5c15ab07fc98d354c240b842 (diff)
downloadmitmproxy-fbdce4b629fe0e626818aafe81dc247f746d70cd.tar.gz
mitmproxy-fbdce4b629fe0e626818aafe81dc247f746d70cd.tar.bz2
mitmproxy-fbdce4b629fe0e626818aafe81dc247f746d70cd.zip
addons filstreamer: tests and bugfixes
- Move tests to taddons - Fix a bug where options updates caused streaming to halt
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_filestreamer.py38
1 files changed, 13 insertions, 25 deletions
diff --git a/test/mitmproxy/addons/test_filestreamer.py b/test/mitmproxy/addons/test_filestreamer.py
index 28094c43..f86912fc 100644
--- a/test/mitmproxy/addons/test_filestreamer.py
+++ b/test/mitmproxy/addons/test_filestreamer.py
@@ -1,44 +1,32 @@
from mitmproxy.test import tflow
from mitmproxy.test import tutils
-
-from .. import mastertest
+from mitmproxy.test import taddons
import os.path
-
from mitmproxy.addons import filestreamer
-from mitmproxy import master
from mitmproxy import io
-from mitmproxy import options
-from mitmproxy import proxy
-class TestStream(mastertest.MasterTest):
- def test_stream(self):
+def test_stream():
+ sa = filestreamer.FileStreamer()
+ with taddons.context() as tctx:
with tutils.tmpdir() as tdir:
p = os.path.join(tdir, "foo")
def r():
- r = io.FlowReader(open(p, "rb"))
- return list(r.stream())
+ x = io.FlowReader(open(p, "rb"))
+ return list(x.stream())
- o = options.Options(
- outfile = (p, "wb")
- )
- m = master.Master(o, proxy.DummyServer())
- sa = filestreamer.FileStreamer()
+ tctx.configure(sa, outfile=(p, "wb"))
- m.addons.add(sa)
f = tflow.tflow(resp=True)
- m.request(f)
- m.response(f)
- m.addons.remove(sa)
-
+ sa.request(f)
+ sa.response(f)
+ tctx.configure(sa, outfile=None)
assert r()[0].response
- m.options.outfile = (p, "ab")
-
- m.addons.add(sa)
+ tctx.configure(sa, outfile=(p, "ab"))
f = tflow.tflow()
- m.request(f)
- m.addons.remove(sa)
+ sa.request(f)
+ tctx.configure(sa, outfile=None)
assert not r()[1].response