mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-04 01:05:36 +00:00
Merge pull request #1625 from cortesi/dupflow
master.duplicate_flow -> state.duplicate_flow
This commit is contained in:
commit
faa26a5d6b
@ -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":
|
||||
|
@ -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.")
|
||||
|
@ -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
|
||||
|
@ -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 = ()
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
15
test/mitmproxy/test_flow_state.py
Normal file
15
test/mitmproxy/test_flow_state.py
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user