[MM-25659] ability to permanent delete channel through client (#15202)

Summary

    Ability to permanent delete channel through client

Ticket Link

    https://mattermost.atlassian.net/browse/MM-25659
Этот коммит содержится в:
Ashish Bhate
2020-08-14 08:42:39 +00:00
коммит произвёл GitHub
родитель 11513a8d0d
Коммит d76039db23
7 изменённых файлов: 113 добавлений и 2 удалений

Просмотреть файл

@@ -1629,6 +1629,45 @@ func TestDeleteChannel2(t *testing.T) {
CheckForbiddenStatus(t, resp)
}
func TestPermanentDeleteChannel(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
enableAPIChannelDeletion := *th.App.Config().ServiceSettings.EnableAPIChannelDeletion
defer func() {
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableAPIChannelDeletion = &enableAPIChannelDeletion })
}()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableAPIChannelDeletion = false })
publicChannel1 := th.CreatePublicChannel()
t.Run("Permanent deletion not available through API if EnableAPIChannelDeletion is not set", func(t *testing.T) {
_, resp := th.SystemAdminClient.PermanentDeleteChannel(publicChannel1.Id)
CheckUnauthorizedStatus(t, resp)
})
t.Run("Permanent deletion available through local mode even if EnableAPIChannelDeletion is not set", func(t *testing.T) {
ok, resp := th.LocalClient.PermanentDeleteChannel(publicChannel1.Id)
CheckNoError(t, resp)
assert.True(t, ok)
})
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableAPIChannelDeletion = true })
th.TestForSystemAdminAndLocal(t, func(t *testing.T, c *model.Client4) {
publicChannel := th.CreatePublicChannel()
ok, resp := c.PermanentDeleteChannel(publicChannel.Id)
CheckNoError(t, resp)
assert.True(t, ok)
_, err := th.App.GetChannel(publicChannel.Id)
assert.NotNil(t, err)
ok, resp = c.PermanentDeleteChannel("junk")
CheckBadRequestStatus(t, resp)
require.False(t, ok, "should have returned false")
}, "Permanent deletion with EnableAPIChannelDeletion set")
}
func TestConvertChannelToPrivate(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()