summaryrefslogtreecommitdiffstats
path: root/api4/channel_test.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2018-07-10 09:55:46 +0100
committerCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-07-10 10:55:46 +0200
commit2d16a71af9bff88d89244279849f8129a326a0e1 (patch)
treef5121acb3386c03ac32ffe29f3eca0b6ed086c59 /api4/channel_test.go
parent602fd0ffdd5b6cfcf99363921960f02f1bd0d6ee (diff)
downloadchat-2d16a71af9bff88d89244279849f8129a326a0e1.tar.gz
chat-2d16a71af9bff88d89244279849f8129a326a0e1.tar.bz2
chat-2d16a71af9bff88d89244279849f8129a326a0e1.zip
MM-11228: Fix channel update/patch API endpoints. (#9073)
Diffstat (limited to 'api4/channel_test.go')
-rw-r--r--api4/channel_test.go58
1 files changed, 57 insertions, 1 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go
index ab751f151..43223d060 100644
--- a/api4/channel_test.go
+++ b/api4/channel_test.go
@@ -209,8 +209,34 @@ func TestUpdateChannel(t *testing.T) {
channel.DisplayName = "Should not update"
_, resp = Client.UpdateChannel(channel)
- CheckNotFoundStatus(t, resp)
+ CheckForbiddenStatus(t, resp)
+
+ // Test updating the header of someone else's GM channel.
+ user1 := th.CreateUser()
+ user2 := th.CreateUser()
+ user3 := th.CreateUser()
+
+ groupChannel, resp := Client.CreateGroupChannel([]string{user1.Id, user2.Id})
+ CheckNoError(t, resp)
+
+ groupChannel.Header = "lolololol"
+ Client.Logout()
+ Client.Login(user3.Email, user3.Password)
+ _, resp = Client.UpdateChannel(groupChannel)
+ CheckForbiddenStatus(t, resp)
+ // Test updating the header of someone else's GM channel.
+ Client.Logout()
+ Client.Login(user.Email, user.Password)
+
+ directChannel, resp := Client.CreateDirectChannel(user.Id, user1.Id)
+ CheckNoError(t, resp)
+
+ directChannel.Header = "lolololol"
+ Client.Logout()
+ Client.Login(user3.Email, user3.Password)
+ _, resp = Client.UpdateChannel(directChannel)
+ CheckForbiddenStatus(t, resp)
}
func TestPatchChannel(t *testing.T) {
@@ -267,6 +293,36 @@ func TestPatchChannel(t *testing.T) {
_, resp = th.SystemAdminClient.PatchChannel(th.BasicPrivateChannel.Id, patch)
CheckNoError(t, resp)
+
+ // Test updating the header of someone else's GM channel.
+ user1 := th.CreateUser()
+ user2 := th.CreateUser()
+ user3 := th.CreateUser()
+
+ groupChannel, resp := Client.CreateGroupChannel([]string{user1.Id, user2.Id})
+ CheckNoError(t, resp)
+
+ Client.Logout()
+ Client.Login(user3.Email, user3.Password)
+
+ channelPatch := &model.ChannelPatch{}
+ channelPatch.Header = new(string)
+ *channelPatch.Header = "lolololol"
+
+ _, resp = Client.PatchChannel(groupChannel.Id, channelPatch)
+ CheckForbiddenStatus(t, resp)
+
+ // Test updating the header of someone else's GM channel.
+ Client.Logout()
+ Client.Login(user.Email, user.Password)
+
+ directChannel, resp := Client.CreateDirectChannel(user.Id, user1.Id)
+ CheckNoError(t, resp)
+
+ Client.Logout()
+ Client.Login(user3.Email, user3.Password)
+ _, resp = Client.PatchChannel(directChannel.Id, channelPatch)
+ CheckForbiddenStatus(t, resp)
}
func TestCreateDirectChannel(t *testing.T) {