[MM-29361] Send cloud flag with Marketplace requests (#15913)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3697f92045
Коммит
76f1bfb941
@@ -633,7 +633,57 @@ func TestGetMarketplacePlugins(t *testing.T) {
|
||||
plugins, resp := client.GetMarketplacePlugins(&model.MarketplacePluginFilter{})
|
||||
CheckNoError(t, resp)
|
||||
require.Empty(t, plugins)
|
||||
}, "verify EnterprisePlugins is false for E20")
|
||||
}, "verify EnterprisePlugins is true for E20")
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
cloud, ok := req.URL.Query()["cloud"]
|
||||
require.True(t, ok)
|
||||
require.Len(t, cloud, 1)
|
||||
require.Equal(t, "false", cloud[0])
|
||||
|
||||
res.WriteHeader(http.StatusOK)
|
||||
json, err := json.Marshal([]*model.MarketplacePlugin{})
|
||||
require.NoError(t, err)
|
||||
res.Write(json)
|
||||
}))
|
||||
defer func() { testServer.Close() }()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.EnableMarketplace = true
|
||||
*cfg.PluginSettings.MarketplaceUrl = testServer.URL
|
||||
})
|
||||
|
||||
plugins, resp := client.GetMarketplacePlugins(&model.MarketplacePluginFilter{})
|
||||
CheckNoError(t, resp)
|
||||
require.Empty(t, plugins)
|
||||
}, "verify EnterprisePlugins is false if there is no license")
|
||||
|
||||
th.TestForSystemAdminAndLocal(t, func(t *testing.T, client *model.Client4) {
|
||||
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
cloud, ok := req.URL.Query()["cloud"]
|
||||
require.True(t, ok)
|
||||
require.Len(t, cloud, 1)
|
||||
require.Equal(t, "true", cloud[0])
|
||||
|
||||
res.WriteHeader(http.StatusOK)
|
||||
json, err := json.Marshal([]*model.MarketplacePlugin{})
|
||||
require.NoError(t, err)
|
||||
res.Write(json)
|
||||
}))
|
||||
defer func() { testServer.Close() }()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PluginSettings.EnableMarketplace = true
|
||||
*cfg.PluginSettings.MarketplaceUrl = testServer.URL
|
||||
})
|
||||
|
||||
th.App.Srv().SetLicense(model.NewTestLicense("cloud"))
|
||||
|
||||
plugins, resp := client.GetMarketplacePlugins(&model.MarketplacePluginFilter{})
|
||||
CheckNoError(t, resp)
|
||||
require.Empty(t, plugins)
|
||||
}, "verify Cloud is true for cloud license")
|
||||
}
|
||||
|
||||
func TestGetInstalledMarketplacePlugins(t *testing.T) {
|
||||
|
||||
@@ -668,6 +668,10 @@ func (a *App) getBaseMarketplaceFilter() *model.MarketplacePluginFilter {
|
||||
filter.EnterprisePlugins = true
|
||||
}
|
||||
|
||||
if license != nil && *license.Features.Cloud {
|
||||
filter.Cloud = true
|
||||
}
|
||||
|
||||
if model.BuildEnterpriseReady == "true" {
|
||||
filter.BuildEnterpriseReady = true
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ type MarketplacePluginFilter struct {
|
||||
ServerVersion string
|
||||
BuildEnterpriseReady bool
|
||||
EnterprisePlugins bool
|
||||
Cloud bool
|
||||
LocalOnly bool
|
||||
Platform string
|
||||
}
|
||||
@@ -95,6 +96,7 @@ func (filter *MarketplacePluginFilter) ApplyToURL(u *url.URL) {
|
||||
q.Add("server_version", filter.ServerVersion)
|
||||
q.Add("build_enterprise_ready", strconv.FormatBool(filter.BuildEnterpriseReady))
|
||||
q.Add("enterprise_plugins", strconv.FormatBool(filter.EnterprisePlugins))
|
||||
q.Add("cloud", strconv.FormatBool(filter.Cloud))
|
||||
q.Add("local_only", strconv.FormatBool(filter.LocalOnly))
|
||||
q.Add("platform", filter.Platform)
|
||||
u.RawQuery = q.Encode()
|
||||
|
||||
Ссылка в новой задаче
Block a user