Example #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"] == []
Example #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"] == []
Example #3
0
def test_max_path_length_no():
    current_max_path_length = 2
    max_assigned = True
    constraints = Constraints()
    current_max_path_length = calculate_path_length(constraints,
                                                    current_max_path_length,
                                                    max_assigned)
    assert current_max_path_length == 1
Example #4
0
def test_max_path_length_start():
    current_max_path_length = 0
    max_assigned = False
    constraints = Constraints(max_path_length=1)
    current_max_path_length = calculate_path_length(constraints,
                                                    current_max_path_length,
                                                    max_assigned)
    assert current_max_path_length == 1
Example #5
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"]
Example #6
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