Reject mysql for enterprise advanced (#31164)
* reject MySQL with the enterprise advanced license If a user attempts to set an Enterprise Advanced License while configured with MySQL, reject the license. This SKU is not compatible with MYSQL. * fix trial typo * suppress trial banner if MySQL * Update server/channels/app/platform/license_test.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix types * suppress mysql from show start trial modal * Skip MySQL-incompatible tests for access control and channel banner features Skip the following tests when running with MySQL database: - Access control policy tests (create, get, delete, check/test expressions, search, assign/unassign, get channels) - Channel banner tests in TestPatchChannel and TestCanEditChannelBanner These features are not supported on MySQL and the tests would fail. Tests will continue to run normally on PostgreSQL. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Skip TestSearchChannelsForAccessControlPolicy subtest for MySQL Add MySQL skip logic to the "SearchChannelsForAccessControlPolicy with regular user" subtest as this access control feature is not supported on MySQL. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * reject trial license requests for MySQL * return false on sku + mysql match, even if logger is nil * Fix MySQL trial license tests to skip appropriately based on database driver 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f2bb82bc01
Коммит
70a42ffd5f
@@ -22,6 +22,10 @@ func TestCreateAccessControlPolicy(t *testing.T) {
|
||||
os.Unsetenv("MM_FEATUREFLAGS_ATTRIBUTEBASEDACCESSCONTROL")
|
||||
})
|
||||
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Access control tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
samplePolicy := &model.AccessControlPolicy{
|
||||
Type: model.AccessControlPolicyTypeChannel,
|
||||
Version: model.AccessControlPolicyVersionV0_1,
|
||||
@@ -89,6 +93,10 @@ func TestGetAccessControlPolicy(t *testing.T) {
|
||||
os.Unsetenv("MM_FEATUREFLAGS_ATTRIBUTEBASEDACCESSCONTROL")
|
||||
})
|
||||
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Access control tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
samplePolicy := &model.AccessControlPolicy{
|
||||
ID: model.NewId(),
|
||||
Type: model.AccessControlPolicyTypeChannel,
|
||||
@@ -152,6 +160,10 @@ func TestDeleteAccessControlPolicy(t *testing.T) {
|
||||
os.Unsetenv("MM_FEATUREFLAGS_ATTRIBUTEBASEDACCESSCONTROL")
|
||||
})
|
||||
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Access control tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
samplePolicyID := model.NewId()
|
||||
|
||||
t.Run("DeleteAccessControlPolicy without license", func(t *testing.T) {
|
||||
@@ -202,6 +214,10 @@ func TestCheckExpression(t *testing.T) {
|
||||
os.Unsetenv("MM_FEATUREFLAGS_ATTRIBUTEBASEDACCESSCONTROL")
|
||||
})
|
||||
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Access control tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
t.Run("CheckExpression without license", func(t *testing.T) {
|
||||
_, resp, err := th.SystemAdminClient.CheckExpression(context.Background(), "true")
|
||||
require.Error(t, err)
|
||||
@@ -275,6 +291,10 @@ func TestTestExpression(t *testing.T) {
|
||||
os.Unsetenv("MM_FEATUREFLAGS_ATTRIBUTEBASEDACCESSCONTROL")
|
||||
})
|
||||
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Access control tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
t.Run("TestExpression without license", func(t *testing.T) {
|
||||
_, resp, err := th.SystemAdminClient.TestExpression(context.Background(), model.QueryExpressionParams{})
|
||||
require.Error(t, err)
|
||||
@@ -327,6 +347,10 @@ func TestSearchAccessControlPolicies(t *testing.T) {
|
||||
os.Unsetenv("MM_FEATUREFLAGS_ATTRIBUTEBASEDACCESSCONTROL")
|
||||
})
|
||||
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Access control tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
t.Run("SearchAccessControlPolicies without license", func(t *testing.T) {
|
||||
_, resp, err := th.SystemAdminClient.SearchAccessControlPolicies(context.Background(), model.AccessControlPolicySearch{})
|
||||
require.Error(t, err)
|
||||
@@ -381,6 +405,10 @@ func TestAssignAccessPolicy(t *testing.T) {
|
||||
os.Unsetenv("MM_FEATUREFLAGS_ATTRIBUTEBASEDACCESSCONTROL")
|
||||
})
|
||||
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Access control tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
samplePolicy := &model.AccessControlPolicy{
|
||||
ID: model.NewId(),
|
||||
Type: model.AccessControlPolicyTypeParent,
|
||||
@@ -448,6 +476,10 @@ func TestUnassignAccessPolicy(t *testing.T) {
|
||||
os.Unsetenv("MM_FEATUREFLAGS_ATTRIBUTEBASEDACCESSCONTROL")
|
||||
})
|
||||
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Access control tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
samplePolicy := &model.AccessControlPolicy{
|
||||
ID: model.NewId(),
|
||||
Type: model.AccessControlPolicyTypeParent,
|
||||
@@ -519,6 +551,10 @@ func TestGetChannelsForAccessControlPolicy(t *testing.T) {
|
||||
os.Unsetenv("MM_FEATUREFLAGS_ATTRIBUTEBASEDACCESSCONTROL")
|
||||
})
|
||||
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Access control tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
samplePolicy := &model.AccessControlPolicy{
|
||||
ID: model.NewId(),
|
||||
Type: model.AccessControlPolicyTypeParent,
|
||||
@@ -596,6 +632,10 @@ func TestSearchChannelsForAccessControlPolicy(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("SearchChannelsForAccessControlPolicy with regular user", func(t *testing.T) {
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Access control tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
ok := th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuEnterpriseAdvanced))
|
||||
require.True(t, ok, "SetLicense should return true")
|
||||
|
||||
|
||||
@@ -810,6 +810,10 @@ func TestPatchChannel(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Should be able to configure channel banner on a channel", func(t *testing.T) {
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Channel banner tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
client.Logout(context.Background())
|
||||
th.LoginBasic()
|
||||
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuEnterpriseAdvanced))
|
||||
@@ -866,6 +870,10 @@ func TestPatchChannel(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Should be able to configure channel banner as a team admin", func(t *testing.T) {
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Channel banner tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
client.Logout(context.Background())
|
||||
th.LoginTeamAdmin()
|
||||
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuEnterpriseAdvanced))
|
||||
@@ -891,6 +899,10 @@ func TestPatchChannel(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Cannot enable channel banner without configuring it", func(t *testing.T) {
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Channel banner tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
client.Logout(context.Background())
|
||||
th.LoginBasic()
|
||||
th.App.Srv().SetLicense(model.NewTestLicenseSKU(model.LicenseShortSkuEnterpriseAdvanced))
|
||||
@@ -1010,6 +1022,10 @@ func TestCanEditChannelBanner(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
if *mainHelper.GetSQLSettings().DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Channel banner tests are not supported on MySQL")
|
||||
}
|
||||
|
||||
t.Run("when license is nil", func(t *testing.T) {
|
||||
channel := &model.Channel{
|
||||
Type: model.ChannelTypeOpen,
|
||||
|
||||
@@ -186,6 +186,12 @@ func requestTrialLicense(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// MySQL is not supported for trial licenses
|
||||
if c.App.Config().SqlSettings.DriverName != nil && *c.App.Config().SqlSettings.DriverName == model.DatabaseDriverMysql {
|
||||
c.Err = model.NewAppError("requestTrialLicense", "api.license.request-trial.mysql.app_error", nil, "mysql is not supported for trial licenses", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if c.App.Srv().Platform().LicenseManager() == nil {
|
||||
c.Err = model.NewAppError("requestTrialLicense", "api.license.upgrade_needed.app_error", nil, "", http.StatusForbidden)
|
||||
return
|
||||
|
||||
@@ -258,7 +258,27 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("mysql database not supported", func(t *testing.T) {
|
||||
// Skip this test unless running with MySQL driver
|
||||
if *th.App.Config().SqlSettings.DriverName != model.DatabaseDriverMysql {
|
||||
t.Skip("Skipping test - only runs with MySQL driver")
|
||||
}
|
||||
|
||||
licenseManagerMock := &mocks.LicenseInterface{}
|
||||
licenseManagerMock.On("CanStartTrial").Return(true, nil).Once()
|
||||
th.App.Srv().Platform().SetLicenseManager(licenseManagerMock)
|
||||
|
||||
resp, err := th.SystemAdminClient.RequestTrialLicenseWithExtraFields(context.Background(), validTrialRequest)
|
||||
CheckErrorID(t, err, "api.license.request-trial.mysql.app_error")
|
||||
CheckBadRequestStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("trial license user count less than current users", func(t *testing.T) {
|
||||
// Skip this test when MySQL is configured as it hits the MySQL check first
|
||||
if *th.App.Config().SqlSettings.DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Skipping test - MySQL does not support trial licenses")
|
||||
}
|
||||
|
||||
license := model.NewTestLicense()
|
||||
license.Features.Users = model.NewPointer(nUsers)
|
||||
licenseJSON, jsonErr := json.Marshal(license)
|
||||
@@ -295,6 +315,11 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("returns status 451 when it receives status 451", func(t *testing.T) {
|
||||
// Skip this test when MySQL is configured as it hits the MySQL check first
|
||||
if *th.App.Config().SqlSettings.DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Skipping test - MySQL does not support trial licenses")
|
||||
}
|
||||
|
||||
license := model.NewTestLicense()
|
||||
license.Features.Users = model.NewPointer(nUsers)
|
||||
licenseJSON, jsonErr := json.Marshal(license)
|
||||
@@ -325,6 +350,11 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("returns status 400 if request is a mix of legacy and new fields", func(t *testing.T) {
|
||||
// Skip this test when MySQL is configured as it hits the MySQL check first
|
||||
if *th.App.Config().SqlSettings.DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Skipping test - MySQL does not support trial licenses")
|
||||
}
|
||||
|
||||
validTrialRequest.CompanyCountry = ""
|
||||
validTrialRequest.Users = 100
|
||||
defer func() { validTrialRequest.CompanyCountry = "US" }()
|
||||
@@ -365,6 +395,11 @@ func TestRequestTrialLicenseWithExtraFields(t *testing.T) {
|
||||
|
||||
th.App.Srv().Platform().SetLicenseManager(nil)
|
||||
t.Run("trial license should fail if LicenseManager is nil", func(t *testing.T) {
|
||||
// Skip this test when MySQL is configured as it hits the MySQL check first
|
||||
if *th.App.Config().SqlSettings.DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Skipping test - MySQL does not support trial licenses")
|
||||
}
|
||||
|
||||
resp, err := th.SystemAdminClient.RequestTrialLicenseWithExtraFields(context.Background(), validTrialRequest)
|
||||
CheckErrorID(t, err, "api.license.upgrade_needed.app_error")
|
||||
CheckForbiddenStatus(t, resp)
|
||||
@@ -387,7 +422,27 @@ func TestRequestTrialLicense(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("mysql database not supported", func(t *testing.T) {
|
||||
// Skip this test unless running with MySQL driver
|
||||
if *th.App.Config().SqlSettings.DriverName != model.DatabaseDriverMysql {
|
||||
t.Skip("Skipping test - only runs with MySQL driver")
|
||||
}
|
||||
|
||||
licenseManagerMock := &mocks.LicenseInterface{}
|
||||
licenseManagerMock.On("CanStartTrial").Return(true, nil).Once()
|
||||
th.App.Srv().Platform().SetLicenseManager(licenseManagerMock)
|
||||
|
||||
resp, err := th.SystemAdminClient.RequestTrialLicense(context.Background(), 1000)
|
||||
CheckErrorID(t, err, "api.license.request-trial.mysql.app_error")
|
||||
CheckBadRequestStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("trial license invalid JSON", func(t *testing.T) {
|
||||
// Skip this test when MySQL is configured as it hits the MySQL check first
|
||||
if *th.App.Config().SqlSettings.DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Skipping test - MySQL does not support trial licenses")
|
||||
}
|
||||
|
||||
// the JSON is invalid because it is missing a closing brace
|
||||
|
||||
licenseManagerMock := &mocks.LicenseInterface{}
|
||||
@@ -400,6 +455,11 @@ func TestRequestTrialLicense(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("trial license user count less than current users", func(t *testing.T) {
|
||||
// Skip this test when MySQL is configured as it hits the MySQL check first
|
||||
if *th.App.Config().SqlSettings.DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Skipping test - MySQL does not support trial licenses")
|
||||
}
|
||||
|
||||
nUsers := 1
|
||||
license := model.NewTestLicense()
|
||||
license.Features.Users = model.NewPointer(nUsers)
|
||||
@@ -435,6 +495,11 @@ func TestRequestTrialLicense(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("returns status 451 when it receives status 451", func(t *testing.T) {
|
||||
// Skip this test when MySQL is configured as it hits the MySQL check first
|
||||
if *th.App.Config().SqlSettings.DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Skipping test - MySQL does not support trial licenses")
|
||||
}
|
||||
|
||||
nUsers := 1
|
||||
license := model.NewTestLicense()
|
||||
license.Features.Users = model.NewPointer(nUsers)
|
||||
@@ -467,6 +532,11 @@ func TestRequestTrialLicense(t *testing.T) {
|
||||
|
||||
th.App.Srv().Platform().SetLicenseManager(nil)
|
||||
t.Run("trial license should fail if LicenseManager is nil", func(t *testing.T) {
|
||||
// Skip this test when MySQL is configured as it hits the MySQL check first
|
||||
if *th.App.Config().SqlSettings.DriverName == model.DatabaseDriverMysql {
|
||||
t.Skip("Skipping test - MySQL does not support trial licenses")
|
||||
}
|
||||
|
||||
resp, err := th.SystemAdminClient.RequestTrialLicense(context.Background(), 1)
|
||||
CheckErrorID(t, err, "api.license.upgrade_needed.app_error")
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
Ссылка в новой задаче
Block a user