MM-62500 - Apply Delete check on commands (#29896)

* apply delete check on commands, add tests

* combine tests

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Scott Bishel
2025-01-30 08:20:36 -07:00
коммит произвёл GitHub
родитель 1f34d784dd
Коммит f2af360401
3 изменённых файлов: 26 добавлений и 0 удалений

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

@@ -1140,4 +1140,21 @@ func TestExecuteCommandReadOnly(t *testing.T) {
_, resp, err = client.ExecuteCommandWithTeam(context.Background(), th.BasicChannel.Id, th.BasicChannel.TeamId, "/postcommand")
require.Error(t, err)
CheckForbiddenStatus(t, resp)
// Confirm that the command works when the channel is not read only - use different channel
_, resp, err = client.ExecuteCommandWithTeam(context.Background(), th.BasicChannel2.Id, th.BasicChannel2.TeamId, "/postcommand")
require.NoError(t, err)
CheckOKStatus(t, resp)
appErr = th.App.DeleteChannel(
th.Context,
th.BasicChannel2,
th.SystemAdminUser.Id,
)
require.Nil(t, appErr, "failed to delete channel")
// Confirm that the command fails when the channel is archived
_, resp, err = client.ExecuteCommandWithTeam(context.Background(), th.BasicChannel2.Id, th.BasicChannel2.TeamId, "/postcommand")
require.Error(t, err)
CheckBadRequestStatus(t, resp)
}