Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_statusbar(monkeypatch):
o = options.Options()
m = master.ConsoleMaster(o)
m.options.update(
setheaders=[":~q:foo:bar"],
replacements=[":~q:foo:bar"],
ignore_hosts=["example.com", "example.org"],
tcp_hosts=["example.tcp"],
intercept="~q",
view_filter="~dst example.com",
stickycookie="~dst example.com",
stickyauth="~dst example.com",
console_default_contentview="javascript",
anticache=True,
anticomp=True,
showhost=True,
server_replay_refresh=False,
server_replay_kill_extra=True,
def get_options(cls):
cls.cadir = os.path.join(tempfile.gettempdir(), "mitmproxy")
return options.Options(
listen_port=0,
cadir=cls.cadir,
add_upstream_certs_to_client_chain=cls.add_upstream_certs_to_client_chain,
ssl_insecure=True,
)
def test_mitmweb():
opts = options.Options()
web.master.WebMaster(opts)
ap = cmdline.mitmweb(opts)
assert ap
def mkmaster(self, flt, **opts):
o = options.Options(view_filter=flt, verbosity=-1, flow_detail=0, **opts)
m = dump.DumpMaster(o, proxy.DummyServer(), with_termlog=False, with_dumper=False)
return m
def test_shorten_message(message, ready_message):
o = options.Options()
m = master.ConsoleMaster(o)
ab = statusbar.ActionBar(m)
assert ab.shorten_message(message, max_width=30) == ready_message
def get_options(cls):
opts = options.Options(
listen_port=0,
upstream_cert=True,
ssl_insecure=True,
websocket=True,
)
opts.confdir = os.path.join(tempfile.gettempdir(), "mitmproxy")
return opts
def test_dump_dicts():
o = options.Options()
assert optmanager.dump_dicts(o)
assert optmanager.dump_dicts(o, ['http2', 'listen_port'])
def run_mitm(
master_cls: typing.Type[master.Master],
make_parser: typing.Callable[[options.Options], argparse.ArgumentParser],
arguments: typing.Sequence[str],
extra: typing.Callable[[typing.Any], dict] = None
) -> master.Master: # pragma: no cover
"""
extra: Extra argument processing callable which returns a dict of
options.
"""
debug.register_info_dumpers()
opts = options.Options()
master = master_cls(opts)
parser = make_parser(opts)
# To make migration from 2.x to 3.0 bearable.
if "-R" in sys.argv and sys.argv[sys.argv.index("-R") + 1].startswith("http"):
print("-R is used for specifying replacements.\n"
"To use mitmproxy in reverse mode please use --mode reverse:SPEC instead")
try:
args = parser.parse_args(arguments)
except SystemExit:
arg_check.check()
sys.exit(1)
try:
opts.confdir = args.confdir