本文整理汇总了Python中zato.server.rbac_.RBAC.create_role_permission_allow方法的典型用法代码示例。如果您正苦于以下问题:Python RBAC.create_role_permission_allow方法的具体用法?Python RBAC.create_role_permission_allow怎么用?Python RBAC.create_role_permission_allow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zato.server.rbac_.RBAC
的用法示例。
在下文中一共展示了RBAC.create_role_permission_allow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_role_permission_allow
# 需要导入模块: from zato.server.rbac_ import RBAC [as 别名]
# 或者: from zato.server.rbac_.RBAC import create_role_permission_allow [as 别名]
def test_create_role_permission_allow(self):
role_id1, role_id2 = 1, 2
role_name1, role_name2 = 'role_name1', 'role_name2'
res_name1, res_name2 = 'res_name1', 'res_name2'
perm_id1, perm_id2 = 11, 22
perm_name1, perm_name2 = 'perm_name1', 'perm_name2'
rbac = RBAC()
rbac.create_role(role_id1, role_name1, None)
rbac.create_role(role_id2, role_name2, None)
rbac.create_resource(res_name1)
rbac.create_resource(res_name2)
rbac.create_permission(perm_id1, perm_name1)
rbac.create_permission(perm_id2, perm_name2)
rbac.create_role_permission_allow(role_id1, perm_id1, res_name1)
rbac.create_role_permission_allow(role_id1, perm_id2, res_name1)
rbac.create_role_permission_allow(role_id2, perm_id1, res_name2)
rbac.create_role_permission_allow(role_id2, perm_id2, res_name2)
self.assertIn((role_id1, perm_id1, res_name1), rbac.registry._allowed)
self.assertIn((role_id1, perm_id2, res_name1), rbac.registry._allowed)
self.assertIn((role_id2, perm_id1, res_name2), rbac.registry._allowed)
self.assertIn((role_id2, perm_id2, res_name2), rbac.registry._allowed)
示例2: test_is_role_allowed_parent_hierarchy
# 需要导入模块: from zato.server.rbac_ import RBAC [as 别名]
# 或者: from zato.server.rbac_.RBAC import create_role_permission_allow [as 别名]
def test_is_role_allowed_parent_hierarchy(self):
role_id1, role_id2 = 1, 2
role_name1, role_name2 = 'role_name1', 'role_name2'
res_name1, res_name2 = 'res_name1', 'res_name2'
perm_id1 = 11
perm_name1 = 'perm_name1'
rbac = RBAC()
rbac.create_role(role_id1, role_name1, None)
rbac.create_role(role_id2, role_name2, role_id1)
rbac.create_resource(res_name1)
rbac.create_resource(res_name2)
rbac.create_permission(perm_id1, perm_name1)
rbac.create_role_permission_allow(role_id2, perm_id1, res_name1)
rbac.create_role_permission_deny(role_id2, perm_id1, res_name2)
self.assertTrue(rbac.is_role_allowed(role_id2, perm_id1, res_name1))
self.assertFalse(rbac.is_role_allowed(role_id2, perm_id1, res_name2))
# Denied implicitly because there is no explicit 'allow'
self.assertFalse(rbac.is_role_allowed(role_id1, perm_id1, res_name1))
self.assertFalse(rbac.is_role_allowed(role_id1, perm_id1, res_name2))
示例3: test_delete_permission_has_role_permission
# 需要导入模块: from zato.server.rbac_ import RBAC [as 别名]
# 或者: from zato.server.rbac_.RBAC import create_role_permission_allow [as 别名]
def test_delete_permission_has_role_permission(self):
role_id1, role_name1 = 1, 'role_name1'
role_id2, role_name2 = 2, 'role_name2'
perm_id1, perm_name1 = 11, 'perm_name1'
perm_id2, perm_name2 = 22, 'perm_name2'
res_name1, res_name2 = 'res_name1', 'res_name2'
rbac = RBAC()
rbac.create_role(role_id1, role_name1, None)
rbac.create_role(role_id2, role_name2, None)
rbac.create_permission(perm_id1, perm_name1)
rbac.create_permission(perm_id2, perm_name2)
rbac.create_resource(res_name1)
rbac.create_resource(res_name2)
rbac.create_role_permission_allow(role_id1, perm_id1, res_name1)
rbac.create_role_permission_allow(role_id1, perm_id2, res_name1)
rbac.create_role_permission_allow(role_id2, perm_id1, res_name2)
rbac.create_role_permission_allow(role_id2, perm_id2, res_name2)
self.assertIn((role_id1, perm_id1, res_name1), rbac.registry._allowed)
self.assertIn((role_id1, perm_id2, res_name1), rbac.registry._allowed)
self.assertIn((role_id2, perm_id1, res_name2), rbac.registry._allowed)
self.assertIn((role_id2, perm_id2, res_name2), rbac.registry._allowed)
rbac.delete_permission(perm_id1)
self.assertNotIn((role_id1, perm_id1, res_name1), rbac.registry._allowed)
self.assertIn((role_id1, perm_id2, res_name1), rbac.registry._allowed)
self.assertNotIn((role_id2, perm_id1, res_name2), rbac.registry._allowed)
self.assertIn((role_id2, perm_id2, res_name2), rbac.registry._allowed)