коммит произвёл
GitHub
родитель
532f2882d1
Коммит
450dba8cad
@@ -1641,6 +1641,29 @@ func TestUpdatePost(t *testing.T) {
|
||||
assert.Contains(t, updatedPost.FileIds, fileId)
|
||||
})
|
||||
|
||||
t.Run("should prevent editing when create_post permission is revoked", func(t *testing.T) {
|
||||
th.LoginBasic()
|
||||
|
||||
postToEdit, _, appErr := th.App.CreatePost(th.Context, &model.Post{
|
||||
UserId: th.BasicUser.Id,
|
||||
ChannelId: channel.Id,
|
||||
Message: "original message",
|
||||
}, channel, model.CreatePostFlags{SetOnline: true})
|
||||
require.Nil(t, appErr)
|
||||
|
||||
th.RemovePermissionFromRole(model.PermissionCreatePost.Id, model.ChannelUserRoleId)
|
||||
defer th.AddPermissionToRole(model.PermissionCreatePost.Id, model.ChannelUserRoleId)
|
||||
|
||||
updatePost := &model.Post{
|
||||
Id: postToEdit.Id,
|
||||
ChannelId: channel.Id,
|
||||
Message: "edited message",
|
||||
}
|
||||
_, resp, err := client.UpdatePost(context.Background(), postToEdit.Id, updatePost)
|
||||
require.Error(t, err)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("logged out", func(t *testing.T) {
|
||||
_, err := client.Logout(context.Background())
|
||||
require.NoError(t, err)
|
||||
@@ -2027,6 +2050,27 @@ func TestPatchPost(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("should prevent patching when create_post permission is revoked", func(t *testing.T) {
|
||||
th.LoginBasic()
|
||||
|
||||
postToEdit, _, err := client.CreatePost(context.Background(), &model.Post{
|
||||
ChannelId: channel.Id,
|
||||
Message: "original message",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
defaultPerms := th.SaveDefaultRolePermissions()
|
||||
defer th.RestoreDefaultRolePermissions(defaultPerms)
|
||||
th.RemovePermissionFromRole(model.PermissionCreatePost.Id, model.ChannelUserRoleId)
|
||||
|
||||
patch := &model.PostPatch{
|
||||
Message: model.NewPointer("edited message"),
|
||||
}
|
||||
_, resp, err := client.PatchPost(context.Background(), postToEdit.Id, patch)
|
||||
require.Error(t, err)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("time limit expired", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.PostEditTimeLimit = 1
|
||||
|
||||
Ссылка в новой задаче
Block a user