Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 'enterprise' license type #52273

Merged
merged 12 commits into from
Dec 17, 2019
Merged
1 change: 1 addition & 0 deletions x-pack/legacy/common/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export {
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
LICENSE_TYPE_TRIAL,
RANKED_LICENSE_TYPES,
LicenseType,
Expand Down
3 changes: 3 additions & 0 deletions x-pack/legacy/common/constants/license_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export const LICENSE_TYPE_BASIC = 'basic';
export const LICENSE_TYPE_STANDARD = 'standard';
export const LICENSE_TYPE_GOLD = 'gold';
export const LICENSE_TYPE_PLATINUM = 'platinum';
export const LICENSE_TYPE_ENTERPRISE = 'enterprise';
export const LICENSE_TYPE_TRIAL = 'trial';

export type LicenseType =
| typeof LICENSE_TYPE_BASIC
| typeof LICENSE_TYPE_STANDARD
| typeof LICENSE_TYPE_GOLD
| typeof LICENSE_TYPE_PLATINUM
| typeof LICENSE_TYPE_ENTERPRISE
| typeof LICENSE_TYPE_TRIAL;

// These are ordered from least featureful to most featureful, so we can assume that someone holding
Expand All @@ -24,5 +26,6 @@ export const RANKED_LICENSE_TYPES = [
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
LICENSE_TYPE_TRIAL,
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
*/

export const REQUIRED_ROLES = ['beats_admin'];
export const REQUIRED_LICENSES = ['standard', 'gold', 'trial', 'platinum'];
export const LICENSES = ['oss', 'basic', 'standard', 'gold', 'trial', 'platinum'];
export type LicenseType = 'oss' | 'basic' | 'trial' | 'standard' | 'basic' | 'gold' | 'platinum';
export const REQUIRED_LICENSES = ['standard', 'gold', 'trial', 'platinum', 'enterprise'];
export const LICENSES = ['oss', 'basic', 'standard', 'gold', 'trial', 'platinum', 'enterprise'];
export type LicenseType =
| 'oss'
| 'basic'
| 'trial'
| 'standard'
| 'gold'
| 'platinum'
| 'enterprise';
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const RuntimeFrameworkInfo = t.interface(
basic: null,
gold: null,
platinum: null,
enterprise: null,
}),
expired: t.boolean,
expiry_date_in_millis: t.number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function checkLicense(xpackLicenseInfo) {
};
}

const VALID_LICENSE_MODES = ['trial', 'platinum'];
const VALID_LICENSE_MODES = ['trial', 'platinum', 'enterprise'];

const isLicenseModeValid = xpackLicenseInfo.license.isOneOf(VALID_LICENSE_MODES);
const isLicenseActive = xpackLicenseInfo.license.isActive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('check_license', function() {
set(mockLicenseInfo, 'license.getType', () => 'basic');
});

