[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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ffb3897c8c
Коммит
fa769e46d7
@@ -1721,6 +1721,11 @@ func TestAddTeamMembers(t *testing.T) {
|
||||
otherUser.Id,
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.EnableBotAccountCreation = true
|
||||
})
|
||||
bot := th.CreateBotWithSystemAdminClient()
|
||||
|
||||
err := th.App.RemoveUserFromTeam(th.BasicTeam.Id, th.BasicUser2.Id, "")
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -1813,6 +1818,10 @@ func TestAddTeamMembers(t *testing.T) {
|
||||
_, resp = Client.AddTeamMembers(team.Id, userList)
|
||||
CheckErrorMessage(t, resp, "api.team.add_members.user_denied")
|
||||
|
||||
// Ensure that a group synced team can still add bots
|
||||
_, resp = Client.AddTeamMembers(team.Id, []string{bot.UserId})
|
||||
CheckNoError(t, resp)
|
||||
|
||||
// Associate group to team
|
||||
_, err = th.App.UpsertGroupSyncable(&model.GroupSyncable{
|
||||
GroupId: th.Group.Id,
|
||||
@@ -1834,6 +1843,11 @@ func TestRemoveTeamMember(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.EnableBotAccountCreation = true
|
||||
})
|
||||
bot := th.CreateBotWithSystemAdminClient()
|
||||
|
||||
pass, resp := Client.RemoveTeamMember(th.BasicTeam.Id, th.BasicUser.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -1860,6 +1874,9 @@ func TestRemoveTeamMember(t *testing.T) {
|
||||
_, resp = th.SystemAdminClient.AddTeamMember(th.BasicTeam.Id, th.SystemAdminUser.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
_, resp = th.SystemAdminClient.AddTeamMember(th.BasicTeam.Id, bot.UserId)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
// If the team is group-constrained the user cannot be removed
|
||||
th.BasicTeam.GroupConstrained = model.NewBool(true)
|
||||
_, err := th.App.UpdateTeam(th.BasicTeam)
|
||||
@@ -1867,6 +1884,10 @@ func TestRemoveTeamMember(t *testing.T) {
|
||||
_, resp = th.SystemAdminClient.RemoveTeamMember(th.BasicTeam.Id, th.BasicUser.Id)
|
||||
require.Equal(t, "api.team.remove_member.group_constrained.app_error", resp.Error.Id)
|
||||
|
||||
// Can remove a bot even if team is group-constrained
|
||||
_, resp = th.SystemAdminClient.RemoveTeamMember(th.BasicTeam.Id, bot.UserId)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
// Can remove self even if team is group-constrained
|
||||
_, resp = th.SystemAdminClient.RemoveTeamMember(th.BasicTeam.Id, th.SystemAdminUser.Id)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
Ссылка в новой задаче
Block a user