def testRoleDefaults(self): self.assertEqual( a.Role({}, default=[a.Allow()]).allows(object()), True) self.assertEqual( a.Role({}, default=[a.Deny()]).allows(object()), False) self.assertEqual(a.Role({}, default=[]).allows(object()), None)
def testRoleDenies(self): obj = object() self.assertEqual(a.Role({obj: [a.Deny()]}).allows(obj), False)
def testRoleAllows(self): obj = object() self.assertEqual(a.Role({obj: [a.Allow()]}).allows(obj), True)
def testEmptyRuleList(self): obj = object() self.assertEqual(a.Role({obj: []}).allows(obj), None)
def testEmptyRole(self): self.assertEqual(a.Role({}).allows(object()), None)
from warp.common import access as a from warp.helpers import getNode config = { 'domain': 'localhost', 'port': 8080, 'db': "sqlite:warp.sqlite", # For posgres/mysql 'schema': { # Whether to check schema on startup 'check': False # By default migrations are read from "migrations" dir under # the project's root. Customize it with this key # 'migrations_dir': a twisted.python.filepath.FilePath }, # Whether to trace SQL queries using storm tracer 'trace': False, 'default': 'home', "defaultRoles": ("anon", ), "roles": { "anon": a.Role({ getNode("home"): (a.Allow(), ), }), "admin": a.Role({}, default=(a.Allow(), )), }, }