本文整理匯總了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)