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>
Этот коммит содержится в:
Jesse Hallam
2025-05-26 15:44:32 -03:00
коммит произвёл GitHub
родитель f2bb82bc01
Коммит 70a42ffd5f
14 изменённых файлов: 244 добавлений и 5 удалений

Просмотреть файл

@@ -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)