コード例 #1
0
def test_check_allowlist_accepts_all_on_star() -> None:
    assert util.check_allowlist("192.168.0.1", ['*']) is True
    assert util.check_allowlist("192.168.0.1:80", ['*']) is True
    assert util.check_allowlist("192.168.0.1:5006", ['*']) is True
    assert util.check_allowlist("192.168.0.1:80", ['*:80']) is True
    assert util.check_allowlist("192.168.0.1:80", ['*:81']) is False
    assert util.check_allowlist("192.168.0.1:5006", ['*:*']) is True
    assert util.check_allowlist("192.168.0.1", ['192.168.0.*']) is True
    assert util.check_allowlist("192.168.0.1:5006", ['192.168.0.*']) is True
    assert util.check_allowlist("192.168.1.1", ['192.168.0.*']) is False
    assert util.check_allowlist("foobarbaz", ['*']) is True
    assert util.check_allowlist("192.168.0.1", ['192.168.0.*']) is True
    assert util.check_allowlist("192.168.1.1", ['192.168.0.*']) is False
    assert util.check_allowlist("192.168.0.1", ['192.168.0.*:5006']) is False
    assert util.check_allowlist("192.168.0.1", ['192.168.0.*:80']) is True
    assert util.check_allowlist("foobarbaz", ['*']) is True
    assert util.check_allowlist("foobarbaz", ['*:*']) is True
    assert util.check_allowlist("foobarbaz", ['*:80']) is True
    assert util.check_allowlist("foobarbaz", ['*:5006']) is False
    assert util.check_allowlist("foobarbaz:5006", ['*']) is True
    assert util.check_allowlist("foobarbaz:5006", ['*:*']) is True
    assert util.check_allowlist("foobarbaz:5006", ['*:5006']) is True
コード例 #2
0
def test_check_allowlist_accepts_implicit_port_80() -> None:
    assert util.check_allowlist("foo", ["foo:80"]) is True
コード例 #3
0
def test_check_allowlist_rejects_name_mismatch() -> None:
    assert util.check_allowlist("foo:100", ["bar:100", "baz:100"]) is False
コード例 #4
0
def test_check_allowlist_accepts_name_port_match() -> None:
    assert util.check_allowlist("foo:100", ["foo:100", "baz:100"]) is True
コード例 #5
0
def test_check_allowlist_rejects_port_mismatch() -> None:
    assert util.check_allowlist("foo:100", ["foo:101", "foo:102"]) is False