[MM-47489] Move Shared Channels (Experimental) to Professional (#21882)
* Move shared channels to professional license * Remove references to SharedChannels from license and use license SKU instead * add tests * Refactor shared channels license check and add tests * Re-add removed negation on license check Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
@@ -595,7 +595,7 @@ func (s *Server) startInterClusterServices(license *model.License) error {
|
|||||||
// Shared Channels service
|
// Shared Channels service
|
||||||
|
|
||||||
// License check
|
// License check
|
||||||
if !*license.Features.SharedChannels {
|
if !license.HasSharedChannels() {
|
||||||
mlog.Debug("License does not have shared channels enabled")
|
mlog.Debug("License does not have shared channels enabled")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ func GenerateClientConfig(c *model.Config, telemetryID string, license *model.Li
|
|||||||
props["DataRetentionBoardsRetentionDays"] = strconv.FormatInt(int64(*c.DataRetentionSettings.BoardsRetentionDays), 10)
|
props["DataRetentionBoardsRetentionDays"] = strconv.FormatInt(int64(*c.DataRetentionSettings.BoardsRetentionDays), 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *license.Features.SharedChannels {
|
if license.HasSharedChannels() {
|
||||||
props["ExperimentalSharedChannels"] = strconv.FormatBool(*c.ExperimentalSettings.EnableSharedChannels)
|
props["ExperimentalSharedChannels"] = strconv.FormatBool(*c.ExperimentalSettings.EnableSharedChannels)
|
||||||
props["ExperimentalRemoteClusterService"] = strconv.FormatBool(c.FeatureFlags.EnableRemoteClusterService && *c.ExperimentalSettings.EnableRemoteClusterService)
|
props["ExperimentalRemoteClusterService"] = strconv.FormatBool(c.FeatureFlags.EnableRemoteClusterService && *c.ExperimentalSettings.EnableRemoteClusterService)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -254,6 +254,78 @@ func TestGetClientConfig(t *testing.T) {
|
|||||||
"EnableCustomGroups": "false",
|
"EnableCustomGroups": "false",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"Shared channels other license",
|
||||||
|
&model.Config{
|
||||||
|
ExperimentalSettings: model.ExperimentalSettings{
|
||||||
|
EnableSharedChannels: model.NewBool(true),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"",
|
||||||
|
&model.License{
|
||||||
|
Features: &model.Features{
|
||||||
|
SharedChannels: model.NewBool(false),
|
||||||
|
},
|
||||||
|
SkuShortName: "other",
|
||||||
|
},
|
||||||
|
map[string]string{
|
||||||
|
"ExperimentalSharedChannels": "false",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"licensed for shared channels",
|
||||||
|
&model.Config{
|
||||||
|
ExperimentalSettings: model.ExperimentalSettings{
|
||||||
|
EnableSharedChannels: model.NewBool(true),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"",
|
||||||
|
&model.License{
|
||||||
|
Features: &model.Features{
|
||||||
|
SharedChannels: model.NewBool(true),
|
||||||
|
},
|
||||||
|
SkuShortName: "other",
|
||||||
|
},
|
||||||
|
map[string]string{
|
||||||
|
"ExperimentalSharedChannels": "true",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Shared channels professional license",
|
||||||
|
&model.Config{
|
||||||
|
ExperimentalSettings: model.ExperimentalSettings{
|
||||||
|
EnableSharedChannels: model.NewBool(true),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"",
|
||||||
|
&model.License{
|
||||||
|
Features: &model.Features{
|
||||||
|
SharedChannels: model.NewBool(false),
|
||||||
|
},
|
||||||
|
SkuShortName: model.LicenseShortSkuProfessional,
|
||||||
|
},
|
||||||
|
map[string]string{
|
||||||
|
"ExperimentalSharedChannels": "true",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Shared channels enterprise license",
|
||||||
|
&model.Config{
|
||||||
|
ExperimentalSettings: model.ExperimentalSettings{
|
||||||
|
EnableSharedChannels: model.NewBool(true),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"",
|
||||||
|
&model.License{
|
||||||
|
Features: &model.Features{
|
||||||
|
SharedChannels: model.NewBool(false),
|
||||||
|
},
|
||||||
|
SkuShortName: model.LicenseShortSkuEnterprise,
|
||||||
|
},
|
||||||
|
map[string]string{
|
||||||
|
"ExperimentalSharedChannels": "true",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
|
|||||||
@@ -312,6 +312,16 @@ func (l *License) HasEnterpriseMarketplacePlugins() bool {
|
|||||||
l.SkuShortName == LicenseShortSkuEnterprise
|
l.SkuShortName == LicenseShortSkuEnterprise
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *License) HasSharedChannels() bool {
|
||||||
|
if l == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return (l.Features != nil && l.Features.SharedChannels != nil && *l.Features.SharedChannels) ||
|
||||||
|
l.SkuShortName == LicenseShortSkuProfessional ||
|
||||||
|
l.SkuShortName == LicenseShortSkuEnterprise
|
||||||
|
}
|
||||||
|
|
||||||
// NewTestLicense returns a license that expires in the future and has the given features.
|
// NewTestLicense returns a license that expires in the future and has the given features.
|
||||||
func NewTestLicense(features ...string) *License {
|
func NewTestLicense(features ...string) *License {
|
||||||
ret := &License{
|
ret := &License{
|
||||||
|
|||||||
@@ -343,3 +343,53 @@ func TestLicense_IsSanctionedTrial(t *testing.T) {
|
|||||||
assert.True(t, license.IsSanctionedTrial())
|
assert.True(t, license.IsSanctionedTrial())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLicenseHasSharedChannels(t *testing.T) {
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
description string
|
||||||
|
license License
|
||||||
|
expectedValue bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"licensed for shared channels",
|
||||||
|
License{
|
||||||
|
Features: &Features{
|
||||||
|
SharedChannels: NewBool(true),
|
||||||
|
},
|
||||||
|
SkuShortName: "other",
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"not licensed for shared channels",
|
||||||
|
License{
|
||||||
|
Features: &Features{},
|
||||||
|
SkuShortName: "other",
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"professional license for shared channels",
|
||||||
|
License{
|
||||||
|
Features: &Features{},
|
||||||
|
SkuShortName: LicenseShortSkuProfessional,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enterprise license for shared channels",
|
||||||
|
License{
|
||||||
|
Features: &Features{},
|
||||||
|
SkuShortName: LicenseShortSkuEnterprise,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
t.Run(testCase.description, func(t *testing.T) {
|
||||||
|
assert.Equal(t, testCase.expectedValue, testCase.license.HasSharedChannels())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user