[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>
This commit is contained in:
Shota Gvinepadze
2020-01-27 17:12:16 +04:00
committed by GitHub
parent f0934361a1
commit 1e9556cc28
2 changed files with 6 additions and 1 deletions

View File

@@ -85,7 +85,9 @@ func uploadPlugin(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)
return
}

View File

@@ -145,6 +145,9 @@ func TestPlugin(t *testing.T) {
_, resp = th.SystemAdminClient.UploadPlugin(bytes.NewReader(tarData))
CheckNotImplementedStatus(t, resp)
_, resp = th.SystemAdminClient.InstallPluginFromUrl(url, false)
CheckNotImplementedStatus(t, resp)
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.EnableUploads = true })
_, resp = th.Client.UploadPlugin(bytes.NewReader(tarData))
CheckForbiddenStatus(t, resp)