本文整理匯總了Python中zato.server.rbac_.RBAC.delete_role方法的典型用法代碼示例。如果您正苦於以下問題:Python RBAC.delete_role方法的具體用法?Python RBAC.delete_role怎麽用?Python RBAC.delete_role使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類zato.server.rbac_.RBAC
的用法示例。
在下文中一共展示了RBAC.delete_role方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_delete_role_parent_hierarchy_delete_leaf
# 需要導入模塊: from zato.server.rbac_ import RBAC [as 別名]
# 或者: from zato.server.rbac_.RBAC import delete_role [as 別名]
def test_delete_role_parent_hierarchy_delete_leaf(self):
id1, parent_id1 = 1, 11
id2, id3, id4 = 2, 3, 4
name1, name2, name3, name4 = 'name1', 'name2', 'name3', 'name4'
rbac = RBAC()
rbac.create_role(id1, name1, parent_id1)
rbac.create_role(id2, name2, id1)
rbac.create_role(id3, name3, id1)
rbac.create_role(id4, name4, id2)
rbac.delete_role(id4, name4)
self.assertIn(id1, rbac.role_id_to_name)
self.assertIn(id2, rbac.role_id_to_name)
self.assertIn(id3, rbac.role_id_to_name)
self.assertNotIn(id4, rbac.role_id_to_name)
self.assertIn(name1, rbac.role_name_to_id)
self.assertIn(name2, rbac.role_name_to_id)
self.assertIn(name3, rbac.role_name_to_id)
self.assertNotIn(name4, rbac.role_name_to_id)
self.assertIn(id1, rbac.registry._roles)
self.assertIn(id2, rbac.registry._roles)
self.assertIn(id3, rbac.registry._roles)
self.assertNotIn(id4, rbac.registry._roles)
示例2: test_delete_role_parent_not_given
# 需要導入模塊: from zato.server.rbac_ import RBAC [as 別名]
# 或者: from zato.server.rbac_.RBAC import delete_role [as 別名]
def test_delete_role_parent_not_given(self):
id, name = rand_int(), rand_string()
rbac = RBAC()
# Create and confirm it was added
rbac.create_role(id, name, None)
self.assertEqual(rbac.role_id_to_name[id], name)
self.assertEqual(rbac.role_name_to_id[name], id)
self.assertIn(id, rbac.registry._roles)
self.assertEquals(rbac.registry._roles[id], set())
# Delete and confirm the action
rbac.delete_role(id, name)
self.assertNotIn(id, rbac.role_id_to_name)
self.assertNotIn(name, rbac.role_name_to_id)
self.assertNotIn(id, rbac.registry._roles)