diff options
Diffstat (limited to 'api4/post_test.go')
-rw-r--r-- | api4/post_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/api4/post_test.go b/api4/post_test.go index bfc0c286a..abfd83989 100644 --- a/api4/post_test.go +++ b/api4/post_test.go @@ -752,6 +752,23 @@ func TestGetPost(t *testing.T) { CheckBadRequestStatus(t, resp) _, resp = Client.GetPost(model.NewId(), "") + CheckNotFoundStatus(t, resp) + + Client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser.Id) + + // Channel is public, should be able to read post + post, resp = Client.GetPost(th.BasicPost.Id, "") + CheckNoError(t, resp) + + privatePost := th.CreatePostWithClient(Client, th.BasicPrivateChannel) + + post, resp = Client.GetPost(privatePost.Id, "") + CheckNoError(t, resp) + + Client.RemoveUserFromChannel(th.BasicPrivateChannel.Id, th.BasicUser.Id) + + // Channel is private, should not be able to read post + post, resp = Client.GetPost(privatePost.Id, "") CheckForbiddenStatus(t, resp) Client.Logout() @@ -831,6 +848,23 @@ func TestGetPostThread(t *testing.T) { CheckBadRequestStatus(t, resp) _, resp = Client.GetPostThread(model.NewId(), "") + CheckNotFoundStatus(t, resp) + + Client.RemoveUserFromChannel(th.BasicChannel.Id, th.BasicUser.Id) + + // Channel is public, should be able to read post + _, resp = Client.GetPostThread(th.BasicPost.Id, "") + CheckNoError(t, resp) + + privatePost := th.CreatePostWithClient(Client, th.BasicPrivateChannel) + + _, resp = Client.GetPostThread(privatePost.Id, "") + CheckNoError(t, resp) + + Client.RemoveUserFromChannel(th.BasicPrivateChannel.Id, th.BasicUser.Id) + + // Channel is private, should not be able to read post + _, resp = Client.GetPostThread(privatePost.Id, "") CheckForbiddenStatus(t, resp) Client.Logout() |