Fix panic when receiving a config to update to if some settings are not set (#13889)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5f7b5686a8
Коммит
dd1c8c22dc
@@ -57,6 +57,8 @@ func updateConfig(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg.SetDefaults()
|
||||||
|
|
||||||
if !c.App.SessionHasPermissionTo(*c.App.Session(), model.PERMISSION_MANAGE_SYSTEM) {
|
if !c.App.SessionHasPermissionTo(*c.App.Session(), model.PERMISSION_MANAGE_SYSTEM) {
|
||||||
c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
|
c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -103,6 +103,11 @@ func TestUpdateConfig(t *testing.T) {
|
|||||||
|
|
||||||
require.Equal(t, SiteName, cfg.TeamSettings.SiteName, "It should update the SiteName")
|
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) {
|
t.Run("Should fail with validation error if invalid config setting is passed", func(t *testing.T) {
|
||||||
//Revert the change
|
//Revert the change
|
||||||
badcfg := cfg.Clone()
|
badcfg := cfg.Clone()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user