Fix panic when receiving a config to update to if some settings are not set (#13889)

Этот коммит содержится в:
Joram Wilander
2020-02-13 14:26:57 -05:00
коммит произвёл GitHub
родитель 5f7b5686a8
Коммит dd1c8c22dc
2 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@@ -57,6 +57,8 @@ func updateConfig(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
cfg.SetDefaults()
if !c.App.SessionHasPermissionTo(*c.App.Session(), model.PERMISSION_MANAGE_SYSTEM) {
c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
return

Просмотреть файл

@@ -103,6 +103,11 @@ func TestUpdateConfig(t *testing.T) {
require.Equal(t, SiteName, cfg.TeamSettings.SiteName, "It should update the SiteName")
t.Run("Should set defaults for missing fields", func(t *testing.T) {
_, appErr := th.SystemAdminClient.DoApiPut(th.SystemAdminClient.GetConfigRoute(), `{"ServiceSettings":{}}`)
require.Nil(t, appErr)
})
t.Run("Should fail with validation error if invalid config setting is passed", func(t *testing.T) {
//Revert the change
badcfg := cfg.Clone()