def p(self, *args): parser = MockParser() opts = options.Options() cmdline.common_options(parser, opts) args = parser.parse_args(args=args) pconf = main.process_options(parser, opts, args) return parser, pconf
def p(self, *args): parser = MockParser() cmdline.common_options(parser) args = parser.parse_args(args=args) opts = cmdline.get_common_options(args) pconf = config.ProxyConfig(options.Options(**opts)) return parser, pconf
def p(self, *args): parser = tutils.MockParser() cmdline.common_options(parser) args = parser.parse_args(args=args) opts = cmdline.get_common_options(args) pconf = config.ProxyConfig(options.Options(**opts)) return parser, pconf
def p(self, *args): parser = MockParser() cmdline.common_options(parser) args = parser.parse_args(args=args) opts = options.Options() opts.merge(cmdline.get_common_options(args)) pconf = config.ProxyConfig(opts) return parser, pconf
def test_common(): parser = argparse.ArgumentParser() cmdline.common_options(parser) opts = parser.parse_args(args=[]) assert cmdline.get_common_options(opts) opts.stickycookie_filt = "foo" opts.stickyauth_filt = "foo" v = cmdline.get_common_options(opts) assert v["stickycookie"] == "foo" assert v["stickyauth"] == "foo" opts.setheader = ["/foo/bar/voing"] v = cmdline.get_common_options(opts) assert v["setheaders"] == [("foo", "bar", "voing")] opts.setheader = ["//"] tutils.raises( "empty clause", cmdline.get_common_options, opts ) opts.setheader = [] opts.replace = ["/foo/bar/voing"] v = cmdline.get_common_options(opts) assert v["replacements"] == [("foo", "bar", "voing")] opts.replace = ["//"] tutils.raises( "empty clause", cmdline.get_common_options, opts ) opts.replace = [] opts.replace_file = [("/foo/bar/nonexistent")] tutils.raises( "could not read replace file", cmdline.get_common_options, opts ) opts.replace_file = [("/~/bar/nonexistent")] tutils.raises( "filter pattern", cmdline.get_common_options, opts ) p = tutils.test_data.path("mitmproxy/data/replace") opts.replace_file = [("/foo/bar/%s" % p)] v = cmdline.get_common_options(opts)["replacements"] assert len(v) == 1 assert v[0][2].strip() == b"replacecontents"
def test_common(): parser = argparse.ArgumentParser() cmdline.common_options(parser) opts = parser.parse_args(args=[]) assert cmdline.get_common_options(opts) opts.stickycookie_filt = "foo" opts.stickyauth_filt = "foo" v = cmdline.get_common_options(opts) assert v["stickycookie"] == "foo" assert v["stickyauth"] == "foo"
def test_common(): parser = argparse.ArgumentParser() cmdline.common_options(parser) opts = parser.parse_args(args=[]) assert cmdline.get_common_options(opts) opts.stickycookie_filt = "foo" opts.stickyauth_filt = "foo" v = cmdline.get_common_options(opts) assert v["stickycookie"] == "foo" assert v["stickyauth"] == "foo" opts.setheader = ["/foo/bar/voing"] v = cmdline.get_common_options(opts) assert v["setheaders"] == [("foo", "bar", "voing")] opts.setheader = ["//"] tutils.raises("empty clause", cmdline.get_common_options, opts) opts.setheader = [] opts.replace = ["/foo/bar/voing"] v = cmdline.get_common_options(opts) assert v["replacements"] == [("foo", "bar", "voing")] opts.replace = ["//"] tutils.raises("empty clause", cmdline.get_common_options, opts) opts.replace = [] opts.replace_file = [("/foo/bar/nonexistent")] tutils.raises("could not read replace file", cmdline.get_common_options, opts) opts.replace_file = [("/~/bar/nonexistent")] tutils.raises("filter pattern", cmdline.get_common_options, opts) p = tutils.test_data.path("data/replace") opts.replace_file = [("/foo/bar/%s" % p)] v = cmdline.get_common_options(opts)["replacements"] assert len(v) == 1 assert v[0][2].strip() == b"replacecontents"
def monitor(): parser = argparse.ArgumentParser(usage="%(prog)s [options]") group = parser.add_argument_group("Mitmmonitor") group.add_argument( "--no-browser", action="store_false", dest="monitor_open_browser", help="Don't start a browser", ) group.add_argument("--monitor-port", action="store", type=int, dest="monitor_port", metavar="PORT", help="Mitmweb port.") group.add_argument("--monitor-host", action="store", dest="monitor_host", metavar="HOST", help="Mitmmonitor host.") common_options(parser) return parser
def test_common(): parser = argparse.ArgumentParser() opts = options.Options() cmdline.common_options(parser, opts) args = parser.parse_args(args=[]) main.process_options(parser, opts, args)
def test_common(): parser = argparse.ArgumentParser() opts = options.Options() cmdline.common_options(parser, opts) args = parser.parse_args(args=[]) assert main.process_options(parser, opts, args)