mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
adjust tests, fix option handling
This commit is contained in:
parent
4d9799f103
commit
1bfc164692
@ -161,7 +161,6 @@ def get_common_options(options):
|
||||
anticache = options.anticache,
|
||||
anticomp = options.anticomp,
|
||||
client_replay = options.client_replay,
|
||||
flow_detail = options.flow_detail,
|
||||
kill = options.kill,
|
||||
no_server = options.no_server,
|
||||
refresh_server_playback = not options.norefresh,
|
||||
|
@ -67,6 +67,6 @@ class AddressPriority(object):
|
||||
|
||||
|
||||
class Log:
|
||||
def __init__(self, msg, level):
|
||||
def __init__(self, msg, level="info"):
|
||||
self.msg = msg
|
||||
self.level = level
|
7
mitmdump
7
mitmdump
@ -44,11 +44,8 @@ if __name__ == '__main__':
|
||||
print >> sys.stderr, "mitmdump:", v.args[0]
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
try:
|
||||
dumpopts = dump.Options(**cmdline.get_common_options(options))
|
||||
except cmdline.OptionException, v:
|
||||
parser.error(v.message)
|
||||
dumpopts = dump.Options(**cmdline.get_common_options(options))
|
||||
dumpopts.flow_detail = options.flow_detail,
|
||||
dumpopts.keepserving = options.keepserving
|
||||
|
||||
if options.args:
|
||||
|
@ -52,10 +52,8 @@ if __name__ == '__main__':
|
||||
print >> sys.stderr, "mitmproxy:", v.args[0]
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
opts = console.Options(**cmdline.get_common_options(options))
|
||||
except cmdline.OptionException, v:
|
||||
parser.error(v.message)
|
||||
opts = console.Options(**cmdline.get_common_options(options))
|
||||
opts.eventlog = options.eventlog
|
||||
opts.intercept = options.intercept
|
||||
opts.debug = options.debug
|
||||
opts.palette = options.palette
|
||||
|
@ -56,7 +56,7 @@ class TestDumpMaster:
|
||||
|
||||
def test_error(self):
|
||||
cs = StringIO()
|
||||
o = dump.Options(verbosity=1)
|
||||
o = dump.Options(flow_detail=1)
|
||||
m = dump.DumpMaster(None, o, None, outfile=cs)
|
||||
f = tutils.tflow_err()
|
||||
m.handle_request(f.request)
|
||||
@ -90,7 +90,7 @@ class TestDumpMaster:
|
||||
with tutils.tmpdir() as t:
|
||||
p = os.path.join(t, "read")
|
||||
self._flowfile(p)
|
||||
assert "GET" in self._dummy_cycle(0, None, "", verbosity=1, rfile=p)
|
||||
assert "GET" in self._dummy_cycle(0, None, "", flow_detail=1, rfile=p)
|
||||
|
||||
tutils.raises(
|
||||
dump.DumpError, self._dummy_cycle,
|
||||
@ -127,9 +127,9 @@ class TestDumpMaster:
|
||||
|
||||
def test_basic(self):
|
||||
for i in (1, 2, 3):
|
||||
assert "GET" in self._dummy_cycle(1, "~s", "", verbosity=i)
|
||||
assert "GET" in self._dummy_cycle(1, "~s", "\x00\x00\x00", verbosity=i)
|
||||
assert "GET" in self._dummy_cycle(1, "~s", "ascii", verbosity=i)
|
||||
assert "GET" in self._dummy_cycle(1, "~s", "", flow_detail=i)
|
||||
assert "GET" in self._dummy_cycle(1, "~s", "\x00\x00\x00", flow_detail=i)
|
||||
assert "GET" in self._dummy_cycle(1, "~s", "ascii", flow_detail=i)
|
||||
|
||||
def test_write(self):
|
||||
with tutils.tmpdir() as d:
|
||||
@ -150,7 +150,7 @@ class TestDumpMaster:
|
||||
def test_script(self):
|
||||
ret = self._dummy_cycle(
|
||||
1, None, "",
|
||||
scripts=[tutils.test_data.path("scripts/all.py")], verbosity=0
|
||||
scripts=[tutils.test_data.path("scripts/all.py")], verbosity=1
|
||||
)
|
||||
assert "XCLIENTCONNECT" in ret
|
||||
assert "XSERVERCONNECT" in ret
|
||||
|
Loading…
Reference in New Issue
Block a user