當前位置: 首頁>>代碼示例>>Python>>正文


Python RBAC.create_resource方法代碼示例

本文整理匯總了Python中zato.server.rbac_.RBAC.create_resource方法的典型用法代碼示例。如果您正苦於以下問題:Python RBAC.create_resource方法的具體用法?Python RBAC.create_resource怎麽用?Python RBAC.create_resource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在zato.server.rbac_.RBAC的用法示例。


在下文中一共展示了RBAC.create_resource方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_is_role_allowed_parent_hierarchy

# 需要導入模塊: from zato.server.rbac_ import RBAC [as 別名]
# 或者: from zato.server.rbac_.RBAC import create_resource [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))
開發者ID:Aayush-Kasurde,項目名稱:zato,代碼行數:31,代碼來源:test_rbac_.py

示例2: test_create_role_permission_deny

# 需要導入模塊: from zato.server.rbac_ import RBAC [as 別名]
# 或者: from zato.server.rbac_.RBAC import create_resource [as 別名]
    def test_create_role_permission_deny(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_deny(role_id1, perm_id1, res_name1)
        rbac.create_role_permission_deny(role_id1, perm_id2, res_name1)

        rbac.create_role_permission_deny(role_id2, perm_id1, res_name2)
        rbac.create_role_permission_deny(role_id2, perm_id2, res_name2)

        self.assertIn((role_id1, perm_id1, res_name1), rbac.registry._denied)
        self.assertIn((role_id1, perm_id2, res_name1), rbac.registry._denied)

        self.assertIn((role_id2, perm_id1, res_name2), rbac.registry._denied)
        self.assertIn((role_id2, perm_id2, res_name2), rbac.registry._denied)
開發者ID:Aayush-Kasurde,項目名稱:zato,代碼行數:34,代碼來源:test_rbac_.py

示例3: test_create_resource

# 需要導入模塊: from zato.server.rbac_ import RBAC [as 別名]
# 或者: from zato.server.rbac_.RBAC import create_resource [as 別名]
    def test_create_resource(self):
        name1, name2 = 'name1', 'name2'

        rbac = RBAC()
        rbac.create_resource(name1)
        rbac.create_resource(name2)

        self.assertEquals(rbac.registry._resources[name1], set())
        self.assertEquals(rbac.registry._resources[name2], set())
開發者ID:Aayush-Kasurde,項目名稱:zato,代碼行數:11,代碼來源:test_rbac_.py

示例4: test_delete_resource_no_roles

# 需要導入模塊: from zato.server.rbac_ import RBAC [as 別名]
# 或者: from zato.server.rbac_.RBAC import create_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)
開發者ID:Aayush-Kasurde,項目名稱:zato,代碼行數:12,代碼來源:test_rbac_.py

示例5: test_delete_permission_has_role_permission

# 需要導入模塊: from zato.server.rbac_ import RBAC [as 別名]
# 或者: from zato.server.rbac_.RBAC import create_resource [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)
開發者ID:Aayush-Kasurde,項目名稱:zato,代碼行數:42,代碼來源:test_rbac_.py


注:本文中的zato.server.rbac_.RBAC.create_resource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。