diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 9fc6966bc..561461538 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -69,7 +69,7 @@ class Options(optmanager.OptManager): ) self.add_option( "allow_hosts", Sequence[str], [], - "Opposite of --ignore_hosts." + "Opposite of --ignore-hosts." ) self.add_option( "listen_host", str, "", diff --git a/test/mitmproxy/proxy/test_config.py b/test/mitmproxy/proxy/test_config.py index 1da031c66..1319d1a9d 100644 --- a/test/mitmproxy/proxy/test_config.py +++ b/test/mitmproxy/proxy/test_config.py @@ -17,3 +17,12 @@ class TestProxyConfig: opts.certs = [tdata.path("mitmproxy/data/dumpfile-011")] with pytest.raises(exceptions.OptionsError, match="Invalid certificate format"): ProxyConfig(opts) + + def test_cannot_set_both_allow_and_filter_options(self): + opts = options.Options() + opts.ignore_hosts = ["foo"] + opts.allow_hosts = ["bar"] + with pytest.raises(exceptions.OptionsError, match="--ignore-hosts and --allow-hosts are " + "mutually exclusive; please choose " + "one."): + ProxyConfig(opts)