Pull requests

#1 Merged
Repository
febbraro
Branch
master
Repository
knecht_andreas
Branch
master

Fixed the path to the group name

Author
  1. Frank Febbraro
Reviewers
Description

Thanks for the feedback. Updated the PR to support both JIRA and Crowd.

  • Learn about pull requests

Comments (3)

  1. Andreas Knecht repo owner

    Thanks for the pull request!

    Well so this is a bit annoying. If you use this against JIRA (with JIRA setups as a 'User Server') then its REST api returns this:

    {
        "expand": "group",
        "groups": [{
            "GroupEntity": {
                "link": {
                    "href": "http://localhost:2990/jira/rest/usermanagement/latest/group?groupname=jira-administrators",
                    "rel": "self"
                },
                "name": "jira-administrators"
            }
        }, {
            "GroupEntity": {
                "link": {
                    "href": "http://localhost:2990/jira/rest/usermanagement/latest/group?groupname=jira-developers",
                    "rel": "self"
                },
                "name": "jira-developers"
            }
        }, {
            "GroupEntity": {
                "link": {
                    "href": "http://localhost:2990/jira/rest/usermanagement/latest/group?groupname=jira-users",
                    "rel": "self"
                },
                "name": "jira-users"
            }
        }]
    }
    

    Latest version of Crowd however returns this:

    {
        "expand": "group",
        "groups": [{
            "link": {
                "href": "http://localhost:8095/crowd/rest/usermanagement/latest/group?groupname=crowd-administrators",
                "rel": "self"
            },
            "name": "crowd-administrators"
        }]
    }
    

    They both share the same library to make this Crowd REST api available, but looks like the REST api has evolved a bit in Crowd and JIRA isn't bundling the latest version yet. I think we should support both in order to stay backwards compatible with older versions as well.

    Can you change this to be something like this (after testing in your environment to make sure it works for you), and I'll merge in the pull request and deploy a new release of the library to NPM:

    if(group.GroupEntity) {
        groups.push(group.GroupEntity.name);
    } else {
        groups.push(group.name);
    }