本文整理匯總了Python中zato.server.rbac_.RBAC.delete_resource方法的典型用法代碼示例。如果您正苦於以下問題:Python RBAC.delete_resource方法的具體用法?Python RBAC.delete_resource怎麽用?Python RBAC.delete_resource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類zato.server.rbac_.RBAC
的用法示例。
在下文中一共展示了RBAC.delete_resource方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_delete_resource_no_roles
# 需要導入模塊: from zato.server.rbac_ import RBAC [as 別名]
# 或者: from zato.server.rbac_.RBAC import delete_resource [as 別名]
def test_delete_resource_no_roles(self):
name1, name2 = 'name1', 'name2'
rbac = RBAC()
rbac.create_resource(name1)
rbac.create_resource(name2)
rbac.delete_resource(name2)
self.assertEquals(rbac.registry._resources[name1], set())
self.assertNotIn(name2, rbac.registry._resources)
示例2: test_delete_resource_has_roles
# 需要導入模塊: from zato.server.rbac_ import RBAC [as 別名]
# 或者: from zato.server.rbac_.RBAC import delete_resource [as 別名]
def test_delete_resource_has_roles(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)
rbac.delete_resource(res_name1)
self.assertNotIn((role_id1, perm_id1, res_name1), rbac.registry._allowed)
self.assertNotIn((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)