Support 'enterprise' license type (#52273)

* add enterprise license type to licensing plugin

* add enterprise license to x-pack plugins

* update uptime license list

* improve naming in security plugin

* update reporting licensing
This commit is contained in:
Mikhail Shustov 2019-12-17 15:43:19 +01:00 committed by GitHub
parent 4f5db1498b
commit 74e1d17cf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 143 additions and 39 deletions

View file

@ -16,6 +16,7 @@ export {
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
LICENSE_TYPE_TRIAL,
RANKED_LICENSE_TYPES,
LicenseType,

View file

@ -8,6 +8,7 @@ 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 =
@ -15,6 +16,7 @@ export type LicenseType =
| 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
@ -24,5 +26,6 @@ export const RANKED_LICENSE_TYPES = [
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
LICENSE_TYPE_TRIAL,
];

View file

@ -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';

View file

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

View file

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

View file

@ -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', () => {

View file

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

View file

@ -1,5 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`RequestTrialExtension component should display when enterprise license is not active and trial has been used 1`] = `"<div class=\\"euiFlexItem\\"><div class=\\"euiCard euiCard--centerAligned\\"><div class=\\"euiCard__content\\"><span class=\\"euiTitle euiTitle--small euiCard__title\\" id=\\"generated-idTitle\\">Extend your trial</span><div class=\\"euiText euiText--small euiCard__description\\" id=\\"generated-idDescription\\"><p><span>If youd like to continue using machine learning, advanced security, and our other awesome <a class=\\"euiLink euiLink--primary\\" href=\\"https://www.elastic.co/subscriptions\\" target=\\"_blank\\" rel=\\"noopener\\">Platinum features</a>, request an extension now.</span></p></div></div><div class=\\"euiCard__footer\\"><a class=\\"euiButton euiButton--primary\\" href=\\"https://www.elastic.co/trialextension\\" target=\\"_blank\\" rel=\\"noopener\\" data-test-subj=\\"extendTrialButton\\"><span class=\\"euiButton__content\\"><span class=\\"euiButton__text\\">Extend trial</span></span></a></div></div></div>"`;
exports[`RequestTrialExtension component should display when license is active and trial has been used 1`] = `"<div class=\\"euiFlexItem\\"><div class=\\"euiCard euiCard--centerAligned\\"><div class=\\"euiCard__content\\"><span class=\\"euiTitle euiTitle--small euiCard__title\\" id=\\"generated-idTitle\\">Extend your trial</span><div class=\\"euiText euiText--small euiCard__description\\" id=\\"generated-idDescription\\"><p><span>If youd like to continue using machine learning, advanced security, and our other awesome <a class=\\"euiLink euiLink--primary\\" href=\\"https://www.elastic.co/subscriptions\\" target=\\"_blank\\" rel=\\"noopener\\">Platinum features</a>, request an extension now.</span></p></div></div><div class=\\"euiCard__footer\\"><a class=\\"euiButton euiButton--primary\\" href=\\"https://www.elastic.co/trialextension\\" target=\\"_blank\\" rel=\\"noopener\\" data-test-subj=\\"extendTrialButton\\"><span class=\\"euiButton__content\\"><span class=\\"euiButton__text\\">Extend trial</span></span></a></div></div></div>"`;
exports[`RequestTrialExtension component should display when license is not active and trial has been used 1`] = `"<div class=\\"euiFlexItem\\"><div class=\\"euiCard euiCard--centerAligned\\"><div class=\\"euiCard__content\\"><span class=\\"euiTitle euiTitle--small euiCard__title\\" id=\\"generated-idTitle\\">Extend your trial</span><div class=\\"euiText euiText--small euiCard__description\\" id=\\"generated-idDescription\\"><p><span>If youd like to continue using machine learning, advanced security, and our other awesome <a class=\\"euiLink euiLink--primary\\" href=\\"https://www.elastic.co/subscriptions\\" target=\\"_blank\\" rel=\\"noopener\\">Platinum features</a>, request an extension now.</span></p></div></div><div class=\\"euiCard__footer\\"><a class=\\"euiButton euiButton--primary\\" href=\\"https://www.elastic.co/trialextension\\" target=\\"_blank\\" rel=\\"noopener\\" data-test-subj=\\"extendTrialButton\\"><span class=\\"euiButton__content\\"><span class=\\"euiButton__text\\">Extend trial</span></span></a></div></div></div>"`;

View file

@ -2,6 +2,8 @@
exports[`StartTrial component when trial is allowed display for basic license 1`] = `"<div class=\\"euiFlexItem\\"><div class=\\"euiCard euiCard--centerAligned\\"><div class=\\"euiCard__content\\"><span class=\\"euiTitle euiTitle--small euiCard__title\\" id=\\"generated-idTitle\\">Start a 30-day trial</span><div class=\\"euiText euiText--small euiCard__description\\" id=\\"generated-idDescription\\"><p><span>Experience what machine learning, advanced security, and all our other <a class=\\"euiLink euiLink--primary\\" href=\\"https://www.elastic.co/subscriptions\\" target=\\"_blank\\" rel=\\"noopener\\">Platinum features</a> have to offer.</span></p></div></div><div class=\\"euiCard__footer\\"><button class=\\"euiButton euiButton--primary\\" type=\\"button\\" data-test-subj=\\"startTrialButton\\"><span class=\\"euiButton__content\\"><span class=\\"euiButton__text\\">Start trial</span></span></button></div></div></div>"`;
exports[`StartTrial component when trial is allowed should display for expired enterprise license 1`] = `"<div class=\\"euiFlexItem\\"><div class=\\"euiCard euiCard--centerAligned\\"><div class=\\"euiCard__content\\"><span class=\\"euiTitle euiTitle--small euiCard__title\\" id=\\"generated-idTitle\\">Start a 30-day trial</span><div class=\\"euiText euiText--small euiCard__description\\" id=\\"generated-idDescription\\"><p><span>Experience what machine learning, advanced security, and all our other <a class=\\"euiLink euiLink--primary\\" href=\\"https://www.elastic.co/subscriptions\\" target=\\"_blank\\" rel=\\"noopener\\">Platinum features</a> have to offer.</span></p></div></div><div class=\\"euiCard__footer\\"><button class=\\"euiButton euiButton--primary\\" type=\\"button\\" data-test-subj=\\"startTrialButton\\"><span class=\\"euiButton__content\\"><span class=\\"euiButton__text\\">Start trial</span></span></button></div></div></div>"`;
exports[`StartTrial component when trial is allowed should display for expired platinum license 1`] = `"<div class=\\"euiFlexItem\\"><div class=\\"euiCard euiCard--centerAligned\\"><div class=\\"euiCard__content\\"><span class=\\"euiTitle euiTitle--small euiCard__title\\" id=\\"generated-idTitle\\">Start a 30-day trial</span><div class=\\"euiText euiText--small euiCard__description\\" id=\\"generated-idDescription\\"><p><span>Experience what machine learning, advanced security, and all our other <a class=\\"euiLink euiLink--primary\\" href=\\"https://www.elastic.co/subscriptions\\" target=\\"_blank\\" rel=\\"noopener\\">Platinum features</a> have to offer.</span></p></div></div><div class=\\"euiCard__footer\\"><button class=\\"euiButton euiButton--primary\\" type=\\"button\\" data-test-subj=\\"startTrialButton\\"><span class=\\"euiButton__content\\"><span class=\\"euiButton__text\\">Start trial</span></span></button></div></div></div>"`;
exports[`StartTrial component when trial is allowed should display for gold license 1`] = `"<div class=\\"euiFlexItem\\"><div class=\\"euiCard euiCard--centerAligned\\"><div class=\\"euiCard__content\\"><span class=\\"euiTitle euiTitle--small euiCard__title\\" id=\\"generated-idTitle\\">Start a 30-day trial</span><div class=\\"euiText euiText--small euiCard__description\\" id=\\"generated-idDescription\\"><p><span>Experience what machine learning, advanced security, and all our other <a class=\\"euiLink euiLink--primary\\" href=\\"https://www.elastic.co/subscriptions\\" target=\\"_blank\\" rel=\\"noopener\\">Platinum features</a> have to offer.</span></p></div></div><div class=\\"euiCard__footer\\"><button class=\\"euiButton euiButton--primary\\" type=\\"button\\" data-test-subj=\\"startTrialButton\\"><span class=\\"euiButton__content\\"><span class=\\"euiButton__text\\">Start trial</span></span></button></div></div></div>"`;

View file

@ -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(
{

View file

@ -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', () => {
@ -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(

View file

@ -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))
);
};
@ -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 => {

View file

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

View file

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

View file

@ -21,6 +21,7 @@ export function checkLicense(xPackInfo) {
'standard',
'gold',
'platinum',
'enterprise',
'trial',
]);

