def test_initialization_with_set(flask_app, oso, simple_policy, app_ctx, user): """Test that setting oso works correctly.""" # Establish that an improperly initalized flask oso throws an exception. flask_oso = FlaskOso() flask_oso.set_get_actor(lambda: user) with pytest.raises(AttributeError): flask_oso.authorize(action="read", resource="resource") # Works after set oso. flask_oso.set_oso(oso) flask_oso.authorize(action="read", resource="resource")
def test_initialization_with_init(flask_app, oso, simple_policy, app_ctx, user): # Works with oso init. flask_oso = FlaskOso(oso=oso) flask_oso.set_get_actor(lambda: user) flask_oso.authorize(action="read", resource="resource")