From aab45078adfdf143722aa021c7d7ad1b2eb61ed3 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 9 Jul 2012 11:03:55 +1200 Subject: [PATCH] Unit test request replay thread. This is a small patch, but is the culmination of lots of work: we can now unit test the deep innards of mitmproxy, with coverage. There's a lot more to come in this vein. --- libmproxy/flow.py | 1 + test/test_server.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 17e88bc11..53644fb1e 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -1382,6 +1382,7 @@ class FlowMaster(controller.Master): self.masterq, ) rt.start() # pragma: no cover + return rt def run_script_hook(self, name, *args, **kwargs): if self.script and not self.pause_scripts: diff --git a/test/test_server.py b/test/test_server.py index 87996c43b..a500d81cd 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -20,6 +20,16 @@ class SanityMixin: def test_large(self): assert len(self.pathod("200:b@50k").content) == 1024*50 + def test_replay(self): + assert self.pathod("304").status_code == 304 + assert len(self.master.state.view) == 1 + l = self.master.state.view[0] + assert l.response.code == 304 + l.request.path = "/p/305" + rt = self.master.replay_request(l) + rt.join() + assert l.response.code == 305 + class TestHTTP(tutils.HTTPProxTest, SanityMixin): def test_invalid_http(self):