[MM-21793] Allow bots to be added to group synced channels and teams (#13672)

* MM-21793: Allow bots to be removed and added from group synced teams and channels

* MM-21793: Add tests for adding and removing a team and channel members

* MM-21793 Add punctuation to comments and remove unnecessary variable
Этот коммит содержится в:
Farhan Munshi
2020-01-29 11:01:06 -05:00
коммит произвёл GitHub
родитель ffb3897c8c
Коммит fa769e46d7
10 изменённых файлов: 191 добавлений и 45 удалений

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

@@ -2387,6 +2387,12 @@ func TestRemoveChannelMember(t *testing.T) {
defer th.TearDown()
Client := th.Client
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.EnableBotAccountCreation = true
})
bot := th.CreateBotWithSystemAdminClient()
th.App.AddUserToTeam(team.Id, bot.UserId, "")
pass, resp := Client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser2.Id)
CheckNoError(t, resp)
require.True(t, pass, "should have passed")
@@ -2536,6 +2542,8 @@ func TestRemoveChannelMember(t *testing.T) {
CheckNoError(t, resp)
_, resp = th.SystemAdminClient.AddChannelMember(privateChannel.Id, user2.Id)
CheckNoError(t, resp)
_, resp = th.SystemAdminClient.AddChannelMember(privateChannel.Id, bot.UserId)
CheckNoError(t, resp)
_, resp = Client.RemoveUserFromChannel(privateChannel.Id, user2.Id)
CheckForbiddenStatus(t, resp)
@@ -2564,6 +2572,10 @@ func TestRemoveChannelMember(t *testing.T) {
directChannel, resp := Client.CreateDirectChannel(user1.Id, user2.Id)
CheckNoError(t, resp)
// If the channel is group-constrained a user can remove a bot
_, resp = Client.RemoveUserFromChannel(privateChannel.Id, bot.UserId)
CheckNoError(t, resp)
_, resp = Client.RemoveUserFromChannel(directChannel.Id, user1.Id)
CheckBadRequestStatus(t, resp)