added fetching groups of user if the scope includes 'api', extended and refactored tests
Description
This commit includes changes that extend the profile-object returned by this application to include the groups the user has access to. This is done by means of a nested callback which is executed if the scope includes 'api'. The callback extends the profile object by the groups-property, which value is an array containing the group names.
To test the behaviour of the newly added code, the strategy.profile.spec.js was extended with more tests. It was necessary to wrap the _oauth.get-method inside a closure to generate different behaviour, as this class mocks the behaviour of that method. The oAuthGetReplacementClosure now accepts a config object to e.g. return a malformed response to the groups request, but a correct one to the profile-request. The existing tests were adapted to use the newly introduced method.
Further information
This feature is useful if an existing gitlab-deployment shall be used for login, but not every user should have access to the application. To my knowledge, there exists no standardized way for writing groups to the user profile. Therefore, this commit uses the most basic approach of just adding the groups as an array of strings.
Coverage remained the same at 100.0% when pulling 7d4457a89f8fdf5fd7f238f6e2c1373f5c31e6e1 on zergar:master into 4238b67438c1f1a7050908556ac010bc319b734a on fh1ch:master.
Hello @fh1ch, how are you ? The passport-gitlab2 module, is it still maintained ? Do you think, you can merge this MR to the module ? I'm looking for a way to filter logins based on the group.