describe('& license is trial, standard, gold, platinum', () => {
describe('& license is > basic', () => {
beforeEach(() => set(mockLicenseInfo, 'license.isOneOf', () => true));

describe('& license is active', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function checkLicense(xpackLicenseInfo) {
};
}

const VALID_LICENSE_MODES = ['trial', 'basic', 'standard', 'gold', 'platinum'];
const VALID_LICENSE_MODES = ['basic', 'standard', 'gold', 'platinum', 'enterprise', 'trial'];

const isLicenseModeValid = xpackLicenseInfo.license.isOneOf(VALID_LICENSE_MODES);
const isLicenseActive = xpackLicenseInfo.license.isActive();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ describe('RequestTrialExtension component', () => {
expect(html).not.toBeNull();
expect(html).toMatchSnapshot();
});
test('should display when enterprise license is not active and trial has been used', () => {
const rendered = getComponent(
{
trialStatus: {
canStartTrial: false,
},
license: createMockLicense('enterprise', 0),
},
RequestTrialExtension
);
const html = rendered.html();
expect(html).not.toBeNull();
expect(html).toMatchSnapshot();
});
test('should not display when platinum license is active and trial has been used', () => {
const rendered = getComponent(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ describe('StartTrial component when trial is allowed', () => {
);
expect(rendered.html()).toMatchSnapshot();
});
test('should not display for active enterprise license', () => {
const rendered = getComponent(
{
license: createMockLicense('enterprise'),
trialStatus: { canStartTrial: true },
},
StartTrial
);
expect(rendered.isEmptyRender()).toBeTruthy();
});
test('should display for expired enterprise license', () => {
const rendered = getComponent(
{
license: createMockLicense('enterprise', 0),
trialStatus: { canStartTrial: true },
},
StartTrial
);
expect(rendered.html()).toMatchSnapshot();
});
});

describe('StartTrial component when trial is not available', () => {
Expand Down Expand Up @@ -93,6 +113,16 @@ describe('StartTrial component when trial is not available', () => {
);
expect(rendered.isEmptyRender()).toBeTruthy();
});
test('should not display for enterprise license', () => {
const rendered = getComponent(
{
license: createMockLicense('enterprise'),
trialStatus: { canStartTrial: false },
},
StartTrial
);
expect(rendered.isEmptyRender()).toBeTruthy();
});

test('should not display for trial license', () => {
const rendered = getComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export const shouldShowStartTrial = state => {
return (
state.trialStatus.canStartTrial &&
licenseType !== 'trial' &&
//don't show for platinum unless it is expired
(licenseType !== 'platinum' || isExpired(state))
//don't show for platinum & enterprise unless it is expired
((licenseType !== 'platinum' && licenseType !== 'enterprise') || isExpired(state))
);
};

Expand All @@ -120,7 +120,7 @@ export const shouldShowRequestTrialExtension = state => {
return false;
}
const { type } = getLicense(state);
return type !== 'platinum' || isExpired(state);
return (type !== 'platinum' && type !== 'enterprise') || isExpired(state);
};

export const startTrialError = state => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('check_license', function() {
set(mockLicenseInfo, 'license.getType', () => 'basic');
});

describe('& license is trial, standard, gold, platinum', () => {
describe('& license is > basic', () => {
beforeEach(() => {
set(mockLicenseInfo, 'license.isOneOf', () => true);
mockLicenseInfo.feature = () => ({ isEnabled: () => true }); // Security feature is enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function checkLicense(xpackLicenseInfo) {
};
}

const VALID_LICENSE_MODES = ['trial', 'standard', 'gold', 'platinum'];
const VALID_LICENSE_MODES = ['trial', 'standard', 'gold', 'platinum', 'enterprise'];

const isLicenseModeValid = xpackLicenseInfo.license.isOneOf(VALID_LICENSE_MODES);
const isLicenseActive = xpackLicenseInfo.license.isActive();
Expand Down
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/maps/check_license.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function checkLicense(xPackInfo) {
'standard',
'gold',
'platinum',
'enterprise',
'trial',
]);

Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/ml/common/constants/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

export enum LICENSE_TYPE {
BASIC,
FULL, // platinum or trial
FULL, // >= platinum
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,28 @@
import expect from '@kbn/expect';
import sinon from 'sinon';
import { set } from 'lodash';
import { XPackInfo } from '../../../../../../../legacy/plugins/xpack_main/server/lib/xpack_info';
import { checkLicense } from '../check_license';
import { XPackInfo } from '../../../../xpack_main/server/lib/xpack_info';
import { checkLicense } from './check_license';

describe('check_license', () => {
let mockLicenseInfo: XPackInfo;
beforeEach(() => (mockLicenseInfo = {} as XPackInfo));

describe('license information is undefined', () => {
beforeEach(() => (mockLicenseInfo = {} as XPackInfo));

it('should set isAvailable to false', () => {
expect(checkLicense(mockLicenseInfo).isAvailable).to.be(false);
expect(checkLicense(undefined as any).isAvailable).to.be(false);
});

it('should set showLinks to true', () => {
expect(checkLicense(mockLicenseInfo).showLinks).to.be(true);
expect(checkLicense(undefined as any).showLinks).to.be(true);
});

it('should set enableLinks to false', () => {
expect(checkLicense(mockLicenseInfo).enableLinks).to.be(false);
expect(checkLicense(undefined as any).enableLinks).to.be(false);
});

it('should set a message', () => {
expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined);
expect(checkLicense(undefined as any).message).to.not.be(undefined);
});
});

Expand Down Expand Up @@ -101,7 +99,7 @@ describe('check_license', () => {
);
});

describe('& license is trial or platinum', () => {
describe('& license is >= platinum', () => {
beforeEach(() => set(mockLicenseInfo, 'license.isOneOf', () => true));

describe('& license is active', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function checkLicense(xpackLicenseInfo: XPackInfo): Response {
};
}

const VALID_FULL_LICENSE_MODES = ['trial', 'platinum'];
const VALID_FULL_LICENSE_MODES = ['platinum', 'enterprise', 'trial'];

const isLicenseModeValid = xpackLicenseInfo.license.isOneOf(VALID_FULL_LICENSE_MODES);
const licenseType = isLicenseModeValid === true ? LICENSE_TYPE.FULL : LICENSE_TYPE.BASIC;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/monitoring/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const CALCULATE_DURATION_UNTIL = 'until';
/**
* In order to show ML Jobs tab in the Elasticsearch section / tab navigation, license must be supported
*/
export const ML_SUPPORTED_LICENSES = ['trial', 'platinum'];
export const ML_SUPPORTED_LICENSES = ['trial', 'platinum', 'enterprise'];

/**
* Metadata service URLs for the different cloud services that have constant URLs (e.g., unlike GCP, which is a constant prefix).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ describe('Monitoring Check License', () => {
});
});

it('enterprise active license - results true with no message', () => {
const result = checkLicense('enterprise', true, 'test-cluster-pqr');
expect(result).to.eql({
clusterAlerts: { enabled: true },
});
});

describe('Watcher is not enabled', () => {
it('platinum active license - watcher disabled - results false with message', () => {
const result = checkLicense('platinum', true, 'test-cluster-pqr', false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function checkLicense(type, active, clusterSource, watcher = true) {
}

// Disabled because the license type is not valid (basic)
if (!includes(['trial', 'standard', 'gold', 'platinum'], type)) {
if (!includes(['trial', 'standard', 'gold', 'platinum', 'enterprise'], type)) {
return Object.assign(licenseInfo, {
message: i18n.translate(
'xpack.monitoring.clusterAlerts.checkLicense.licenseIsBasicDescription',
Expand Down
1 change: 1 addition & 0 deletions x-pack/legacy/plugins/reporting/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ export const LICENSE_TYPE_BASIC = 'basic';
export const LICENSE_TYPE_STANDARD = 'standard';
export const LICENSE_TYPE_GOLD = 'gold';
export const LICENSE_TYPE_PLATINUM = 'platinum';
export const LICENSE_TYPE_ENTERPRISE = 'enterprise';
2 changes: 2 additions & 0 deletions x-pack/legacy/plugins/reporting/export_types/csv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
} from '../../common/constants';
import { ExportTypeDefinition, ESQueueCreateJobFn, ESQueueWorkerExecuteFn } from '../../types';
import { metadata } from './metadata';
Expand All @@ -35,5 +36,6 @@ export const getExportType = (): ExportTypeDefinition<
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
} from '../../common/constants';
import { ExportTypeDefinition, ImmediateCreateJobFn, ImmediateExecuteFn } from '../../types';
import { createJobFactory } from './server/create_job';
Expand Down Expand Up @@ -42,5 +43,6 @@ export const getExportType = (): ExportTypeDefinition<
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
],
});
2 changes: 2 additions & 0 deletions x-pack/legacy/plugins/reporting/export_types/png/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
} from '../../common/constants';
import { ExportTypeDefinition, ESQueueCreateJobFn, ESQueueWorkerExecuteFn } from '../../types';
import { createJobFactory } from './server/create_job';
Expand All @@ -34,5 +35,6 @@ export const getExportType = (): ExportTypeDefinition<
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
} from '../../common/constants';
import { ExportTypeDefinition, ESQueueCreateJobFn, ESQueueWorkerExecuteFn } from '../../types';
import { createJobFactory } from './server/create_job';
Expand All @@ -34,5 +35,6 @@ export const getExportType = (): ExportTypeDefinition<
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('check_license', function() {
set(mockLicenseInfo, 'license.getType', () => 'basic');
});

describe('& license is trial, standard, gold, platinum', () => {
describe('& license is > basic', () => {
beforeEach(() => set(mockLicenseInfo, 'license.isOneOf', () => true));

describe('& license is active', () => {
Expand Down
Loading