def test_key_dict_unsupport(self): struct = yaml.load(""" testing: admin: key: wont: work""") self.assertRaises(Exception, build_acl, struct) try: build_acl(struct) except Exception as e: assert 'not supported' in str(e)
def test_basic_key(self): struct = yaml.load(""" testing: user: key: exists""") acl = build_acl(struct) assert 'key_exists' in acl['testing']['user']
def test_basic_inherit_role(self): struct = yaml.load(""" testing: admin: inherit: user user: key: - exists""") acl = build_acl(struct) assert 'key_exists' in acl['testing']['admin']
def test_basic_inherit_type(self): struct = yaml.load(""" testing: user: key: exists testing2: inherit: testing user: key: also_exists""") acl = build_acl(struct) assert 'key_exists' in acl['testing2']['user']
def test_inherit_virtual(self): struct = yaml.load(""" testing: virtual: true user: key: exists testing2: inherit: testing admin: inherit: user""") acl = build_acl(struct) assert 'testing' not in acl assert 'key_exists' in acl['testing2']['admin']
def test_inherit_virtual_inherit(self): struct = yaml.load(""" testing: other: key2: exists user: key: exists inherit: other testing2: inherit: testing other: key3: exists admin: inherit: user""") acl = build_acl(struct) assert 'key3_exists' in acl['testing2']['admin'] assert 'key2_exists' in acl['testing2']['admin']
import yaml from . import root from lever import build_acl acl_yaml = yaml.load(open(root + '/crowdlink/acl.yaml')) acl = build_acl(acl_yaml)
def test_virtual_removal(self): struct = yaml.load(""" testing: virtual: true""") acl = build_acl(struct) assert 'testing' not in acl