PLT-7849 Add config setting to disable plugin uploads (#7666)
* Add config setting to disable plugin uploads * Update unit test
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5474cff0eb
Коммит
1d968eb55e
@@ -32,8 +32,8 @@ func (api *API) InitPlugin() {
|
||||
}
|
||||
|
||||
func uploadPlugin(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if !*c.App.Config().PluginSettings.Enable {
|
||||
c.Err = model.NewAppError("uploadPlugin", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
if !*c.App.Config().PluginSettings.Enable || !*c.App.Config().PluginSettings.EnableUploads {
|
||||
c.Err = model.NewAppError("uploadPlugin", "app.plugin.upload_disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,17 @@ func TestPlugin(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
enablePlugins := *th.App.Config().PluginSettings.Enable
|
||||
enableUploadPlugins := *th.App.Config().PluginSettings.EnableUploads
|
||||
defer func() {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = enablePlugins })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.Enable = enablePlugins
|
||||
*cfg.PluginSettings.EnableUploads = enableUploadPlugins
|
||||
})
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.Enable = true
|
||||
*cfg.PluginSettings.EnableUploads = true
|
||||
})
|
||||
|
||||
th.App.InitPlugins(pluginDir, webappDir)
|
||||
defer func() {
|
||||
@@ -61,7 +68,14 @@ func TestPlugin(t *testing.T) {
|
||||
_, resp = th.SystemAdminClient.UploadPlugin(file)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.Enable = true
|
||||
*cfg.PluginSettings.EnableUploads = false
|
||||
})
|
||||
_, resp = th.SystemAdminClient.UploadPlugin(file)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.EnableUploads = true })
|
||||
_, resp = th.Client.UploadPlugin(file)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user