本文整理汇总了Python中zato.server.rbac_.RBAC.delete_permission方法的典型用法代码示例。如果您正苦于以下问题:Python RBAC.delete_permission方法的具体用法?Python RBAC.delete_permission怎么用?Python RBAC.delete_permission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zato.server.rbac_.RBAC
的用法示例。
在下文中一共展示了RBAC.delete_permission方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_permission_no_client_permission
# 需要导入模块: from zato.server.rbac_ import RBAC [as 别名]
# 或者: from zato.server.rbac_.RBAC import delete_permission [as 别名]
def test_delete_permission_no_client_permission(self):
id, name = 1, 'name'
rbac = RBAC()
rbac.create_permission(id, name)
rbac.delete_permission(id)
self.assertTrue(id not in rbac.permissions)
示例2: test_delete_permission_has_role_permission
# 需要导入模块: from zato.server.rbac_ import RBAC [as 别名]
# 或者: from zato.server.rbac_.RBAC import delete_permission [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)