예제 #1
0
파일: test_acl.py 프로젝트: thulyacloud/pcs
 def test_success(self):
     role_el = etree.Element("acl_role")
     etree.SubElement(role_el, "acl_permission", {
         "id": "role1-perm1",
         "kind": "read",
         "xpath": "XPATH",
     })
     etree.SubElement(
         role_el, "acl_permission", {
             "id": "role1-perm2",
             "description": "desc",
             "kind": "write",
             "reference": "id",
         })
     etree.SubElement(
         role_el, "acl_permission", {
             "id": "role1-perm3",
             "kind": "deny",
             "object-type": "type",
             "attribute": "attr",
         })
     expected = [{
         "id": "role1-perm1",
         "description": None,
         "kind": "read",
         "xpath": "XPATH",
         "reference": None,
         "object-type": None,
         "attribute": None,
     }, {
         "id": "role1-perm2",
         "description": "desc",
         "kind": "write",
         "xpath": None,
         "reference": "id",
         "object-type": None,
         "attribute": None,
     }, {
         "id": "role1-perm3",
         "description": None,
         "kind": "deny",
         "xpath": None,
         "reference": None,
         "object-type": "type",
         "attribute": "attr",
     }]
     # pylint: disable=protected-access
     self.assertEqual(expected, lib._get_permission_list(role_el))
예제 #2
0
 def test_success(self):
     role_el = etree.Element("acl_role")
     etree.SubElement(
         role_el,
         "acl_permission",
         {
             "id":"role1-perm1",
             "kind": "read",
             "xpath": "XPATH",
         }
     )
     etree.SubElement(
         role_el,
         "acl_permission",
         {
             "id": "role1-perm2",
             "description": "desc",
             "kind": "write",
             "reference": "id",
         }
     )
     etree.SubElement(
         role_el,
         "acl_permission",
         {
             "id": "role1-perm3",
             "kind": "deny",
             "object-type": "type",
             "attribute": "attr",
         }
     )
     expected = [
         {
             "id": "role1-perm1",
             "description": None,
             "kind": "read",
             "xpath": "XPATH",
             "reference": None,
             "object-type": None,
             "attribute": None,
         },
         {
             "id": "role1-perm2",
             "description": "desc",
             "kind": "write",
             "xpath": None,
             "reference": "id",
             "object-type": None,
             "attribute": None,
         },
         {
             "id": "role1-perm3",
             "description": None,
             "kind": "deny",
             "xpath": None,
             "reference": None,
             "object-type": "type",
             "attribute": "attr",
         }
     ]
     self.assertEqual(expected, lib._get_permission_list(role_el))