View file

@ -6,5 +6,5 @@
export enum LICENSE_TYPE {
BASIC,
FULL, // platinum or trial
FULL, // >= platinum
}

View file

@ -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);
});
});
@ -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', () => {

View file

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

View file

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

View file

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

View file

@ -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',

View file

@ -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';

View file

@ -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';
@ -35,5 +36,6 @@ export const getExportType = (): ExportTypeDefinition<
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
],
});

View file

@ -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';
@ -42,5 +43,6 @@ export const getExportType = (): ExportTypeDefinition<
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
],
});

View file

@ -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';
@ -34,5 +35,6 @@ export const getExportType = (): ExportTypeDefinition<
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
],
});

View file

@ -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';
@ -34,5 +35,6 @@ export const getExportType = (): ExportTypeDefinition<
LICENSE_TYPE_STANDARD,
LICENSE_TYPE_GOLD,
LICENSE_TYPE_PLATINUM,
LICENSE_TYPE_ENTERPRISE,
],
});

View file

@ -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', () => {

View file

@ -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', () => {

View file

@ -24,7 +24,7 @@ export function checkLicense(xpackLicenseInfo) {
};
}
const VALID_LICENSE_MODES = ['trial', 'basic', 'standard', 'gold', 'platinum'];
const VALID_LICENSE_MODES = ['trial', 'basic', 'standard', 'gold', 'platinum', 'enterprise'];
const isLicenseModeValid = xpackLicenseInfo.license.isOneOf(VALID_LICENSE_MODES);
const isLicenseActive = xpackLicenseInfo.license.isActive();

