summaryrefslogtreecommitdiffstats
path: root/api4/channel_test.go
diff options
context:
space:
mode:
authorMartin Kraft <martinkraft@gmail.com>2018-04-24 10:21:18 -0400
committerMartin Kraft <martinkraft@gmail.com>2018-04-24 10:21:18 -0400
commit7294644e9d74ca1512a730c597d61a97ccbcf10c (patch)
tree36cad0e1782b2e6bc06aab3e7afc54d45579d271 /api4/channel_test.go
parentcd55c44c8fd8f61cdb7cbfb57a588be82c7aa0ab (diff)
parent3224d2f6a3bd95293fff25d6cc417b30b4f6e334 (diff)
downloadchat-7294644e9d74ca1512a730c597d61a97ccbcf10c.tar.gz
chat-7294644e9d74ca1512a730c597d61a97ccbcf10c.tar.bz2
chat-7294644e9d74ca1512a730c597d61a97ccbcf10c.zip
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2
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 0603afe74..c3d8c8039 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()