summaryrefslogtreecommitdiffstats
path: root/api4/channel_test.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2018-04-23 20:18:58 +0800
committerJoram Wilander <jwawilander@gmail.com>2018-04-23 08:18:58 -0400
commit3224d2f6a3bd95293fff25d6cc417b30b4f6e334 (patch)
tree43ee308651d3a8e969ff550d6ae74a587de7bf01 /api4/channel_test.go
parent853445dc2ea68f765faa04ad14618b04f1081c43 (diff)
downloadchat-3224d2f6a3bd95293fff25d6cc417b30b4f6e334.tar.gz
chat-3224d2f6a3bd95293fff25d6cc417b30b4f6e334.tar.bz2
chat-3224d2f6a3bd95293fff25d6cc417b30b4f6e334.zip
add api to convert a channel from public to private and restrict that to system_admin (#8655)
Diffstat (limited to 'api4/channel_test.go')
-rw-r--r--api4/channel_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/api4/channel_test.go b/api4/channel_test.go
index 4c27e040a..767fdbdb8 100644
--- a/api4/channel_test.go
+++ b/api4/channel_test.go
@@ -897,6 +897,46 @@ func TestDeleteChannel(t *testing.T) {
CheckForbiddenStatus(t, resp)
}
+func TestConvertChannelToPrivate(t *testing.T) {
+ th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+ Client := th.Client
+
+ defaultChannel, _ := th.App.GetChannelByName(model.DEFAULT_CHANNEL, th.BasicTeam.Id)
+ _, resp := Client.ConvertChannelToPrivate(defaultChannel.Id)
+ CheckForbiddenStatus(t, resp)
+
+ privateChannel := th.CreatePrivateChannel()
+ _, resp = Client.ConvertChannelToPrivate(privateChannel.Id)
+ CheckForbiddenStatus(t, resp)
+
+ publicChannel := th.CreatePublicChannel()
+ _, resp = Client.ConvertChannelToPrivate(publicChannel.Id)
+ CheckForbiddenStatus(t, resp)
+
+ th.LoginTeamAdmin()
+ _, resp = Client.ConvertChannelToPrivate(publicChannel.Id)
+ CheckForbiddenStatus(t, resp)
+
+ rchannel, resp := th.SystemAdminClient.ConvertChannelToPrivate(privateChannel.Id)
+ CheckBadRequestStatus(t, resp)
+ if rchannel != nil {
+ t.Fatal("should not return a channel")
+ }
+
+ rchannel, resp = th.SystemAdminClient.ConvertChannelToPrivate(defaultChannel.Id)
+ CheckBadRequestStatus(t, resp)
+ if rchannel != nil {
+ t.Fatal("should not return a channel")
+ }
+
+ rchannel, resp = th.SystemAdminClient.ConvertChannelToPrivate(publicChannel.Id)
+ CheckOKStatus(t, resp)
+ if rchannel.Type != model.CHANNEL_PRIVATE {
+ t.Fatal("channel should be converted from public to private")
+ }
+}
+
func TestRestoreChannel(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer th.TearDown()