atlassian-python-api icon indicating copy to clipboard operation
atlassian-python-api copied to clipboard

confluence.add_user_to_group is wrong

Open Mauwork opened this issue 1 year ago • 5 comments

https://github.com/atlassian-api/atlassian-python-api/blob/42ed0b022ec5d13416d79f4118e655f536247d07/atlassian/confluence.py#L3062 This function is using the wrong URL and it should be a "PUT" not a "POST" see: https://docs.atlassian.com/ConfluenceServer/rest/8.2.0/#api/user/{username}/group/{groupName}-update Fix that should work:

def add_user_to_group(self, username, group_name):
        """
        Add given user to a group

        :param username: str - username of user to add to group
        :param group_name: str - name of group to add user to
        :return: Current state of the group
        """
       url = f"rest/api/user/{username}/group/{group_name}"
       return self.put(url)

Mauwork avatar Jun 19 '24 06:06 Mauwork

Hi @Mauwork , first of all, thank you for your detection. please send PR

gonchik avatar Jun 26 '24 12:06 gonchik

PR: https://github.com/atlassian-api/atlassian-python-api/pull/1425

Mauwork avatar Jun 26 '24 13:06 Mauwork

Can someone point me to a place where I can add a test to cover the method ? So that the pull request can be merged ?

Mauwork avatar Jul 17 '24 15:07 Mauwork

In the test dir there are only two test files for confluence.

Spacetown avatar Jul 17 '24 19:07 Spacetown

Thanks, I would have guessed that somewhere all the other methods are tested, but it does not seem to be the case. So I guess for previous commits the coverage was not a necessary criterion to merge a pull request ?

Mauwork avatar Jul 18 '24 05:07 Mauwork

Actually, it has been fixed. Sorry, forgot to follow-up.

meanwhile added remove_user_from_group method as well https://github.com/atlassian-api/atlassian-python-api/commit/9181fe134b152558d754ec2ef564027a793b3520

gonchik avatar Apr 01 '25 21:04 gonchik