MM-14753: Verifies that user can join teams and channels in spite of group constraints. (#10529)

* MM-147753: Verifies that users are allowed to be members of a team or a channel, based on group constraints, prior to allowing the API to add them.

* MM-14753: Allow methods to return meaningful results for deleted teams or channels.

* MM-14753: Renames methods to differentiate from permissions and other team and channel restrictions.

* MM-14753: Only check if users are team/channel members if team/channel is group constrained.

* MM-14753: Updates test function names.

* MM-14753: Changes a few method signatures.

* MM-14753: Small refactor and adds missing returns.

* MM-14753: Changes method names from Get* to Filter* name prefixes.

* MM-14753: Renames error variables.

* MM-14753: Updates method names for consistency with join table names.

* MM-14753: Adds case for non AppError return.

* Update i18n/en.json
Этот коммит содержится в:
Martin Kraft
2019-04-09 07:09:57 -04:00
коммит произвёл GitHub
родитель 43fa7e0548
Коммит 7bde0378cd
11 изменённых файлов: 629 добавлений и 2 удалений

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

@@ -2021,6 +2021,30 @@ func TestAddChannelMember(t *testing.T) {
_, resp = Client.AddChannelMember(privateChannel.Id, user3.Id)
CheckNoError(t, resp)
Client.Logout()
// Set a channel to group-constrained
privateChannel.GroupConstrained = model.NewBool(true)
_, appErr := th.App.UpdateChannel(privateChannel)
require.Nil(t, appErr)
// User is not in associated groups so shouldn't be allowed
_, resp = th.SystemAdminClient.AddChannelMember(privateChannel.Id, user.Id)
CheckErrorMessage(t, resp, "api.channel.add_members.user_denied")
// Associate group to team
_, appErr = th.App.CreateGroupSyncable(&model.GroupSyncable{
GroupId: th.Group.Id,
SyncableId: privateChannel.Id,
Type: model.GroupSyncableTypeChannel,
})
require.Nil(t, appErr)
// Add user to group
_, appErr = th.App.CreateOrRestoreGroupMember(th.Group.Id, user.Id)
require.Nil(t, appErr)
_, resp = th.SystemAdminClient.AddChannelMember(privateChannel.Id, user.Id)
CheckNoError(t, resp)
}
func TestAddChannelMemberAddMyself(t *testing.T) {