summaryrefslogtreecommitdiffstats
path: root/api4/channel_test.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2018-08-21 20:53:32 +0800
committerGitHub <noreply@github.com>2018-08-21 20:53:32 +0800
commitf16687f83cea20f1ed3682226b60011097c85648 (patch)
tree2f0e331da8931c8f97dcdd93ff7c1634397311b3 /api4/channel_test.go
parentcea1796f0698956e4fab57a0015b292854bbbcf3 (diff)
downloadchat-f16687f83cea20f1ed3682226b60011097c85648.tar.gz
chat-f16687f83cea20f1ed3682226b60011097c85648.tar.bz2
chat-f16687f83cea20f1ed3682226b60011097c85648.zip
[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
Diffstat (limited to 'api4/channel_test.go')
-rw-r--r--api4/channel_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go
index 5ca4dee6e..8593ea831 100644
--- a/api4/channel_test.go
+++ b/api4/channel_test.go
@@ -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) {