summaryrefslogtreecommitdiffstats
path: root/api4/post_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'api4/post_test.go')
-rw-r--r--api4/post_test.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/api4/post_test.go b/api4/post_test.go
index 53babc6e6..f136ba676 100644
--- a/api4/post_test.go
+++ b/api4/post_test.go
@@ -302,6 +302,61 @@ func TestCreatePostPublic(t *testing.T) {
CheckNoError(t, resp)
}
+func TestCreatePostAll(t *testing.T) {
+ th := Setup().InitBasic().InitSystemAdmin()
+ defer TearDown()
+ Client := th.Client
+
+ post := &model.Post{ChannelId: th.BasicChannel.Id, Message: "#hashtag a" + model.NewId() + "a"}
+
+ user := model.User{Email: GenerateTestEmail(), Nickname: "Joram Wilander", Password: "hello1", Username: GenerateTestUsername(), Roles: model.ROLE_SYSTEM_USER.Id}
+
+ directChannel, _ := app.CreateDirectChannel(th.BasicUser.Id, th.BasicUser2.Id)
+
+ ruser, resp := Client.CreateUser(&user)
+ CheckNoError(t, resp)
+
+ Client.Login(user.Email, user.Password)
+
+ _, resp = Client.CreatePost(post)
+ CheckForbiddenStatus(t, resp)
+
+ app.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id+" "+model.ROLE_SYSTEM_POST_ALL.Id)
+ app.InvalidateAllCaches()
+
+ Client.Login(user.Email, user.Password)
+
+ _, resp = Client.CreatePost(post)
+ CheckNoError(t, resp)
+
+ post.ChannelId = th.BasicPrivateChannel.Id
+ _, resp = Client.CreatePost(post)
+ CheckNoError(t, resp)
+
+ post.ChannelId = directChannel.Id
+ _, resp = Client.CreatePost(post)
+ CheckNoError(t, resp)
+
+ app.UpdateUserRoles(ruser.Id, model.ROLE_SYSTEM_USER.Id)
+ app.JoinUserToTeam(th.BasicTeam, ruser, "")
+ app.UpdateTeamMemberRoles(th.BasicTeam.Id, ruser.Id, model.ROLE_TEAM_USER.Id+" "+model.ROLE_TEAM_POST_ALL.Id)
+ app.InvalidateAllCaches()
+
+ Client.Login(user.Email, user.Password)
+
+ post.ChannelId = th.BasicPrivateChannel.Id
+ _, resp = Client.CreatePost(post)
+ CheckNoError(t, resp)
+
+ post.ChannelId = th.BasicChannel.Id
+ _, resp = Client.CreatePost(post)
+ CheckNoError(t, resp)
+
+ post.ChannelId = directChannel.Id
+ _, resp = Client.CreatePost(post)
+ CheckForbiddenStatus(t, resp)
+}
+
func TestUpdatePost(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
defer TearDown()