Example #1
0
 def test_success(self):
     self.cib.append_to_first_tag_name(
         "configuration", """
         <acls>
             <acl_role id="role1" description="desc1">
                 <acl_permission id="role1-perm1" kind="read" xpath="XPATH"/>
                 <acl_permission
                     id="role1-perm2"
                     description="desc"
                     kind="write"
                     reference="id"
                 />
                 <acl_permission
                     id="role1-perm3"
                     kind="deny"
                     object-type="type"
                     attribute="attr"
                 />
             </acl_role>
             <acl_target id="target1"/>
             <acl_role id="role2"/>
         </acls>
         """)
     expected = [{
         "id":
         "role1",
         "description":
         "desc1",
         "permission_list": [{
             "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",
         }]
     }, {
         "id": "role2",
         "description": None,
         "permission_list": [],
     }]
     self.assertEqual(expected, lib.get_role_list(self.acls))
Example #2
0
def get_config(lib_env):
    """
    Returns ACL configuration in dictionary. Format of output:
        {
            "target_list": <list of targets>,
            "group_list": <list og groups>,
            "role_list": <list of roles>,
        }

    lib_env -- LibraryEnvironment
    """
    acl_section = get_acls(lib_env.get_cib(REQUIRED_CIB_VERSION))
    return {
        "target_list": acl.get_target_list(acl_section),
        "group_list": acl.get_group_list(acl_section),
        "role_list": acl.get_role_list(acl_section),
    }
Example #3
0
def get_config(lib_env):
    """
    Returns ACL configuration in disctionary. Fromat of output:
        {
            "target_list": <list of targets>,
            "group_list": <list og groups>,
            "role_list": <list of roles>,
        }

    lib_env -- LibraryEnvironment
    """
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    return {
        "target_list": acl.get_target_list(cib),
        "group_list": acl.get_group_list(cib),
        "role_list": acl.get_role_list(cib),
    }
Example #4
0
 def test_success(self):
     self.cib.append_to_first_tag_name(
         "configuration",
         """
         <acls>
             <acl_role id="role1" description="desc1">
                 <acl_permission id="role1-perm1" kind="read" xpath="XPATH"/>
                 <acl_permission
                     id="role1-perm2"
                     description="desc"
                     kind="write"
                     reference="id"
                 />
                 <acl_permission
                     id="role1-perm3"
                     kind="deny"
                     object-type="type"
                     attribute="attr"
                 />
             </acl_role>
             <acl_target id="target1"/>
             <acl_role id="role2"/>
         </acls>
         """
     )
     expected = [
         {
             "id": "role1",
             "description": "desc1",
             "permission_list": [
                 {
                     "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",
                 }
             ]
         },
         {
             "id": "role2",
             "description": None,
             "permission_list": [],
         }
     ]
     self.assertEqual(expected, lib.get_role_list(self.cib.tree))