summaryrefslogtreecommitdiffstats
path: root/api4/system_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-02-13 11:08:49 -0500
committerGitHub <noreply@github.com>2018-02-13 11:08:49 -0500
commit5c560db8102b8ce6dc29bf91ab5e24ca4af66fdf (patch)
tree6cd13db91ab4a768e33ba92e7f8a3cea71da4481 /api4/system_test.go
parentd88d2bc2ed3aefa68b5ed2942f493ae42bb40bfa (diff)
downloadchat-5c560db8102b8ce6dc29bf91ab5e24ca4af66fdf.tar.gz
chat-5c560db8102b8ce6dc29bf91ab5e24ca4af66fdf.tar.bz2
chat-5c560db8102b8ce6dc29bf91ab5e24ca4af66fdf.zip
ABC-176 Prevent changing PluginSettings.EnableUploads through the API (#8249)
* Prevent changing PluginSettings.EnableUploads through the API * Contain api4 test case in it's own test
Diffstat (limited to 'api4/system_test.go')
-rw-r--r--api4/system_test.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/api4/system_test.go b/api4/system_test.go
index 1b2bb5d99..01b4934ae 100644
--- a/api4/system_test.go
+++ b/api4/system_test.go
@@ -7,6 +7,7 @@ import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/mattermost-server/model"
+ "github.com/stretchr/testify/assert"
)
func TestGetPing(t *testing.T) {
@@ -106,9 +107,10 @@ func TestUpdateConfig(t *testing.T) {
defer th.TearDown()
Client := th.Client
- cfg := th.App.GetConfig()
+ cfg, resp := th.SystemAdminClient.GetConfig()
+ CheckNoError(t, resp)
- _, resp := Client.UpdateConfig(cfg)
+ _, resp = Client.UpdateConfig(cfg)
CheckForbiddenStatus(t, resp)
SiteName := th.App.Config().TeamSettings.SiteName
@@ -139,6 +141,22 @@ func TestUpdateConfig(t *testing.T) {
t.Fatal()
}
}
+
+ t.Run("Should not be able to modify PluginSettings.EnableUploads", func(t *testing.T) {
+ oldEnableUploads := *th.App.GetConfig().PluginSettings.EnableUploads
+ *cfg.PluginSettings.EnableUploads = !oldEnableUploads
+
+ cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
+ CheckNoError(t, resp)
+ assert.Equal(t, oldEnableUploads, *cfg.PluginSettings.EnableUploads)
+ assert.Equal(t, oldEnableUploads, *th.App.GetConfig().PluginSettings.EnableUploads)
+
+ cfg.PluginSettings.EnableUploads = nil
+ cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
+ CheckNoError(t, resp)
+ assert.Equal(t, oldEnableUploads, *cfg.PluginSettings.EnableUploads)
+ assert.Equal(t, oldEnableUploads, *th.App.GetConfig().PluginSettings.EnableUploads)
+ })
}
func TestGetOldClientConfig(t *testing.T) {