Plugin framework: add ability to install other plugins to the… (#12232)
* add ability to upload other plugins to the plugin API * generated client rpc glue code * fix UploadPlugin API signature * generated plugin mocks * added upload plugin test * removed unused comment * using single line to call InstallPlugin with file Reader * fix minimum server version * added successful plugin upload test * renamed UploadPlugin to InstallPlugin
Этот коммит содержится в:
коммит произвёл
Ali Farooq
родитель
db97b49e7a
Коммит
d7ee3553fa
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/plugin"
|
||||
"github.com/mattermost/mattermost-server/services/mailservice"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
"github.com/mattermost/mattermost-server/utils/fileutils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -684,6 +685,43 @@ func TestPluginAPIGetPlugins(t *testing.T) {
|
||||
assert.Equal(t, pluginManifests, plugins)
|
||||
}
|
||||
|
||||
func TestPluginAPIInstallPlugin(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
api := th.SetupPluginAPI()
|
||||
|
||||
path, _ := fileutils.FindDir("tests")
|
||||
tarData, err := ioutil.ReadFile(filepath.Join(path, "testplugin.tar.gz"))
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = api.InstallPlugin(bytes.NewReader(tarData), true)
|
||||
assert.NotNil(t, err, "should not allow upload if upload disabled")
|
||||
assert.Equal(t, err.Error(), "installPlugin: Plugins and/or plugin uploads have been disabled., ")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.Enable = true
|
||||
*cfg.PluginSettings.EnableUploads = true
|
||||
})
|
||||
|
||||
manifest, err := api.InstallPlugin(bytes.NewReader(tarData), true)
|
||||
defer os.RemoveAll("plugins/testplugin")
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, "testplugin", manifest.Id)
|
||||
|
||||
// Successfully installed
|
||||
pluginsResp, err := api.GetPlugins()
|
||||
require.Nil(t, err)
|
||||
|
||||
found := false
|
||||
for _, m := range pluginsResp {
|
||||
if m.Id == manifest.Id {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
|
||||
assert.True(t, found)
|
||||
}
|
||||
|
||||
func TestPluginAPIGetTeamIcon(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user