コード例 #1
0
 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
コード例 #2
0
 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
コード例 #3
0
ファイル: test_proxy.py プロジェクト: mhils/mitmproxy
 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
コード例 #4
0
ファイル: test_proxy.py プロジェクト: MatthewShao/mitmproxy
 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
コード例 #5
0
ファイル: test_proxy.py プロジェクト: s4chin/mitmproxy
 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
コード例 #6
0
ファイル: test_cmdline.py プロジェクト: YangjunZ/mitmproxy
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"
コード例 #7
0
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"
コード例 #8
0
ファイル: test_cmdline.py プロジェクト: xorrbit/mitmproxy
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"
コード例 #9
0
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
コード例 #10
0
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)
コード例 #11
0
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)