[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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
11513a8d0d
Коммит
d76039db23
@@ -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()
|
||||
|
||||
Ссылка в новой задаче
Block a user