def test_permission_difference_denial(self): p1 = Denial(('a', 'b'), ('a', 'c')) p2 = Denial(('a', 'c'), ('d', 'e')) p3 = p1.difference(p2) assert p3.excludes == set([('a', 'b')]) p4 = p2.difference(p1) assert p4.excludes == set([('d', 'e')])
def files_rest_permission_factory(obj, action): """Generate a denying permission.""" return Denial(any_user)
def test_permission_union_denial(self): p1 = Permission(('a', 'b')) p2 = Denial(('a', 'c')) p3 = p1.union(p2) assert p1.issubset(p3) assert p2.issubset(p3)
if identity.name == 'ali': identity.provides.add(RoleNeed('admin')) class ReraiseException(Exception): """For checking reraising""" admin_permission = Permission(RoleNeed('admin')) anon_permission = Permission() admin_or_editor = Permission(RoleNeed('admin'), RoleNeed('editor')) editor_permission = Permission(RoleNeed('editor')) admin_denied = Denial(RoleNeed('admin')) def mkapp(with_factory=False): app = Flask(__name__) app.secret_key = 'notverysecret' app.debug = True if with_factory: p = Principal() p.init_app(app) else: p = Principal(app) identity_loaded.connect(_on_principal_init)