[MM-42192] Include deleted posts in GetPost (#20358)

* Introduced include_deleted query param on get posts endpoint

* Update the correct func name in the comment.

Co-authored-by: santoniriccardo <santoni.riccardo@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Vishal
2022-06-06 13:29:42 +05:30
коммит произвёл GitHub
родитель 456299841a
Коммит 27fc14201f
16 изменённых файлов: 85 добавлений и 38 удалений

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

@@ -996,7 +996,7 @@ func TestPinPost(t *testing.T) {
_, err := client.PinPost(post.Id)
require.NoError(t, err)
rpost, appErr := th.App.GetSinglePost(post.Id)
rpost, appErr := th.App.GetSinglePost(post.Id, false)
require.Nil(t, appErr)
require.True(t, rpost.IsPinned, "failed to pin post")
@@ -1026,7 +1026,7 @@ func TestUnpinPost(t *testing.T) {
_, err := client.UnpinPost(pinnedPost.Id)
require.NoError(t, err)
rpost, appErr := th.App.GetSinglePost(pinnedPost.Id)
rpost, appErr := th.App.GetSinglePost(pinnedPost.Id, false)
require.Nil(t, appErr)
require.False(t, rpost.IsPinned)
@@ -2000,6 +2000,29 @@ func TestGetPost(t *testing.T) {
_, _, err = th.LocalClient.GetPost(privatePost.Id, "")
require.NoError(t, err)
// Delete post
th.SystemAdminClient.DeletePost(th.BasicPost.Id)
// Normal client should get 404 when trying to access deleted post normally
_, resp, err = client.GetPost(th.BasicPost.Id, "")
require.Error(t, err)
CheckNotFoundStatus(t, resp)
// Normal client should get unauthorized when trying to access deleted post
_, resp, err = client.GetPostIncludeDeleted(th.BasicPost.Id, "")
require.Error(t, err)
CheckForbiddenStatus(t, resp)
// System client should get 404 when trying to access deleted post normally
_, resp, err = th.SystemAdminClient.GetPost(th.BasicPost.Id, "")
require.Error(t, err)
CheckNotFoundStatus(t, resp)
// System client should be able to access deleted post with include_deleted param
post, _, err := th.SystemAdminClient.GetPostIncludeDeleted(th.BasicPost.Id, "")
require.NoError(t, err)
require.Equal(t, th.BasicPost.Id, post.Id)
client.Logout()
// Normal client should get unauthorized, but local client should get 404.