summaryrefslogtreecommitdiffstats
path: root/api4/post_test.go
diff options
context:
space:
mode:
authorDaniel Schalla <daniel@schalla.me>2018-04-17 14:20:47 +0200
committerJoram Wilander <jwawilander@gmail.com>2018-04-17 08:20:47 -0400
commit997df03ac1455785b7a39e40edcd67b3b3e86f9e (patch)
treee11a4f7712e0b5379c89cc415e0be1396b6057b9 /api4/post_test.go
parent3a4c7603b3ce35ab247b4dddaf7a2506375ba2c9 (diff)
downloadchat-997df03ac1455785b7a39e40edcd67b3b3e86f9e.tar.gz
chat-997df03ac1455785b7a39e40edcd67b3b3e86f9e.tar.bz2
chat-997df03ac1455785b7a39e40edcd67b3b3e86f9e.zip
Initial Commit of Ephemeral Message Support for System Admins (#8611)
Fixed Permission Test Fixed and extended ephemeral message tests; Removed Online/Activity Updates Set Create Time to current time gofmt
Diffstat (limited to 'api4/post_test.go')
-rw-r--r--api4/post_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/api4/post_test.go b/api4/post_test.go
index 1b682e38b..63d71b5bd 100644
--- a/api4/post_test.go
+++ b/api4/post_test.go
@@ -116,6 +116,47 @@ func TestCreatePost(t *testing.T) {
}
}
+func TestCreatePostEphemeral(t *testing.T) {
+ th := Setup().InitBasic().InitSystemAdmin()
+ defer th.TearDown()
+ Client := th.SystemAdminClient
+
+ ephemeralPost := &model.PostEphemeral{
+ UserID: th.BasicUser2.Id,
+ Post: &model.Post{ChannelId: th.BasicChannel.Id, Message: "a" + model.NewId() + "a", Props: model.StringInterface{model.PROPS_ADD_CHANNEL_MEMBER: "no good"}},
+ }
+
+ rpost, resp := Client.CreatePostEphemeral(ephemeralPost)
+ CheckNoError(t, resp)
+ CheckCreatedStatus(t, resp)
+
+ if rpost.Message != ephemeralPost.Post.Message {
+ t.Fatal("message didn't match")
+ }
+
+ if rpost.EditAt != 0 {
+ t.Fatal("newly created ephemeral post shouldn't have EditAt set")
+ }
+
+ if r, err := Client.DoApiPost("/posts/ephemeral", "garbage"); err == nil {
+ t.Fatal("should have errored")
+ } else {
+ if r.StatusCode != http.StatusBadRequest {
+ t.Log("actual: " + strconv.Itoa(r.StatusCode))
+ t.Log("expected: " + strconv.Itoa(http.StatusBadRequest))
+ t.Fatal("wrong status code")
+ }
+ }
+
+ Client.Logout()
+ _, resp = Client.CreatePostEphemeral(ephemeralPost)
+ CheckUnauthorizedStatus(t, resp)
+
+ Client = th.Client
+ rpost, resp = Client.CreatePostEphemeral(ephemeralPost)
+ CheckForbiddenStatus(t, resp)
+}
+
func testCreatePostWithOutgoingHook(
t *testing.T,
hookContentType, expectedContentType, message, triggerWord string,