Exemple #1
0
def test_init():
    evaluator = create_evaluator(False)
    definition = "foo-bar"

    r = rule.Simple(definition, evaluator)

    assert r.definition == definition
    assert r.evaluator is evaluator
Exemple #2
0
def test_resolve_not_matching():
    evaluator = create_evaluator(False)
    definition = "foo-bar"
    not_definition = "bar-foo"
    role = mock.Mock()
    instance = rule.Simple(definition, evaluator)

    with pytest.raises(ValueError):
        instance.resolve(role, not_definition)
Exemple #3
0
def test_resolve_false():
    evaluator = create_evaluator(False)
    definition = "foo-bar"
    role = mock.Mock()
    instance = rule.Simple(definition, evaluator)
    result = instance.resolve(role, definition)

    assert not result.is_allowed
    assert result.level == 0
Exemple #4
0
def setup_rules(acl):
    acl.add_rule("user", rules.Simple("index.index", evaluators.allow))