diff options
author | Aldo Cortesi <aldo@corte.si> | 2016-10-18 12:28:47 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-18 12:28:47 +1300 |
commit | faa26a5d6b952351749cbed4601f0376d6ab526d (patch) | |
tree | aa7acbba4e317a899c0d035023ebd3c250d73672 | |
parent | 323f04fbe119341ae9e097c41e0d049cd4fe58c9 (diff) | |
parent | 825b02d495ef762f22b44d48ed9d923f8c54220a (diff) | |
download | mitmproxy-faa26a5d6b952351749cbed4601f0376d6ab526d.tar.gz mitmproxy-faa26a5d6b952351749cbed4601f0376d6ab526d.tar.bz2 mitmproxy-faa26a5d6b952351749cbed4601f0376d6ab526d.zip |
Merge pull request #1625 from cortesi/dupflow
master.duplicate_flow -> state.duplicate_flow
-rw-r--r-- | mitmproxy/console/flowlist.py | 2 | ||||
-rw-r--r-- | mitmproxy/console/flowview.py | 2 | ||||
-rw-r--r-- | mitmproxy/flow/master.py | 9 | ||||
-rw-r--r-- | mitmproxy/flow/state.py | 9 | ||||
-rw-r--r-- | mitmproxy/web/app.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/data/addonscripts/duplicate_flow.py | 2 | ||||
-rw-r--r-- | test/mitmproxy/test_flow.py | 11 | ||||
-rw-r--r-- | test/mitmproxy/test_flow_state.py | 15 |
8 files changed, 28 insertions, 24 deletions
diff --git a/mitmproxy/console/flowlist.py b/mitmproxy/console/flowlist.py index ebba1ea4..653dfa02 100644 --- a/mitmproxy/console/flowlist.py +++ b/mitmproxy/console/flowlist.py @@ -166,7 +166,7 @@ class ConnectionItem(urwid.WidgetWrap): self.state.delete_flow(self.flow) signals.flowlist_change.send(self) elif key == "D": - f = self.master.duplicate_flow(self.flow) + f = self.master.state.duplicate_flow(self.flow) self.master.state.set_focus_flow(f) signals.flowlist_change.send(self) elif key == "m": diff --git a/mitmproxy/console/flowview.py b/mitmproxy/console/flowview.py index 4aa09bd9..0422e72b 100644 --- a/mitmproxy/console/flowview.py +++ b/mitmproxy/console/flowview.py @@ -536,7 +536,7 @@ class FlowView(tabs.Tabs): f.kill(self.master) self.state.delete_flow(f) elif key == "D": - f = self.master.duplicate_flow(self.flow) + f = self.master.state.duplicate_flow(self.flow) signals.pop_view_state.send(self) self.master.view_flow(f) signals.status_message.send(message="Duplicated.") diff --git a/mitmproxy/flow/master.py b/mitmproxy/flow/master.py index 02e5246f..3d57c7bd 100644 --- a/mitmproxy/flow/master.py +++ b/mitmproxy/flow/master.py @@ -57,15 +57,6 @@ class FlowMaster(controller.Master): def start_app(self, host, port): self.apps.add(app.mapp, host, port) - def duplicate_flow(self, f): - """ - Duplicate flow, and insert it into state without triggering any of - the normal flow events. - """ - f2 = f.copy() - self.state.add_flow(f2) - return f2 - def create_request(self, method, scheme, host, port, path): """ this method creates a new artificial and minimalist request also adds it to flowlist diff --git a/mitmproxy/flow/state.py b/mitmproxy/flow/state.py index cb01f6fe..8c8e75c7 100644 --- a/mitmproxy/flow/state.py +++ b/mitmproxy/flow/state.py @@ -261,6 +261,15 @@ class State: def killall(self, master): self.flows.kill_all(master) + def duplicate_flow(self, f): + """ + Duplicate flow, and insert it into state without triggering any of + the normal flow events. + """ + f2 = f.copy() + self.add_flow(f2) + return f2 + class DummyState: flows = () diff --git a/mitmproxy/web/app.py b/mitmproxy/web/app.py index 1aab8e8c..46bdd9e3 100644 --- a/mitmproxy/web/app.py +++ b/mitmproxy/web/app.py @@ -275,7 +275,7 @@ class FlowHandler(RequestHandler): class DuplicateFlow(RequestHandler): def post(self, flow_id): - self.master.duplicate_flow(self.flow) + self.master.state.duplicate_flow(self.flow) class RevertFlow(RequestHandler): diff --git a/test/mitmproxy/data/addonscripts/duplicate_flow.py b/test/mitmproxy/data/addonscripts/duplicate_flow.py index b466423c..02fb8dce 100644 --- a/test/mitmproxy/data/addonscripts/duplicate_flow.py +++ b/test/mitmproxy/data/addonscripts/duplicate_flow.py @@ -2,5 +2,5 @@ from mitmproxy import ctx def request(flow): - f = ctx.master.duplicate_flow(flow) + f = ctx.master.state.duplicate_flow(flow) ctx.master.replay_request(f, block=True) diff --git a/test/mitmproxy/test_flow.py b/test/mitmproxy/test_flow.py index 38d61afe..90b9b61d 100644 --- a/test/mitmproxy/test_flow.py +++ b/test/mitmproxy/test_flow.py @@ -452,17 +452,6 @@ class TestFlowMaster: f.live = True tutils.raises("live", fm.replay_request, f) - def test_duplicate_flow(self): - s = flow.State() - fm = flow.FlowMaster(None, None, s) - f = tutils.tflow(resp=True) - fm.load_flow(f) - assert s.flow_count() == 1 - f2 = fm.duplicate_flow(f) - assert f2.response - assert s.flow_count() == 2 - assert s.index(f2) == 1 - def test_create_flow(self): s = flow.State() fm = flow.FlowMaster(None, None, s) diff --git a/test/mitmproxy/test_flow_state.py b/test/mitmproxy/test_flow_state.py new file mode 100644 index 00000000..cc05537d --- /dev/null +++ b/test/mitmproxy/test_flow_state.py @@ -0,0 +1,15 @@ +from mitmproxy import flow +from . import tutils + + +class TestState: + def test_duplicate_flow(self): + s = flow.State() + fm = flow.FlowMaster(None, None, s) + f = tutils.tflow(resp=True) + fm.load_flow(f) + assert s.flow_count() == 1 + f2 = fm.state.duplicate_flow(f) + assert f2.response + assert s.flow_count() == 2 + assert s.index(f2) == 1 |