summaryrefslogtreecommitdiffstats
path: root/api/post_test.go
diff options
context:
space:
mode:
authorRachel Willmer <rachel@willmer.org>2016-11-17 19:05:53 +0000
committerHarrison Healey <harrisonmhealey@gmail.com>2016-11-17 14:05:53 -0500
commita25afb113489bcdd3fd07cb6dc4c18ae70662795 (patch)
treebab7e41eb37b30d1653fdcc70ba62277bf8e06a2 /api/post_test.go
parent6d2882f6e70bc1c8794e0193a574dfe254b57d79 (diff)
downloadchat-a25afb113489bcdd3fd07cb6dc4c18ae70662795.tar.gz
chat-a25afb113489bcdd3fd07cb6dc4c18ae70662795.tar.bz2
chat-a25afb113489bcdd3fd07cb6dc4c18ae70662795.zip
Fix SystemAdmin use of CreateAt in CreatePost API (#4349) (#4408)
Diffstat (limited to 'api/post_test.go')
-rw-r--r--api/post_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/api/post_test.go b/api/post_test.go
index 0bafb5d20..bedb3aa74 100644
--- a/api/post_test.go
+++ b/api/post_test.go
@@ -138,6 +138,37 @@ func TestCreatePost(t *testing.T) {
}
}
+func TestCreatePostWithCreateAt(t *testing.T) {
+
+ // An ordinary user cannot use CreateAt
+
+ th := Setup().InitBasic()
+ Client := th.BasicClient
+ channel1 := th.BasicChannel
+
+ post := &model.Post{
+ ChannelId: channel1.Id,
+ Message: "PLT-4349",
+ CreateAt: 1234,
+ }
+ if resp, err := Client.CreatePost(post); err != nil {
+ t.Fatal(err)
+ } else if rpost := resp.Data.(*model.Post); rpost.CreateAt == post.CreateAt {
+ t.Fatal("post should be created with default CreateAt timestamp for ordinary user")
+ }
+
+ // But a System Admin user can
+
+ th2 := Setup().InitSystemAdmin()
+ SysClient := th2.SystemAdminClient
+
+ if resp, err := SysClient.CreatePost(post); err != nil {
+ t.Fatal(err)
+ } else if rpost := resp.Data.(*model.Post); rpost.CreateAt != post.CreateAt {
+ t.Fatal("post should be created with provided CreateAt timestamp for System Admin user")
+ }
+}
+
func testCreatePostWithOutgoingHook(
t *testing.T,
hookContentType string,