View file

@ -30,7 +30,7 @@ describe('check_license', () => {
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', () => {

View file

@ -29,7 +29,16 @@ export function checkLicense(
});
}
if (xpackLicenseInfo.license.isOneOf(['trial', 'basic', 'standard', 'gold', 'platinum'])) {
if (
xpackLicenseInfo.license.isOneOf([
'trial',
'basic',
'standard',
'gold',
'platinum',
'enterprise',
])
) {
return {
showAppLink: true,
enableAppLink: isLicenseActive,

View file

@ -19,7 +19,14 @@ export function inspectSettings(xpackInfo) {
license: {
uid: xpackInfo.license.getUid(),
active: xpackInfo.license.isActive(),
valid: xpackInfo.license.isOneOf(['trial', 'standard', 'basic', 'gold', 'platinum']),
valid: xpackInfo.license.isOneOf([
'trial',
'standard',
'basic',
'gold',
'platinum',
'enterprise',
]),
},
};
}

View file

@ -21,7 +21,7 @@ export const licenseCheck: UMLicenseCheck = license => {
statusCode: 400,
};
}
if (!license.isOneOf(['basic', 'standard', 'gold', 'platinum', 'trial'])) {
if (!license.isOneOf(['basic', 'standard', 'gold', 'platinum', 'enterprise', 'trial'])) {
return {
message: 'License not supported',
statusCode: 401,

View file

@ -43,7 +43,7 @@ export interface Feature<
* This does not restrict access to your feature based on license.
* Its only purpose is to inform the space and roles UIs on which features to display.
*/
validLicenses?: Array<'basic' | 'standard' | 'gold' | 'platinum'>;
validLicenses?: Array<'basic' | 'standard' | 'gold' | 'platinum' | 'enterprise'>;
/**
* An optional EUI Icon to be used when displaying your feature.

View file

@ -50,7 +50,9 @@ const schema = Joi.object({
.required(),
name: Joi.string().required(),
excludeFromBasePrivileges: Joi.boolean(),
validLicenses: Joi.array().items(Joi.string().valid('basic', 'standard', 'gold', 'platinum')),
validLicenses: Joi.array().items(
Joi.string().valid('basic', 'standard', 'gold', 'platinum', 'enterprise')
),
icon: Joi.string(),
description: Joi.string(),
navLinkId: Joi.string().regex(uiCapabilitiesRegex),

View file

@ -12,6 +12,7 @@ describe('License', () => {
const basicLicense = licenseMock.create();
const basicExpiredLicense = licenseMock.create({ license: { status: 'expired' } });
const goldLicense = licenseMock.create({ license: { type: 'gold' } });
const enterpriseLicense = licenseMock.create({ license: { type: 'enterprise' } });
const errorMessage = 'unavailable';
const errorLicense = new License({ error: errorMessage, signature: '' });
@ -52,6 +53,7 @@ describe('License', () => {
it('isBasic', () => {
expect(basicLicense.isBasic).toBe(true);
expect(goldLicense.isBasic).toBe(false);
expect(enterpriseLicense.isBasic).toBe(false);
expect(errorLicense.isBasic).toBe(false);
expect(unavailableLicense.isBasic).toBe(false);
});
@ -59,6 +61,7 @@ describe('License', () => {
it('isNotBasic', () => {
expect(basicLicense.isNotBasic).toBe(false);
expect(goldLicense.isNotBasic).toBe(true);
expect(enterpriseLicense.isNotBasic).toBe(true);
expect(errorLicense.isNotBasic).toBe(false);
expect(unavailableLicense.isNotBasic).toBe(false);
});
@ -106,6 +109,9 @@ describe('License', () => {
expect(unavailableLicense.check('ccr', 'basic').state).toBe(LICENSE_CHECK_STATE.Unavailable);
expect(unavailableLicense.check('ccr', 'gold').state).toBe(LICENSE_CHECK_STATE.Unavailable);
expect(enterpriseLicense.check('ccr', 'gold').state).toBe(LICENSE_CHECK_STATE.Valid);
expect(enterpriseLicense.check('ccr', 'enterprise').state).toBe(LICENSE_CHECK_STATE.Valid);
});
it('throws in case of unknown license type', () => {

View file

@ -16,7 +16,8 @@ export enum LICENSE_TYPE {
standard = 20,
gold = 30,
platinum = 40,
trial = 50,
enterprise = 50,
trial = 60,
}
/** @public */

View file

@ -82,11 +82,15 @@ describe('license features', function() {
});
});
it('should allow to login, allow RBAC and document level security if license is platinum or trial.', () => {
it('should allow to login, allow RBAC and document level security if license >= platinum', () => {
const mockRawLicense = getMockRawLicense({ isAvailable: true });
mockRawLicense.isOneOf.mockImplementation(licenses => {
const licenseArray = [licenses].flat();
return licenseArray.includes('trial') || licenseArray.includes('platinum');
return (
licenseArray.includes('trial') ||
licenseArray.includes('platinum') ||
licenseArray.includes('enterprise')
);
});
mockRawLicense.getFeature.mockReturnValue({ isEnabled: true, isAvailable: true });

View file

@ -69,14 +69,14 @@ export class SecurityLicenseService {
};
}
const isLicensePlatinumOrTrial = rawLicense.isOneOf(['platinum', 'trial']);
const isLicensePlatinumOrBetter = rawLicense.isOneOf(['platinum', 'enterprise', 'trial']);
return {
showLogin: true,
allowLogin: true,
showLinks: true,
// Only platinum and trial licenses are compliant with field- and document-level security.
allowRoleDocumentLevelSecurity: isLicensePlatinumOrTrial,
allowRoleFieldLevelSecurity: isLicensePlatinumOrTrial,
allowRoleDocumentLevelSecurity: isLicensePlatinumOrBetter,
allowRoleFieldLevelSecurity: isLicensePlatinumOrBetter,
allowRbac: true,
};
},