adjust tests, fix option handling

This commit is contained in:
Maximilian Hils 2014-03-13 01:22:12 +01:00
parent 4d9799f103
commit 1bfc164692
5 changed files with 11 additions and 17 deletions

View File

@ -161,7 +161,6 @@ def get_common_options(options):
anticache = options.anticache, anticache = options.anticache,
anticomp = options.anticomp, anticomp = options.anticomp,
client_replay = options.client_replay, client_replay = options.client_replay,
flow_detail = options.flow_detail,
kill = options.kill, kill = options.kill,
no_server = options.no_server, no_server = options.no_server,
refresh_server_playback = not options.norefresh, refresh_server_playback = not options.norefresh,

View File

@ -67,6 +67,6 @@ class AddressPriority(object):
class Log: class Log:
def __init__(self, msg, level): def __init__(self, msg, level="info"):
self.msg = msg self.msg = msg
self.level = level self.level = level

View File

@ -44,11 +44,8 @@ if __name__ == '__main__':
print >> sys.stderr, "mitmdump:", v.args[0] print >> sys.stderr, "mitmdump:", v.args[0]
sys.exit(1) sys.exit(1)
dumpopts = dump.Options(**cmdline.get_common_options(options))
try: dumpopts.flow_detail = options.flow_detail,
dumpopts = dump.Options(**cmdline.get_common_options(options))
except cmdline.OptionException, v:
parser.error(v.message)
dumpopts.keepserving = options.keepserving dumpopts.keepserving = options.keepserving
if options.args: if options.args:

View File

@ -52,10 +52,8 @@ if __name__ == '__main__':
print >> sys.stderr, "mitmproxy:", v.args[0] print >> sys.stderr, "mitmproxy:", v.args[0]
sys.exit(1) sys.exit(1)
try: opts = console.Options(**cmdline.get_common_options(options))
opts = console.Options(**cmdline.get_common_options(options)) opts.eventlog = options.eventlog
except cmdline.OptionException, v:
parser.error(v.message)
opts.intercept = options.intercept opts.intercept = options.intercept
opts.debug = options.debug opts.debug = options.debug
opts.palette = options.palette opts.palette = options.palette

View File

@ -56,7 +56,7 @@ class TestDumpMaster:
def test_error(self): def test_error(self):
cs = StringIO() cs = StringIO()
o = dump.Options(verbosity=1) o = dump.Options(flow_detail=1)
m = dump.DumpMaster(None, o, None, outfile=cs) m = dump.DumpMaster(None, o, None, outfile=cs)
f = tutils.tflow_err() f = tutils.tflow_err()
m.handle_request(f.request) m.handle_request(f.request)
@ -90,7 +90,7 @@ class TestDumpMaster:
with tutils.tmpdir() as t: with tutils.tmpdir() as t:
p = os.path.join(t, "read") p = os.path.join(t, "read")
self._flowfile(p) 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( tutils.raises(
dump.DumpError, self._dummy_cycle, dump.DumpError, self._dummy_cycle,
@ -127,9 +127,9 @@ class TestDumpMaster:
def test_basic(self): def test_basic(self):
for i in (1, 2, 3): for i in (1, 2, 3):
assert "GET" in self._dummy_cycle(1, "~s", "", verbosity=i) assert "GET" in self._dummy_cycle(1, "~s", "", flow_detail=i)
assert "GET" in self._dummy_cycle(1, "~s", "\x00\x00\x00", verbosity=i) assert "GET" in self._dummy_cycle(1, "~s", "\x00\x00\x00", flow_detail=i)
assert "GET" in self._dummy_cycle(1, "~s", "ascii", verbosity=i) assert "GET" in self._dummy_cycle(1, "~s", "ascii", flow_detail=i)
def test_write(self): def test_write(self):
with tutils.tmpdir() as d: with tutils.tmpdir() as d:
@ -150,7 +150,7 @@ class TestDumpMaster:
def test_script(self): def test_script(self):
ret = self._dummy_cycle( ret = self._dummy_cycle(
1, None, "", 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 "XCLIENTCONNECT" in ret
assert "XSERVERCONNECT" in ret assert "XSERVERCONNECT" in ret