Beispiel #1
0
def test_naming_constr_perm_2():
    naming_constraints = {"permitted": [], "excluded": []}
    _naming_constraints = NamingConstraints(permitted=["https://.example.com"])
    constraints = Constraints(naming_constraints=_naming_constraints)
    naming_constraints = update_naming_constraints(constraints,
                                                   naming_constraints)
    assert naming_constraints["permitted"] == ["https://.example.com"]
    assert naming_constraints["excluded"] == []

    # adding other domain - not permitted
    _naming_constraints = NamingConstraints(permitted=["https://.example.org"])
    constraints = Constraints(naming_constraints=_naming_constraints)
    naming_constraints = update_naming_constraints(constraints,
                                                   naming_constraints)
    assert naming_constraints["permitted"] == ["https://.example.com"]
    assert naming_constraints["excluded"] == []
Beispiel #2
0
def test_naming_constr_perm_1():
    naming_constraints = {"permitted": [], "excluded": []}
    _naming_constraints = NamingConstraints(permitted=["https://.example.com"])
    constraints = Constraints(naming_constraints=_naming_constraints)
    naming_constraints = update_naming_constraints(constraints,
                                                   naming_constraints)
    assert naming_constraints["permitted"] == ["https://.example.com"]
    assert naming_constraints["excluded"] == []

    # host more specific then domain
    _naming_constraints = NamingConstraints(
        permitted=["https://foo.example.com"])
    constraints = Constraints(naming_constraints=_naming_constraints)
    naming_constraints = update_naming_constraints(constraints,
                                                   naming_constraints)
    assert naming_constraints["permitted"] == ["https://foo.example.com"]
    assert naming_constraints["excluded"] == []
Beispiel #3
0
def test_naming_constr_1():
    naming_constraints = {"permitted": [], "excluded": []}
    _naming_constraints = NamingConstraints(
        permitted=["https://.example.com"],
        excluded=["https://east.example.com"])
    constraints = Constraints(naming_constraints=_naming_constraints)
    naming_constraints = update_naming_constraints(constraints,
                                                   naming_constraints)
    assert naming_constraints["permitted"] == ["https://.example.com"]
    assert naming_constraints["excluded"] == ["https://east.example.com"]
Beispiel #4
0
def test_naming_excluded_1():
    naming_constraints = {"permitted": [], "excluded": []}

    # permitted domain
    _naming_constraints = NamingConstraints(excluded=["https://.example.org"])
    constraints = Constraints(naming_constraints=_naming_constraints)
    naming_constraints = update_naming_constraints(constraints,
                                                   naming_constraints)
    assert naming_constraints["excluded"] == ["https://.example.org"]
    assert naming_constraints["permitted"] == []

    assert excluded('https://foo.example.org',
                    naming_constraints['excluded']) == True