def test_getset_state(self): f = tutils.tflow(resp=True) state = f.get_state() assert f.get_state() == HTTPFlow.from_state(state).get_state() f.response = None f.error = Error("error") state = f.get_state() assert f.get_state() == HTTPFlow.from_state(state).get_state() f2 = f.copy() f2.id = f.id # copy creates a different uuid assert f.get_state() == f2.get_state() assert not f == f2 f2.error = Error("e2") assert not f == f2 f.set_state(f2.get_state()) assert f.get_state() == f2.get_state()
def test_getset_state(self): f = tutils.tflow(resp=True) state = f.get_state() assert f.get_state() == HTTPFlow.from_state( state).get_state() f.response = None f.error = Error("error") state = f.get_state() assert f.get_state() == HTTPFlow.from_state( state).get_state() f2 = f.copy() f2.id = f.id # copy creates a different uuid assert f.get_state() == f2.get_state() assert not f == f2 f2.error = Error("e2") assert not f == f2 f.set_state(f2.get_state()) assert f.get_state() == f2.get_state()
def tflow(client_conn=True, server_conn=True, req=True, resp=None, err=None): """ @type client_conn: bool | None | mitmproxy.proxy.connection.ClientConnection @type server_conn: bool | None | mitmproxy.proxy.connection.ServerConnection @type req: bool | None | mitmproxy.protocol.http.HTTPRequest @type resp: bool | None | mitmproxy.protocol.http.HTTPResponse @type err: bool | None | mitmproxy.protocol.primitives.Error @return: mitmproxy.protocol.http.HTTPFlow """ if client_conn is True: client_conn = tclient_conn() if server_conn is True: server_conn = tserver_conn() if req is True: req = netlib.tutils.treq() if resp is True: resp = netlib.tutils.tresp() if err is True: err = terr() if req: req = HTTPRequest.wrap(req) if resp: resp = HTTPResponse.wrap(resp) f = HTTPFlow(client_conn, server_conn) f.request = req f.response = resp f.error = err f.reply = controller.DummyReply() return f