[MM-11593] Prevent user to remove from a direct channel (#9251)

* prevent user to remove from a direct channel

* only allow removing of a member in private or public channel
Этот коммит содержится в:
Saturnino Abril
2018-08-21 20:53:32 +08:00
коммит произвёл GitHub
родитель cea1796f06
Коммит f16687f83c
3 изменённых файлов: 33 добавлений и 0 удалений

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

@@ -2038,6 +2038,30 @@ func TestRemoveChannelMember(t *testing.T) {
_, resp = Client.RemoveUserFromChannel(privateChannel.Id, user2.Id)
CheckNoError(t, resp)
// Test on preventing removal of user from a direct channel
directChannel, resp := Client.CreateDirectChannel(user1.Id, user2.Id)
CheckNoError(t, resp)
_, resp = Client.RemoveUserFromChannel(directChannel.Id, user1.Id)
CheckBadRequestStatus(t, resp)
_, resp = Client.RemoveUserFromChannel(directChannel.Id, user2.Id)
CheckBadRequestStatus(t, resp)
_, resp = th.SystemAdminClient.RemoveUserFromChannel(directChannel.Id, user1.Id)
CheckBadRequestStatus(t, resp)
// Test on preventing removal of user from a group channel
user3 := th.CreateUser()
groupChannel, resp := Client.CreateGroupChannel([]string{user1.Id, user2.Id, user3.Id})
CheckNoError(t, resp)
_, resp = Client.RemoveUserFromChannel(groupChannel.Id, user1.Id)
CheckBadRequestStatus(t, resp)
_, resp = th.SystemAdminClient.RemoveUserFromChannel(groupChannel.Id, user1.Id)
CheckBadRequestStatus(t, resp)
}
func TestAutocompleteChannels(t *testing.T) {