Verify ignore_hosts & allow_hosts are mutually exclusive

This commit is contained in:
Pierre Gordon 2019-04-19 13:10:39 -05:00
parent 8d0c800d15
commit 1b3f86e709
2 changed files with 10 additions and 1 deletions

View File

@ -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, "",

View File

@ -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)