Esempio n. 1
0
def test_instance_from_external_call(test_oso):
    user = Actor(name="guest")
    resource = Company(id="1")
    assert test_oso.is_allowed(user, "frob", resource)
    assert test_oso.is_allowed({"username": "******"}, "frob", resource)
    Jwt.add_key(public_key)
    assert test_oso.is_allowed(token("guest"), "frob", resource)
Esempio n. 2
0
def test_fail(test_oso):
    actor = Actor(name="guest")
    resource = Widget(id="1")
    action = "not_allowed"
    assert not test_oso.is_allowed(actor, action, resource)
    assert not test_oso.is_allowed({"username": "******"}, action, resource)
    Jwt.add_key(public_key)
    assert not test_oso.is_allowed(token("guest"), action, resource)
Esempio n. 3
0
def test_is_allowed(test_oso):
    actor = Actor(name="guest")
    resource = Widget(id="1")
    action = "get"
    assert test_oso.is_allowed(actor, action, resource)
    assert test_oso.is_allowed({"username": "******"}, action, resource)
    assert test_oso.is_allowed("guest", action, resource)
    Jwt.add_key(public_key)
    assert test_oso.is_allowed(token("guest"), action, resource)

    actor = Actor(name="president")
    action = "create"
    resource = Company(id="1")
    assert test_oso.is_allowed(actor, action, resource)
    assert test_oso.is_allowed({"username": "******"}, action, resource)
    assert test_oso.is_allowed(token("president"), action, resource)