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 удалений

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

@@ -26,6 +26,7 @@ function mapStateToProps(state: GlobalState) {
totalUsers: selectFilteredUserStats(state)?.total_users_count || 0,
upgradedFromTE: config.UpgradedFromTE === 'true',
prevTrialLicense: state.entities.admin.prevTrialLicense,
isMySql: config.SQLDriverName === 'mysql',
};
}

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

@@ -42,6 +42,7 @@ describe('components/admin_console/license_settings/LicenseSettings', () => {
upgradedFromTE: false,
enterpriseReady: true,
totalUsers: 10,
isMySql: false,
actions: {
getLicenseConfig: jest.fn(),
uploadLicense: jest.fn(),

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

@@ -45,6 +45,7 @@ type Props = {
totalUsers: number;
isDisabled: boolean;
prevTrialLicense: ClientLicense;
isMySql: boolean;
actions: {
getLicenseConfig: () => void;
uploadLicense: (file: File) => Promise<ActionResult>;
@@ -280,7 +281,7 @@ export default class LicenseSettings extends React.PureComponent<Props, State> {
);
render() {
const {license, upgradedFromTE, isDisabled} = this.props;
const {license, upgradedFromTE, isDisabled, isMySql} = this.props;
let leftPanel = null;
let rightPanel = null;
@@ -362,6 +363,7 @@ export default class LicenseSettings extends React.PureComponent<Props, State> {
/>
{!this.state.clickNormalUpgradeBtn && license.IsLicensed !== 'true' &&
this.props.prevTrialLicense?.IsLicensed !== 'true' &&
!isMySql &&
<TrialBanner
isDisabled={isDisabled}
gettingTrialResponseCode={this.state.gettingTrialResponseCode}

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

@@ -367,7 +367,7 @@ const TrialBanner = ({
title={
<FormattedMessage
id='licensingPage.infoBanner.startTrialTitle'
defaultMessage='Start a free 30-day tral of Mattermost Enterprise Advanced'
defaultMessage='Start a free 30-day trial of Mattermost Enterprise Advanced'
/>
}
message={

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

@@ -266,6 +266,43 @@ describe('components/sidebar/show_start_trial_modal', () => {
expect(mockDispatch).toHaveBeenCalledTimes(0);
});
test('should NOT dispatch the modal when database is MySQL', () => {
const isAdminUser = {
currentUserId: 'current_user_id',
profiles: {
current_user_id: {roles: 'system_admin system_user'},
},
};
const moreThan10Users = 11;
jest.spyOn(getTotalUsersHook, 'default').mockImplementation(() => moreThan10Users);
const notPreviouslyLicensed = {
prevTrialLicense: {
IsLicensed: 'false',
},
};
const moreThan6HoursWithMySQL = {
config: {
// installation date is set to be 10 hours before current time
InstallationDate: new Date().getTime() - ((10 * 60 * 60) * 1000),
SQLDriverName: 'mysql',
},
license: {
IsLicensed: 'false',
},
};
mockState = {...mockState, entities: {...mockState.entities, users: isAdminUser, admin: notPreviouslyLicensed, general: moreThan6HoursWithMySQL}};
mount(
<ShowStartTrialModal/>,
);
expect(mockDispatch).toHaveBeenCalledTimes(0);
});
test('should dispatch the modal when there are more than 10 users', () => {
const isAdminUser = {
currentUserId: 'current_user_id',
@@ -288,6 +325,7 @@ describe('components/sidebar/show_start_trial_modal', () => {
// installation date is set to be 10 hours before current time
InstallationDate: new Date().getTime() - ((10 * 60 * 60) * 1000),
SQLDriverName: 'postgres',
},
license: {
IsLicensed: 'false',

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

@@ -35,7 +35,9 @@ const ShowStartTrialModal = () => {
const isBenefitsModalOpened = useSelector((state: GlobalState) => isModalOpen(state, ModalIdentifiers.TRIAL_BENEFITS_MODAL));
const installationDate = useSelector((state: GlobalState) => getConfig(state).InstallationDate);
const config = useSelector((state: GlobalState) => getConfig(state));
const installationDate = config.InstallationDate;
const isMySql = config.SQLDriverName === 'mysql';
const currentUser = useSelector((state: GlobalState) => getCurrentUser(state));
const hadAdminDismissedModal = useSelector((state: GlobalState) => getBool(state, Preferences.START_TRIAL_MODAL, Constants.TRIAL_MODAL_AUTO_SHOWN));
@@ -74,7 +76,7 @@ const ShowStartTrialModal = () => {
const now = new Date().getTime();
const hasEnvMoreThan6Hours = now > installationDatePlus6Hours;
const hasEnvMoreThan10Users = Number(totalUsers) > userThreshold;
if (isUserAdmin && !isBenefitsModalOpened && hasEnvMoreThan10Users && hasEnvMoreThan6Hours && !hadAdminDismissedModal && !isLicensedOrPreviousLicensed) {
if (isUserAdmin && !isMySql && !isBenefitsModalOpened && hasEnvMoreThan10Users && hasEnvMoreThan6Hours && !hadAdminDismissedModal && !isLicensedOrPreviousLicensed) {
openStartTrialFormModal({trackingLocation: 'show_start_trial_modal'}, handleOnClose);
trackEvent(
TELEMETRY_CATEGORIES.SELF_HOSTED_START_TRIAL_AUTO_MODAL,

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

@@ -4471,7 +4471,7 @@
"leave_team_modal.no": "No",
"leave_team_modal.title": "Leave the team?",
"leave_team_modal.yes": "Yes",
"licensingPage.infoBanner.startTrialTitle": "Start a free 30-day tral of Mattermost Enterprise Advanced",
"licensingPage.infoBanner.startTrialTitle": "Start a free 30-day trial of Mattermost Enterprise Advanced",
"licensingPage.overageUsersBanner.cta": "Contact Sales",
"licensingPage.overageUsersBanner.noticeDescription": "Notify your Customer Success Manager on your next true-up check. <a></a>",
"licensingPage.overageUsersBanner.noticeTitle": "Your workspace user count has exceeded your licensed seat count by {seats, number} {seats, plural, one {seat} other {seats}}",