Exemplo n.º 1
0
    def tearDown(self):
        if utils.username_exists(self.user):
            utils.delete_user(self.user)
        if utils.username_exists(self.new_user):
            utils.delete_user(self.new_user)

        # Remove groups:
        utils.delete_group(self.group_of_names)
        self.assertFalse(utils.group_exists(self.group_of_names))
        utils.delete_group(self.posix_group)
        self.assertFalse(utils.group_exists(self.posix_group))
        utils.delete_group(self.super_group)
        self.assertFalse(utils.group_exists(self.super_group))
Exemplo n.º 2
0
    def tearDown(self):
        if utils.username_exists(self.user):
            utils.delete_user(self.user)
        if utils.username_exists(self.new_user):
            utils.delete_user(self.new_user)

        # Remove groups:
        utils.delete_group(self.group_of_names)
        self.assertFalse(utils.group_exists(self.group_of_names))
        utils.delete_group(self.posix_group)
        self.assertFalse(utils.group_exists(self.posix_group))
        utils.delete_group(self.super_group)
        self.assertFalse(utils.group_exists(self.super_group))
Exemplo n.º 3
0
    def test_clear_posix_group(self):
        """Test PosixGroup modification"""
        self.assertTrue(utils.group_exists(self.posix_group))
        # Ensure that there are no members in the group (posixGroup has no
        # minimum number of members, so there should be no members upon
        # creation of the group):
        self.assertTrue(len(utils.get_group_members(self.posix_group)) == 0)

        # Add the user to the group:
        self.assertTrue(utils.mod_user_group(
            self.user, self.posix_group, action=MOD_ADD))
        # Ensure that there is now 1 member:
        self.assertTrue(len(utils.get_group_members(self.posix_group)) == 1)

        # Clear the group (removes the user):
        self.assertTrue(utils.clear_group_members(self.posix_group))
        # Group size should be 0 again:
        self.assertTrue(len(utils.get_group_members(self.posix_group)) == 0)
Exemplo n.º 4
0
    def test_clear_posix_group(self):
        """Test PosixGroup modification"""
        self.assertTrue(utils.group_exists(self.posix_group))
        # Ensure that there are no members in the group (posixGroup has no
        # minimum number of members, so there should be no members upon
        # creation of the group):
        self.assertTrue(len(utils.get_group_members(self.posix_group)) == 0)

        # Add the user to the group:
        self.assertTrue(
            utils.mod_user_group(self.user, self.posix_group, action=MOD_ADD))
        # Ensure that there is now 1 member:
        self.assertTrue(len(utils.get_group_members(self.posix_group)) == 1)

        # Clear the group (removes the user):
        self.assertTrue(utils.clear_group_members(self.posix_group))
        # Group size should be 0 again:
        self.assertTrue(len(utils.get_group_members(self.posix_group)) == 0)
Exemplo n.º 5
0
    def test_clear_group_of_names(self):
        """Test GroupOfNames modification"""
        self.assertTrue(utils.group_exists(self.group_of_names))
        # Ensure the there is only 1 member in the group (which should be the
        # default user), since this group is a groupOfNames object, requiring
        # at least 1 member):
        self.assertTrue(len(utils.get_group_members(self.group_of_names)) == 1)

        # Add the user to the group:
        self.assertTrue(
            utils.mod_user_group(self.user,
                                 self.group_of_names,
                                 action=MOD_ADD))
        # Ensure that there are now 2 members:
        self.assertTrue(len(utils.get_group_members(self.group_of_names)) == 2)

        # Clear the group (remove the user):
        self.assertTrue(utils.clear_group_members(self.group_of_names))
        # Group size should be 1 again, since default user should still be
        # left when clearing groupOfNames:
        self.assertTrue(len(utils.get_group_members(self.group_of_names)) == 1)
Exemplo n.º 6
0
    def test_clear_group_of_names(self):
        """Test GroupOfNames modification"""
        self.assertTrue(utils.group_exists(self.group_of_names))
        # Ensure the there is only 1 member in the group (which should be the
        # default user), since this group is a groupOfNames object, requiring
        # at least 1 member):
        self.assertTrue(
            len(utils.get_group_members(self.group_of_names)) == 1)

        # Add the user to the group:
        self.assertTrue(utils.mod_user_group(
            self.user, self.group_of_names, action=MOD_ADD))
        # Ensure that there are now 2 members:
        self.assertTrue(
            len(utils.get_group_members(self.group_of_names)) == 2)

        # Clear the group (remove the user):
        self.assertTrue(utils.clear_group_members(self.group_of_names))
        # Group size should be 1 again, since default user should still be
        # left when clearing groupOfNames:
        self.assertTrue(
            len(utils.get_group_members(self.group_of_names)) == 1)