Ejemplo n.º 1
0
 def test_returns_target(self, find_target, find_group):
     find_target.return_value = "target_element"
     self.assertEqual(lib.find_target_or_group("acl_section", "target_id"),
                      "target_element")
     find_target.assert_called_once_with("acl_section",
                                         "target_id",
                                         none_if_id_unused=True)
Ejemplo n.º 2
0
 def test_returns_group_if_target_is_none(self, find_target, find_group):
     find_target.return_value = None
     find_group.return_value = "group_element"
     self.assertEqual(lib.find_target_or_group("acl_section", "group_id"),
                      "group_element")
     find_target.assert_called_once_with("acl_section",
                                         "group_id",
                                         none_if_id_unused=True)
     find_group.assert_called_once_with(
         "acl_section", "group_id", id_types=["acl_group", "acl_target"])
Ejemplo n.º 3
0
 def test_returns_target(self, find_target, find_group):
     find_target.return_value = "target_element"
     self.assertEqual(
         lib.find_target_or_group("acl_section", "target_id"),
         "target_element"
     )
     find_target.assert_called_once_with(
         "acl_section",
         "target_id",
         none_if_id_unused=True
     )
Ejemplo n.º 4
0
def assign_role_not_specific(lib_env, role_id, target_or_group_id):
    """
    Assign role with id role_id to target or group with id target_or_group_id.
    Target element has bigger priority so if there are target and group with
    the same id only target element will be affected by this function.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnviroment
    role_id -- id of role which should be assigned to target/group
    target_or_group_id -- id of target/group element
    """
    with cib_acl_section(lib_env) as acl_section:
        acl.assign_role(
            acl_section,
            role_id,
            acl.find_target_or_group(acl_section, target_or_group_id),
        )
Ejemplo n.º 5
0
 def test_returns_group_if_target_is_none(self, find_target, find_group):
     find_target.return_value = None
     find_group.return_value = "group_element"
     self.assertEqual(
         lib.find_target_or_group("acl_section", "group_id"),
         "group_element"
     )
     find_target.assert_called_once_with(
         "acl_section",
         "group_id",
         none_if_id_unused=True
     )
     find_group.assert_called_once_with(
         "acl_section",
         "group_id",
         id_types=["acl_group", "acl_target"]
     )
Ejemplo n.º 6
0
def assign_role_not_specific(lib_env, role_id, target_or_group_id):
    """
    Assign role wth id role_id to target or group with id target_or_group_id.
    Target element has bigger pririty so if there are target and group with same
    id only target element will be affected by this function.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnviroment
    role_id -- id of role which should be assigne to target/group
    target_or_group_id -- id of target/group element
    """
    with cib_acl_section(lib_env) as acl_section:
        acl.assign_role(
            acl_section,
            role_id,
            acl.find_target_or_group(acl_section, target_or_group_id),
        )
Ejemplo n.º 7
0
Archivo: acl.py Proyecto: wuyeliang/pcs
def unassign_role_not_specific(lib_env,
                               role_id,
                               target_or_group_id,
                               autodelete_target_group=False):
    """
    Unassign role with role_id from target/group with id target_or_group_id.
    Target element has bigger priority so if there are target and group with
    the same id only target element will be affected by this function.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnvironment
    role_id -- id of role which should be unassigned from target/group
    target_or_group_id -- id of acl_target/acl_group element
    autodelete_target_group -- if True remove target/group element if has no
        more role assigned
    """
    with cib_acl_section(lib_env) as acl_section:
        acl.unassign_role(
            acl.find_target_or_group(acl_section, target_or_group_id), role_id,
            autodelete_target_group)
Ejemplo n.º 8
0
def unassign_role_not_specific(
    lib_env, role_id, target_or_group_id, autodelete_target_group=False
):
    """
    Unassign role with role_id from target/group with id target_or_group_id.
    Target element has bigger pririty so if there are target and group with same
    id only target element will be affected by this function.
    Raises LibraryError on any failure.

    lib_env -- LibraryEnvironment
    role_id -- id of role which should be unassigned from target/group
    target_or_group_id -- id of acl_target/acl_group element
    autodelete_target_group -- if True remove target/group element if has no
        more role assigned
    """
    with cib_acl_section(lib_env) as acl_section:
        acl.unassign_role(
            acl.find_target_or_group(acl_section, target_or_group_id),
            role_id,
            autodelete_target_group
        )