Bump unit tests, rearrange mitmdump command-line options slightly.
This commit is contained in:
parent
4f02480482
commit
42ffded626
|
@ -53,6 +53,7 @@ class ClientPlaybackState:
|
|||
"""
|
||||
if self.flows and not self.current:
|
||||
n = self.flows.pop(0)
|
||||
n.request.client_conn = None
|
||||
self.current = master.handle_request(n.request)
|
||||
if not testing and not self.current.response:
|
||||
#begin nocover
|
||||
|
|
11
mitmdump
11
mitmdump
|
@ -28,7 +28,6 @@ if __name__ == '__main__':
|
|||
usage = "%prog [options] [filter]",
|
||||
version="%%prog %s"%VERSION,
|
||||
)
|
||||
proxy.certificate_option_group(parser)
|
||||
parser.add_option(
|
||||
"-p", action="store",
|
||||
type = "int", dest="port", default=8080,
|
||||
|
@ -56,6 +55,10 @@ if __name__ == '__main__':
|
|||
action="store", dest="wfile", default=None,
|
||||
help="Write flows to file.")
|
||||
|
||||
group = OptionGroup(parser, "Client Replay")
|
||||
group.add_option("-c", action="store", dest="client_replay", default=None, metavar="PATH",
|
||||
help="Replay client requests from a saved file.")
|
||||
parser.add_option_group(group)
|
||||
|
||||
group = OptionGroup(parser, "Server Replay")
|
||||
group.add_option("-s", action="store", dest="server_replay", default=None, metavar="PATH",
|
||||
|
@ -69,11 +72,7 @@ if __name__ == '__main__':
|
|||
"Can be passed multiple times.")
|
||||
parser.add_option_group(group)
|
||||
|
||||
|
||||
group = OptionGroup(parser, "Client Replay")
|
||||
group.add_option("-c", action="store", dest="client_replay", default=None, metavar="PATH",
|
||||
help="Replay client requests from a saved file.")
|
||||
parser.add_option_group(group)
|
||||
proxy.certificate_option_group(parser)
|
||||
|
||||
|
||||
options, args = parser.parse_args()
|
||||
|
|
|
@ -11,8 +11,10 @@ class uStrFuncs(libpry.AutoTree):
|
|||
dump.str_response(t)
|
||||
|
||||
t = tutils.treq()
|
||||
t.client_conn = None
|
||||
t.stickycookie = True
|
||||
assert "stickycookie" in dump.str_request(t)
|
||||
assert "replay" in dump.str_request(t)
|
||||
|
||||
|
||||
class uDumpMaster(libpry.AutoTree):
|
||||
|
@ -58,6 +60,9 @@ class uDumpMaster(libpry.AutoTree):
|
|||
m = dump.DumpMaster(None, o, None, outfile=cs)
|
||||
self._cycle(m, "nonexistent")
|
||||
|
||||
o = dump.Options(client_replay=p, kill=False)
|
||||
m = dump.DumpMaster(None, o, None, outfile=cs)
|
||||
|
||||
def test_options(self):
|
||||
o = dump.Options(verbosity = 2)
|
||||
assert o.verbosity == 2
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import Queue
|
||||
from cStringIO import StringIO
|
||||
from libmproxy import console, proxy, filt, flow
|
||||
import tutils
|
||||
|
@ -375,6 +376,23 @@ class uFlowMaster(libpry.AutoTree):
|
|||
err = proxy.Error(f.request, "msg")
|
||||
fm.handle_error(err)
|
||||
|
||||
def test_client_playback(self):
|
||||
s = flow.State()
|
||||
|
||||
f = tutils.tflow_full()
|
||||
pb = [tutils.tflow_full(), f]
|
||||
fm = flow.FlowMaster(None, s)
|
||||
assert not fm.start_server_playback(pb, False, [])
|
||||
assert not fm.start_client_playback(pb)
|
||||
|
||||
q = Queue.Queue()
|
||||
assert not fm.state.flow_map
|
||||
fm.tick(q)
|
||||
assert fm.state.flow_map
|
||||
|
||||
fm.handle_error(proxy.Error(f.request, "error"))
|
||||
|
||||
|
||||
def test_server_playback(self):
|
||||
s = flow.State()
|
||||
|
||||
|
@ -393,12 +411,6 @@ class uFlowMaster(libpry.AutoTree):
|
|||
r.request.content = "gibble"
|
||||
assert not fm.do_server_playback(r)
|
||||
|
||||
def test_client_playback(self):
|
||||
s = flow.State()
|
||||
fm = flow.FlowMaster(None, s)
|
||||
pb = [tutils.tflow_full()]
|
||||
fm.start_client_playback(pb)
|
||||
|
||||
def test_stickycookie(self):
|
||||
s = flow.State()
|
||||
fm = flow.FlowMaster(None, s)
|
||||
|
|
Loading…
Reference in New Issue