[MM-49929] Work templates: allow simple users to list marketplace plugins (#22151)
Этот коммит содержится в:
@@ -1126,6 +1126,62 @@ func TestGetLocalPluginInMarketplace(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetRemotePluginInMarketplace(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
samplePlugins := []*model.MarketplacePlugin{
|
||||
{
|
||||
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
|
||||
HomepageURL: "https://example.com/mattermost/mattermost-plugin-nps",
|
||||
IconData: "https://example.com/icon.svg",
|
||||
DownloadURL: "www.github.com/example",
|
||||
Manifest: &model.Manifest{
|
||||
Id: "testplugin2",
|
||||
Name: "testplugin2",
|
||||
Description: "a second plugin",
|
||||
Version: "1.2.2",
|
||||
MinServerVersion: "",
|
||||
},
|
||||
},
|
||||
InstalledVersion: "",
|
||||
},
|
||||
}
|
||||
|
||||
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
res.WriteHeader(http.StatusOK)
|
||||
json, err := json.Marshal([]*model.MarketplacePlugin{samplePlugins[0]})
|
||||
require.NoError(t, err)
|
||||
res.Write(json)
|
||||
}))
|
||||
defer testServer.Close()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.Enable = true
|
||||
*cfg.PluginSettings.EnableMarketplace = true
|
||||
*cfg.PluginSettings.EnableRemoteMarketplace = true
|
||||
*cfg.PluginSettings.EnableUploads = true
|
||||
*cfg.PluginSettings.MarketplaceURL = testServer.URL
|
||||
})
|
||||
|
||||
// Upload one local plugin
|
||||
path, _ := fileutils.FindDir("tests")
|
||||
tarData, err := os.ReadFile(filepath.Join(path, "testplugin.tar.gz"))
|
||||
require.NoError(t, err)
|
||||
|
||||
manifest, _, err := th.SystemAdminClient.UploadPlugin(bytes.NewReader(tarData))
|
||||
require.NoError(t, err)
|
||||
|
||||
plugins, _, err := th.SystemAdminClient.GetMarketplacePlugins(&model.MarketplacePluginFilter{RemoteOnly: true})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, plugins, 1)
|
||||
require.Equal(t, samplePlugins[0], plugins[0])
|
||||
|
||||
_, err = th.SystemAdminClient.RemovePlugin(manifest.Id)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
Ссылка в новой задаче
Block a user