mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
add api to convert a channel from public to private and restrict that to system_admin (#8655)
This commit is contained in:
committed by
Joram Wilander
parent
853445dc2e
commit
3224d2f6a3
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user