[MM-38082] Add local-mode handler for config reload endpoint (#18252)
* Add local-mode handler for config reload endpoint * Remove redundant method
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3048f5d435
Коммит
ddfa6e2436
@@ -86,12 +86,15 @@ func configReload(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if *c.App.Config().ExperimentalSettings.RestrictSystemAdmin {
|
if !c.AppContext.Session().IsUnrestricted() && *c.App.Config().ExperimentalSettings.RestrictSystemAdmin {
|
||||||
c.Err = model.NewAppError("configReload", "api.restricted_system_admin", nil, "", http.StatusBadRequest)
|
c.Err = model.NewAppError("configReload", "api.restricted_system_admin", nil, "", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.App.ReloadConfig()
|
if err := c.App.ReloadConfig(); err != nil {
|
||||||
|
c.Err = model.NewAppError("configReload", "api.config.reload_config.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
auditRec.Success()
|
auditRec.Success()
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ func (api *API) InitConfigLocal() {
|
|||||||
api.BaseRoutes.APIRoot.Handle("/config", api.APILocal(localGetConfig)).Methods("GET")
|
api.BaseRoutes.APIRoot.Handle("/config", api.APILocal(localGetConfig)).Methods("GET")
|
||||||
api.BaseRoutes.APIRoot.Handle("/config", api.APILocal(localUpdateConfig)).Methods("PUT")
|
api.BaseRoutes.APIRoot.Handle("/config", api.APILocal(localUpdateConfig)).Methods("PUT")
|
||||||
api.BaseRoutes.APIRoot.Handle("/config/patch", api.APILocal(localPatchConfig)).Methods("PUT")
|
api.BaseRoutes.APIRoot.Handle("/config/patch", api.APILocal(localPatchConfig)).Methods("PUT")
|
||||||
|
api.BaseRoutes.APIRoot.Handle("/config/reload", api.APILocal(configReload)).Methods("POST")
|
||||||
api.BaseRoutes.APIRoot.Handle("/config/migrate", api.APILocal(migrateConfig)).Methods("POST")
|
api.BaseRoutes.APIRoot.Handle("/config/migrate", api.APILocal(migrateConfig)).Methods("POST")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,10 +126,10 @@ func TestReloadConfig(t *testing.T) {
|
|||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("as system admin", func(t *testing.T) {
|
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||||
_, err := th.SystemAdminClient.ReloadConfig()
|
_, err := client.ReloadConfig()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
}, "as system admin and local mode")
|
||||||
|
|
||||||
t.Run("as restricted system admin", func(t *testing.T) {
|
t.Run("as restricted system admin", func(t *testing.T) {
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ExperimentalSettings.RestrictSystemAdmin = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ExperimentalSettings.RestrictSystemAdmin = true })
|
||||||
|
|||||||
@@ -1462,6 +1462,10 @@
|
|||||||
"id": "api.config.patch_config.restricted_merge.app_error",
|
"id": "api.config.patch_config.restricted_merge.app_error",
|
||||||
"translation": "Failed to merge given config."
|
"translation": "Failed to merge given config."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "api.config.reload_config.app_error",
|
||||||
|
"translation": "Failed to reload config."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.config.update_config.clear_siteurl.app_error",
|
"id": "api.config.update_config.clear_siteurl.app_error",
|
||||||
"translation": "Site URL cannot be cleared."
|
"translation": "Site URL cannot be cleared."
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user