[MM-21572] Disable InstallFromUrl if EnableUploads is false (#13636)
* Disable InstallFromUrl if EnableUploads is false * Break into 3 seperate lines Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f0934361a1
Коммит
1e9556cc28
@@ -85,7 +85,9 @@ func uploadPlugin(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func installPluginFromUrl(c *Context, w http.ResponseWriter, r *http.Request) {
|
func installPluginFromUrl(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
if !*c.App.Config().PluginSettings.Enable || *c.App.Config().PluginSettings.RequirePluginSignature {
|
if !*c.App.Config().PluginSettings.Enable ||
|
||||||
|
*c.App.Config().PluginSettings.RequirePluginSignature ||
|
||||||
|
!*c.App.Config().PluginSettings.EnableUploads {
|
||||||
c.Err = model.NewAppError("installPluginFromUrl", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
c.Err = model.NewAppError("installPluginFromUrl", "app.plugin.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,9 @@ func TestPlugin(t *testing.T) {
|
|||||||
_, resp = th.SystemAdminClient.UploadPlugin(bytes.NewReader(tarData))
|
_, resp = th.SystemAdminClient.UploadPlugin(bytes.NewReader(tarData))
|
||||||
CheckNotImplementedStatus(t, resp)
|
CheckNotImplementedStatus(t, resp)
|
||||||
|
|
||||||
|
_, resp = th.SystemAdminClient.InstallPluginFromUrl(url, false)
|
||||||
|
CheckNotImplementedStatus(t, resp)
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.EnableUploads = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.EnableUploads = true })
|
||||||
_, resp = th.Client.UploadPlugin(bytes.NewReader(tarData))
|
_, resp = th.Client.UploadPlugin(bytes.NewReader(tarData))
|
||||||
CheckForbiddenStatus(t, resp)
|
CheckForbiddenStatus(t, resp)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user