summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJesús Espino <jespinog@gmail.com>2018-02-09 16:31:01 +0100
committerMartin Kraft <mkraft@users.noreply.github.com>2018-02-09 10:31:01 -0500
commit0aa7ecd5e89f054ae927b246f2aec4bd6348d42b (patch)
tree1944001594c05731acfb998fc3840d2de456e511 /api
parent96ffde43dc5dccef7af106dc8200566ff16ba1dc (diff)
downloadchat-0aa7ecd5e89f054ae927b246f2aec4bd6348d42b.tar.gz
chat-0aa7ecd5e89f054ae927b246f2aec4bd6348d42b.tar.bz2
chat-0aa7ecd5e89f054ae927b246f2aec4bd6348d42b.zip
AllowEditPost and PostEditTimeLimit migration (#8208)
* AllowEditPost and PostEditTimeLimit migration * Not set EDIT_POST permission to sysadmin_role if ALLOW_EDIT_POST is configured to NEVER * Remove a bit of code duplication
Diffstat (limited to 'api')
-rw-r--r--api/post_test.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/api/post_test.go b/api/post_test.go
index fe0c2a6b7..b88c733db 100644
--- a/api/post_test.go
+++ b/api/post_test.go
@@ -395,7 +395,13 @@ func TestUpdatePost(t *testing.T) {
Client := th.BasicClient
channel1 := th.BasicChannel
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS })
+ // Check the appropriate permissions are enforced.
+ defaultRolePermissions := th.SaveDefaultRolePermissions()
+ defer func() {
+ th.RestoreDefaultRolePermissions(defaultRolePermissions)
+ }()
+
+ th.AddPermissionToRole(model.PERMISSION_EDIT_POST.Id, model.CHANNEL_USER_ROLE_ID)
post1 := &model.Post{ChannelId: channel1.Id, Message: "zz" + model.NewId() + "a"}
rpost1, err := Client.CreatePost(post1)
@@ -474,8 +480,7 @@ func TestUpdatePost(t *testing.T) {
utils.SetLicense(&model.License{Features: &model.Features{}})
utils.License().Features.SetDefaults()
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_NEVER })
-
+ th.RemovePermissionFromRole(model.PERMISSION_EDIT_POST.Id, model.CHANNEL_USER_ROLE_ID)
post4 := &model.Post{ChannelId: channel1.Id, Message: "zz" + model.NewId() + "a", RootId: rpost1.Data.(*model.Post).Id}
rpost4, err := Client.CreatePost(post4)
if err != nil {
@@ -487,7 +492,7 @@ func TestUpdatePost(t *testing.T) {
t.Fatal("shouldn't have been able to update a message when not allowed")
}
- th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_TIME_LIMIT })
+ th.AddPermissionToRole(model.PERMISSION_EDIT_POST.Id, model.CHANNEL_USER_ROLE_ID)
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.PostEditTimeLimit = 1 }) //seconds
post5 := &model.Post{ChannelId: channel1.Id, Message: "zz" + model.NewId() + "a", RootId: rpost1.Data.(*model.Post).Id}