[MM-22071] Allow fetch all groups as a system admin (#13866)

* Merge upstream

* allow fetch all groups

* Delete report.xml

* update i18n stuffz

* fix test cases

* fix bug

Co-authored-by: Jason Paul Deland <9366595+jaydeland@users.noreply.github.com>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Hossein Ahmadian-Yazdi
2020-02-24 05:53:58 -05:00
коммит произвёл GitHub
родитель 17f2cd665d
Коммит 4587913b49
3 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@@ -581,8 +581,8 @@ func getGroups(c *Context, w http.ResponseWriter, r *http.Request) {
channelID = id
}
if teamID == "" && channelID == "" {
c.Err = model.NewAppError("Api4.getGroups", "api.getGroups.invalid_or_missing_channel_or_team_id", nil, "", http.StatusBadRequest)
if teamID == "" && channelID == "" && !c.App.SessionHasPermissionTo(*c.App.Session(), model.PERMISSION_MANAGE_SYSTEM) {
c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
return
}

Просмотреть файл

@@ -801,7 +801,7 @@ func TestGetGroups(t *testing.T) {
th.App.SetLicense(model.NewTestLicense("ldap"))
_, response = th.SystemAdminClient.GetGroups(opts)
CheckBadRequestStatus(t, response)
require.Nil(t, response.Error)
_, response = th.SystemAdminClient.UpdateChannelRoles(th.BasicChannel.Id, th.BasicUser.Id, "")
require.Nil(t, response.Error)
@@ -841,4 +841,9 @@ func TestGetGroups(t *testing.T) {
_, response = th.Client.GetGroups(opts)
assert.Nil(t, response.Error)
opts.NotAssociatedToTeam = ""
opts.NotAssociatedToChannel = ""
_, response = th.Client.GetGroups(opts)
CheckForbiddenStatus(t, response)
}