MM-52981, MM-53559: Streamlined in-product marketplace (#24311)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d57581d01e
Коммит
818225dffe
@@ -462,6 +462,9 @@ func TestDisableOnRemove(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetMarketplacePlugins(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
||||
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -682,6 +685,9 @@ func TestGetMarketplacePlugins(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetInstalledMarketplacePlugins(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
||||
|
||||
samplePlugins := []*model.MarketplacePlugin{
|
||||
{
|
||||
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
|
||||
@@ -825,6 +831,9 @@ func TestGetInstalledMarketplacePlugins(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchGetMarketplacePlugins(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
||||
|
||||
samplePlugins := []*model.MarketplacePlugin{
|
||||
{
|
||||
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
|
||||
@@ -950,6 +959,9 @@ func TestSearchGetMarketplacePlugins(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetLocalPluginInMarketplace(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
||||
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1111,6 +1123,9 @@ func TestGetLocalPluginInMarketplace(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetRemotePluginInMarketplace(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
||||
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1166,7 +1181,70 @@ func TestGetRemotePluginInMarketplace(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestRemoteMarketplaceDisabledByStreamlinedMarketplaceFlag(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "true")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
||||
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
marketplacePlugins := []*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: "marketplace.test",
|
||||
Name: "marketplacetest",
|
||||
Description: "a marketplace plugin",
|
||||
Version: "0.1.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{marketplacePlugins[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
|
||||
})
|
||||
|
||||
prepackagePlugin := &plugin.PrepackagedPlugin{
|
||||
Manifest: &model.Manifest{
|
||||
Version: "0.0.1",
|
||||
Id: "prepackaged.test",
|
||||
},
|
||||
}
|
||||
|
||||
env := th.App.GetPluginsEnvironment()
|
||||
env.SetPrepackagedPlugins([]*plugin.PrepackagedPlugin{prepackagePlugin}, nil)
|
||||
|
||||
// No marketplace plugins returned
|
||||
plugins, _, err := th.SystemAdminClient.GetMarketplacePlugins(context.Background(), &model.MarketplacePluginFilter{})
|
||||
require.NoError(t, err)
|
||||
|
||||
// Only returns the prepackaged plugins
|
||||
require.Len(t, plugins, 1)
|
||||
require.Equal(t, prepackagePlugin.Manifest, plugins[0].Manifest)
|
||||
}
|
||||
|
||||
func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
||||
|
||||
th := Setup(t)
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1212,6 +1290,30 @@ func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
|
||||
env := th.App.GetPluginsEnvironment()
|
||||
env.SetPrepackagedPlugins([]*plugin.PrepackagedPlugin{prepackagePlugin}, nil)
|
||||
|
||||
t.Run("prepackaged plugins are shown in Cloud", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.EnableRemoteMarketplace = true
|
||||
*cfg.PluginSettings.EnableUploads = true
|
||||
})
|
||||
|
||||
lic := th.App.Srv().License()
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
defer th.App.Srv().SetLicense(lic)
|
||||
|
||||
plugins, _, err := th.SystemAdminClient.GetMarketplacePlugins(context.Background(), &model.MarketplacePluginFilter{})
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedPlugins := marketplacePlugins
|
||||
expectedPlugins = append(expectedPlugins, &model.MarketplacePlugin{
|
||||
BaseMarketplacePlugin: &model.BaseMarketplacePlugin{
|
||||
Manifest: prepackagePlugin.Manifest,
|
||||
},
|
||||
})
|
||||
|
||||
require.ElementsMatch(t, expectedPlugins, plugins)
|
||||
require.Len(t, plugins, 2)
|
||||
})
|
||||
|
||||
t.Run("get remote and prepackaged plugins", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.EnableRemoteMarketplace = true
|
||||
@@ -1271,24 +1373,12 @@ func TestGetPrepackagedPluginInMarketplace(t *testing.T) {
|
||||
require.Len(t, plugins, 1)
|
||||
require.Equal(t, newerPrepackagePlugin.Manifest, plugins[0].Manifest)
|
||||
})
|
||||
|
||||
t.Run("prepackaged plugins are not shown in Cloud", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.EnableRemoteMarketplace = true
|
||||
*cfg.PluginSettings.EnableUploads = true
|
||||
})
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
|
||||
plugins, _, err := th.SystemAdminClient.GetMarketplacePlugins(context.Background(), &model.MarketplacePluginFilter{})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.ElementsMatch(t, marketplacePlugins, plugins)
|
||||
require.Len(t, plugins, 1)
|
||||
})
|
||||
}
|
||||
|
||||
func TestInstallMarketplacePlugin(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
||||
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
@@ -1639,6 +1729,9 @@ func TestInstallMarketplacePlugin(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInstallMarketplacePluginPrepackagedDisabled(t *testing.T) {
|
||||
os.Setenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE", "false")
|
||||
defer os.Unsetenv("MM_FEATUREFLAGS_STREAMLINEDMARKETPLACE")
|
||||
|
||||
path, _ := fileutils.FindDir("tests")
|
||||
|
||||
signatureFilename := "testplugin2.tar.gz.sig"
|
||||
|
||||
Ссылка в новой задаче
Block a user