From ee469c93eee81f7647bd880b84bab6bede6fc6da Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Thu, 5 Dec 2019 13:38:23 +0100 Subject: [PATCH 1/5] add enterprise license type to licensing plugin --- x-pack/legacy/common/constants/index.ts | 1 + x-pack/legacy/common/constants/license_types.ts | 3 +++ .../plugins/xpack_main/server/lib/xpack_info_license.d.ts | 2 +- x-pack/plugins/licensing/common/license.test.ts | 6 ++++++ x-pack/plugins/licensing/common/types.ts | 3 ++- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/x-pack/legacy/common/constants/index.ts b/x-pack/legacy/common/constants/index.ts index 842b0aea91d30..4db0f994fd47e 100644 --- a/x-pack/legacy/common/constants/index.ts +++ b/x-pack/legacy/common/constants/index.ts @@ -16,6 +16,7 @@ export { LICENSE_TYPE_STANDARD, LICENSE_TYPE_GOLD, LICENSE_TYPE_PLATINUM, + LICENSE_TYPE_ENTERPRISE, LICENSE_TYPE_TRIAL, RANKED_LICENSE_TYPES, LicenseType, diff --git a/x-pack/legacy/common/constants/license_types.ts b/x-pack/legacy/common/constants/license_types.ts index 3971ed5e95174..8c329df2f85f7 100644 --- a/x-pack/legacy/common/constants/license_types.ts +++ b/x-pack/legacy/common/constants/license_types.ts @@ -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, ]; diff --git a/x-pack/legacy/plugins/xpack_main/server/lib/xpack_info_license.d.ts b/x-pack/legacy/plugins/xpack_main/server/lib/xpack_info_license.d.ts index ab09e0d73b80d..5578ca574da4f 100644 --- a/x-pack/legacy/plugins/xpack_main/server/lib/xpack_info_license.d.ts +++ b/x-pack/legacy/plugins/xpack_main/server/lib/xpack_info_license.d.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -type LicenseType = 'oss' | 'basic' | 'trial' | 'standard' | 'basic' | 'gold' | 'platinum'; +type LicenseType = 'oss' | 'basic' | 'trial' | 'standard' | 'gold' | 'platinum' | 'enterprise'; export declare class XPackInfoLicense { constructor(getRawLicense: () => any); diff --git a/x-pack/plugins/licensing/common/license.test.ts b/x-pack/plugins/licensing/common/license.test.ts index 6dbf009deabb7..bf2a06e69df6e 100644 --- a/x-pack/plugins/licensing/common/license.test.ts +++ b/x-pack/plugins/licensing/common/license.test.ts @@ -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', () => { diff --git a/x-pack/plugins/licensing/common/types.ts b/x-pack/plugins/licensing/common/types.ts index c8edd8fd0cca8..223f9e3f2f26b 100644 --- a/x-pack/plugins/licensing/common/types.ts +++ b/x-pack/plugins/licensing/common/types.ts @@ -17,7 +17,8 @@ export enum LICENSE_TYPE { standard = 20, gold = 30, platinum = 40, - trial = 50, + enterprise = 50, + trial = 60, } /** @public */ From 4815cf3b7f0a89aa4e9bde5ee8b09318d097f08d Mon Sep 17 00:00:00 2001 From: Mikhail Shustov Date: Thu, 5 Dec 2019 13:39:17 +0100 Subject: [PATCH 2/5] add enterprise license to x-pack plugins --- .../common/constants/security.ts | 13 ++++++-- .../lib/adapters/framework/adapter_types.ts | 1 + .../server/lib/check_license/check_license.js | 2 +- .../server/lib/__tests__/check_license.js | 6 ++-- .../plugins/graph/server/lib/check_license.js | 2 +- .../check_license/__tests__/check_license.js | 2 +- .../server/lib/check_license/check_license.js | 5 ++-- .../request_trial_extension.test.js.snap | 2 ++ .../__snapshots__/start_trial.test.js.snap | 2 ++ .../__jest__/request_trial_extension.test.js | 14 +++++++++ .../__jest__/start_trial.test.js | 30 +++++++++++++++++++ .../store/reducers/licenseManagement.js | 6 ++-- .../check_license/__tests__/check_license.js | 2 +- .../server/lib/check_license/check_license.js | 3 +- x-pack/legacy/plugins/maps/check_license.js | 1 + .../plugins/ml/common/constants/license.ts | 2 +- ...check_license.ts => check_license.test.ts} | 16 +++++----- .../server/lib/check_license/check_license.ts | 2 +- .../plugins/monitoring/common/constants.js | 2 +- .../cluster_alerts/__tests__/check_license.js | 7 +++++ .../server/cluster_alerts/check_license.js | 2 +- .../export_types/csv/server/index.ts | 2 +- .../csv_from_savedobject/server/index.ts | 2 +- .../export_types/png/server/index.ts | 2 +- .../printable_pdf/server/index.ts | 2 +- .../server/lib/__tests__/check_license.js | 2 +- .../check_license/__tests__/check_license.js | 2 +- .../server/lib/check_license/check_license.js | 3 +- .../server/np_ready/lib/check_license.test.ts | 2 +- .../server/np_ready/lib/check_license.ts | 11 ++++++- .../tilemap/server/lib/inspect_settings.js | 2 +- .../plugins/uptime/server/lib/domains/auth.ts | 2 +- x-pack/plugins/features/server/feature.ts | 2 +- .../plugins/features/server/feature_schema.ts | 4 ++- .../server/licensing/license_service.test.ts | 8 +++-- .../server/licensing/license_service.ts | 2 +- 36 files changed, 125 insertions(+), 45 deletions(-) rename x-pack/legacy/plugins/ml/server/lib/check_license/{__tests__/check_license.ts => check_license.test.ts} (89%) diff --git a/x-pack/legacy/plugins/beats_management/common/constants/security.ts b/x-pack/legacy/plugins/beats_management/common/constants/security.ts index c80b036dddf83..3a9858979dbb9 100644 --- a/x-pack/legacy/plugins/beats_management/common/constants/security.ts +++ b/x-pack/legacy/plugins/beats_management/common/constants/security.ts @@ -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'; diff --git a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts b/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts index 08832772dd047..bb1f68e1c03b3 100644 --- a/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/legacy/plugins/beats_management/server/lib/adapters/framework/adapter_types.ts @@ -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, diff --git a/x-pack/legacy/plugins/cross_cluster_replication/server/lib/check_license/check_license.js b/x-pack/legacy/plugins/cross_cluster_replication/server/lib/check_license/check_license.js index ddde694bc549a..58ff5da7a409e 100644 --- a/x-pack/legacy/plugins/cross_cluster_replication/server/lib/check_license/check_license.js +++ b/x-pack/legacy/plugins/cross_cluster_replication/server/lib/check_license/check_license.js @@ -26,7 +26,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(); diff --git a/x-pack/legacy/plugins/graph/server/lib/__tests__/check_license.js b/x-pack/legacy/plugins/graph/server/lib/__tests__/check_license.js index c341dfbc378ca..5a4ad10321c01 100644 --- a/x-pack/legacy/plugins/graph/server/lib/__tests__/check_license.js +++ b/x-pack/legacy/plugins/graph/server/lib/__tests__/check_license.js @@ -66,9 +66,9 @@ describe('check_license: ', function () { set(mockLicenseInfo, 'feature', sinon.stub().withArgs('graph').returns({ isEnabled: () => true })); }); - describe('& license is trial or platinum', () => { + describe('& license is >= platinum', () => { beforeEach(() => { - set(mockLicenseInfo, 'license.isOneOf', sinon.stub().withArgs([ 'trial', 'platinum' ]).returns(true)); + set(mockLicenseInfo, 'license.isOneOf', sinon.stub().withArgs([ 'trial', 'platinum', 'enterprise' ]).returns(true)); set(mockLicenseInfo, 'license.getType', () => 'trial'); }); @@ -104,7 +104,7 @@ describe('check_license: ', function () { }); - describe('& license is neither trial nor platinum', () => { + describe('& license is < platinum', () => { beforeEach(() => { set(mockLicenseInfo, 'license.isOneOf', () => false); set(mockLicenseInfo, 'license.getType', () => 'basic'); diff --git a/x-pack/legacy/plugins/graph/server/lib/check_license.js b/x-pack/legacy/plugins/graph/server/lib/check_license.js index 4ddac989a789a..88f79b3e4c829 100644 --- a/x-pack/legacy/plugins/graph/server/lib/check_license.js +++ b/x-pack/legacy/plugins/graph/server/lib/check_license.js @@ -37,7 +37,7 @@ export function checkLicense(xpackLicenseInfo) { }); } - if (xpackLicenseInfo.license.isOneOf([ 'trial', 'platinum' ])) { + if (xpackLicenseInfo.license.isOneOf([ 'trial', 'platinum', 'enterprise' ])) { return { showAppLink: true, enableAppLink: isLicenseActive, diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/__tests__/check_license.js b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/__tests__/check_license.js index 394c2c4735c0c..c4e363bedccda 100644 --- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/__tests__/check_license.js +++ b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/__tests__/check_license.js @@ -59,7 +59,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', () => { diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/check_license.js b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/check_license.js index 91f781575d25f..3025d96c06d2f 100644 --- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/check_license.js +++ b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/check_license.js @@ -25,11 +25,12 @@ export function checkLicense(xpackLicenseInfo) { } const VALID_LICENSE_MODES = [ - 'trial', 'basic', 'standard', 'gold', - 'platinum' + 'platinum', + 'enterprise', + 'trial', ]; const isLicenseModeValid = xpackLicenseInfo.license.isOneOf(VALID_LICENSE_MODES); diff --git a/x-pack/legacy/plugins/license_management/__jest__/__snapshots__/request_trial_extension.test.js.snap b/x-pack/legacy/plugins/license_management/__jest__/__snapshots__/request_trial_extension.test.js.snap index 8670b2c378dca..0f4e8f9b63aa0 100644 --- a/x-pack/legacy/plugins/license_management/__jest__/__snapshots__/request_trial_extension.test.js.snap +++ b/x-pack/legacy/plugins/license_management/__jest__/__snapshots__/request_trial_extension.test.js.snap @@ -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`] = `"
Extend your trial

If you’d like to continue using machine learning, advanced security, and our other awesome Platinum features, request an extension now.

"`; + exports[`RequestTrialExtension component should display when license is active and trial has been used 1`] = `"
Extend your trial

If you’d like to continue using machine learning, advanced security, and our other awesome Platinum features, request an extension now.

"`; exports[`RequestTrialExtension component should display when license is not active and trial has been used 1`] = `"
Extend your trial

If you’d like to continue using machine learning, advanced security, and our other awesome Platinum features, request an extension now.

"`; diff --git a/x-pack/legacy/plugins/license_management/__jest__/__snapshots__/start_trial.test.js.snap b/x-pack/legacy/plugins/license_management/__jest__/__snapshots__/start_trial.test.js.snap index df82a820e9513..9370b77e29560 100644 --- a/x-pack/legacy/plugins/license_management/__jest__/__snapshots__/start_trial.test.js.snap +++ b/x-pack/legacy/plugins/license_management/__jest__/__snapshots__/start_trial.test.js.snap @@ -2,6 +2,8 @@ exports[`StartTrial component when trial is allowed display for basic license 1`] = `"
Start a 30-day trial

Experience what machine learning, advanced security, and all our other Platinum features have to offer.

"`; +exports[`StartTrial component when trial is allowed should display for expired enterprise license 1`] = `"
Start a 30-day trial

Experience what machine learning, advanced security, and all our other Platinum features have to offer.

"`; + exports[`StartTrial component when trial is allowed should display for expired platinum license 1`] = `"
Start a 30-day trial

Experience what machine learning, advanced security, and all our other Platinum features have to offer.

"`; exports[`StartTrial component when trial is allowed should display for gold license 1`] = `"
Start a 30-day trial

Experience what machine learning, advanced security, and all our other Platinum features have to offer.

"`; diff --git a/x-pack/legacy/plugins/license_management/__jest__/request_trial_extension.test.js b/x-pack/legacy/plugins/license_management/__jest__/request_trial_extension.test.js index e990bd48317d1..c3f3ed91d556a 100644 --- a/x-pack/legacy/plugins/license_management/__jest__/request_trial_extension.test.js +++ b/x-pack/legacy/plugins/license_management/__jest__/request_trial_extension.test.js @@ -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( { diff --git a/x-pack/legacy/plugins/license_management/__jest__/start_trial.test.js b/x-pack/legacy/plugins/license_management/__jest__/start_trial.test.js index 928c7df70d0b7..a1e435e7b6c56 100644 --- a/x-pack/legacy/plugins/license_management/__jest__/start_trial.test.js +++ b/x-pack/legacy/plugins/license_management/__jest__/start_trial.test.js @@ -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( diff --git a/x-pack/legacy/plugins/license_management/public/store/reducers/licenseManagement.js b/x-pack/legacy/plugins/license_management/public/store/reducers/licenseManagement.js index 2fa01f1807982..fd93fef31cade 100644 --- a/x-pack/legacy/plugins/license_management/public/store/reducers/licenseManagement.js +++ b/x-pack/legacy/plugins/license_management/public/store/reducers/licenseManagement.js @@ -111,8 +111,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)) ); }; @@ -121,7 +121,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 => { diff --git a/x-pack/legacy/plugins/logstash/server/lib/check_license/__tests__/check_license.js b/x-pack/legacy/plugins/logstash/server/lib/check_license/__tests__/check_license.js index 0a8014c1b8612..79928da6abae9 100755 --- a/x-pack/legacy/plugins/logstash/server/lib/check_license/__tests__/check_license.js +++ b/x-pack/legacy/plugins/logstash/server/lib/check_license/__tests__/check_license.js @@ -59,7 +59,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 diff --git a/x-pack/legacy/plugins/logstash/server/lib/check_license/check_license.js b/x-pack/legacy/plugins/logstash/server/lib/check_license/check_license.js index f09abef932260..6e3ec56d76909 100755 --- a/x-pack/legacy/plugins/logstash/server/lib/check_license/check_license.js +++ b/x-pack/legacy/plugins/logstash/server/lib/check_license/check_license.js @@ -24,7 +24,8 @@ export function checkLicense(xpackLicenseInfo) { 'trial', 'standard', 'gold', - 'platinum' + 'platinum', + 'enterprise' ]; const isLicenseModeValid = xpackLicenseInfo.license.isOneOf(VALID_LICENSE_MODES); diff --git a/x-pack/legacy/plugins/maps/check_license.js b/x-pack/legacy/plugins/maps/check_license.js index 54c423220b68a..9e5397ee5dc75 100644 --- a/x-pack/legacy/plugins/maps/check_license.js +++ b/x-pack/legacy/plugins/maps/check_license.js @@ -21,6 +21,7 @@ export function checkLicense(xPackInfo) { 'standard', 'gold', 'platinum', + 'enterprise', 'trial', ]); diff --git a/x-pack/legacy/plugins/ml/common/constants/license.ts b/x-pack/legacy/plugins/ml/common/constants/license.ts index 23663db69b050..2027e2c8b1865 100644 --- a/x-pack/legacy/plugins/ml/common/constants/license.ts +++ b/x-pack/legacy/plugins/ml/common/constants/license.ts @@ -6,5 +6,5 @@ export enum LICENSE_TYPE { BASIC, - FULL, // platinum or trial + FULL, // >= platinum } diff --git a/x-pack/legacy/plugins/ml/server/lib/check_license/__tests__/check_license.ts b/x-pack/legacy/plugins/ml/server/lib/check_license/check_license.test.ts similarity index 89% rename from x-pack/legacy/plugins/ml/server/lib/check_license/__tests__/check_license.ts rename to x-pack/legacy/plugins/ml/server/lib/check_license/check_license.test.ts index 5a8b4fdcc76db..1d80a226486bb 100644 --- a/x-pack/legacy/plugins/ml/server/lib/check_license/__tests__/check_license.ts +++ b/x-pack/legacy/plugins/ml/server/lib/check_license/check_license.test.ts @@ -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', () => { diff --git a/x-pack/legacy/plugins/ml/server/lib/check_license/check_license.ts b/x-pack/legacy/plugins/ml/server/lib/check_license/check_license.ts index bb92705880dde..c88ab087a8198 100644 --- a/x-pack/legacy/plugins/ml/server/lib/check_license/check_license.ts +++ b/x-pack/legacy/plugins/ml/server/lib/check_license/check_license.ts @@ -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; diff --git a/x-pack/legacy/plugins/monitoring/common/constants.js b/x-pack/legacy/plugins/monitoring/common/constants.js index e40941396b661..5e90c104543e9 100644 --- a/x-pack/legacy/plugins/monitoring/common/constants.js +++ b/x-pack/legacy/plugins/monitoring/common/constants.js @@ -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). diff --git a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/__tests__/check_license.js b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/__tests__/check_license.js index f8dd7a65a184f..4fc6eb90e25b6 100644 --- a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/__tests__/check_license.js +++ b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/__tests__/check_license.js @@ -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); diff --git a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/check_license.js b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/check_license.js index 71f5624e41475..be9ea441fe99c 100644 --- a/x-pack/legacy/plugins/monitoring/server/cluster_alerts/check_license.js +++ b/x-pack/legacy/plugins/monitoring/server/cluster_alerts/check_license.js @@ -35,7 +35,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', { defaultMessage: diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/server/index.ts b/x-pack/legacy/plugins/reporting/export_types/csv/server/index.ts index d752cdcd9779d..ce44b5ba4a331 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/server/index.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv/server/index.ts @@ -17,6 +17,6 @@ export function register(registry: ExportTypesRegistry) { jobContentExtension: 'csv', createJobFactory, executeJobFactory, - validLicenses: ['trial', 'basic', 'standard', 'gold', 'platinum'], + validLicenses: ['trial', 'basic', 'standard', 'gold', 'platinum', 'enterprise'], }); } diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/index.ts b/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/index.ts index b614fd3c681b3..181c5a76ac7af 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/index.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/server/index.ts @@ -17,6 +17,6 @@ export function register(registry: ExportTypesRegistry) { jobContentExtension: 'csv', createJobFactory, executeJobFactory, - validLicenses: ['trial', 'basic', 'standard', 'gold', 'platinum'], + validLicenses: ['trial', 'basic', 'standard', 'gold', 'platinum', 'enterprise'], }); } diff --git a/x-pack/legacy/plugins/reporting/export_types/png/server/index.ts b/x-pack/legacy/plugins/reporting/export_types/png/server/index.ts index a569719f02324..293ae348725b2 100644 --- a/x-pack/legacy/plugins/reporting/export_types/png/server/index.ts +++ b/x-pack/legacy/plugins/reporting/export_types/png/server/index.ts @@ -18,6 +18,6 @@ export function register(registry: ExportTypesRegistry) { jobContentExtension: 'PNG', createJobFactory, executeJobFactory, - validLicenses: ['trial', 'standard', 'gold', 'platinum'], + validLicenses: ['trial', 'standard', 'gold', 'platinum', 'enterprise'], }); } diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/index.ts b/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/index.ts index df798a7af23ec..06e3fb8aa615c 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/index.ts +++ b/x-pack/legacy/plugins/reporting/export_types/printable_pdf/server/index.ts @@ -18,6 +18,6 @@ export function register(registry: ExportTypesRegistry) { jobContentExtension: 'pdf', createJobFactory, executeJobFactory, - validLicenses: ['trial', 'standard', 'gold', 'platinum'], + validLicenses: ['trial', 'standard', 'gold', 'platinum', 'enterprise'], }); } diff --git a/x-pack/legacy/plugins/reporting/server/lib/__tests__/check_license.js b/x-pack/legacy/plugins/reporting/server/lib/__tests__/check_license.js index 480cf4d3e14e2..f7df304af6d7b 100644 --- a/x-pack/legacy/plugins/reporting/server/lib/__tests__/check_license.js +++ b/x-pack/legacy/plugins/reporting/server/lib/__tests__/check_license.js @@ -54,7 +54,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', () => { diff --git a/x-pack/legacy/plugins/rollup/server/lib/check_license/__tests__/check_license.js b/x-pack/legacy/plugins/rollup/server/lib/check_license/__tests__/check_license.js index 394c2c4735c0c..c4e363bedccda 100644 --- a/x-pack/legacy/plugins/rollup/server/lib/check_license/__tests__/check_license.js +++ b/x-pack/legacy/plugins/rollup/server/lib/check_license/__tests__/check_license.js @@ -59,7 +59,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', () => { diff --git a/x-pack/legacy/plugins/rollup/server/lib/check_license/check_license.js b/x-pack/legacy/plugins/rollup/server/lib/check_license/check_license.js index 9740d9b83d6ce..2e1e135adc1e1 100644 --- a/x-pack/legacy/plugins/rollup/server/lib/check_license/check_license.js +++ b/x-pack/legacy/plugins/rollup/server/lib/check_license/check_license.js @@ -31,7 +31,8 @@ export function checkLicense(xpackLicenseInfo) { 'basic', 'standard', 'gold', - 'platinum' + 'platinum', + 'enterprise' ]; const isLicenseModeValid = xpackLicenseInfo.license.isOneOf(VALID_LICENSE_MODES); diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.test.ts b/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.test.ts index f473533fbd48a..1b8155221cb9d 100644 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.test.ts +++ b/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.test.ts @@ -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', () => { diff --git a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.ts b/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.ts index e41925da3e268..2a22d615ca6e5 100644 --- a/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.ts +++ b/x-pack/legacy/plugins/searchprofiler/server/np_ready/lib/check_license.ts @@ -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, diff --git a/x-pack/legacy/plugins/tilemap/server/lib/inspect_settings.js b/x-pack/legacy/plugins/tilemap/server/lib/inspect_settings.js index 95b7b5f89e42a..7df2b8cbdb0c1 100644 --- a/x-pack/legacy/plugins/tilemap/server/lib/inspect_settings.js +++ b/x-pack/legacy/plugins/tilemap/server/lib/inspect_settings.js @@ -19,7 +19,7 @@ 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']) } }; diff --git a/x-pack/legacy/plugins/uptime/server/lib/domains/auth.ts b/x-pack/legacy/plugins/uptime/server/lib/domains/auth.ts index 62d17f121779f..de2bcfd4cf47f 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/domains/auth.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/domains/auth.ts @@ -8,7 +8,7 @@ import Boom from 'boom'; import { get } from 'lodash'; import { UMAuthAdapter } from '../adapters/auth/adapter_types'; -const supportedLicenses = ['basic', 'standard', 'gold', 'platinum', 'trial']; +const supportedLicenses = ['basic', 'standard', 'gold', 'platinum', 'enterprise', 'trial']; export class UMAuthDomain { constructor(private readonly adapter: UMAuthAdapter, libs: {}) { diff --git a/x-pack/plugins/features/server/feature.ts b/x-pack/plugins/features/server/feature.ts index 592ac654655d8..423fe1eb99704 100644 --- a/x-pack/plugins/features/server/feature.ts +++ b/x-pack/plugins/features/server/feature.ts @@ -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. diff --git a/x-pack/plugins/features/server/feature_schema.ts b/x-pack/plugins/features/server/feature_schema.ts index b5ba10f8d0300..3d52401c84595 100644 --- a/x-pack/plugins/features/server/feature_schema.ts +++ b/x-pack/plugins/features/server/feature_schema.ts @@ -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), diff --git a/x-pack/plugins/security/server/licensing/license_service.test.ts b/x-pack/plugins/security/server/licensing/license_service.test.ts index d5d33c07985fd..aa1e420bf4f6c 100644 --- a/x-pack/plugins/security/server/licensing/license_service.test.ts +++ b/x-pack/plugins/security/server/licensing/license_service.test.ts @@ -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 }); diff --git a/x-pack/plugins/security/server/licensing/license_service.ts b/x-pack/plugins/security/server/licensing/license_service.ts index 58c445de9319d..3539309c3acd1 100644 --- a/x-pack/plugins/security/server/licensing/license_service.ts +++ b/x-pack/plugins/security/server/licensing/license_service.ts @@ -69,7 +69,7 @@ export class SecurityLicenseService { }; } - const isLicensePlatinumOrTrial = rawLicense.isOneOf(['platinum', 'trial']); + const isLicensePlatinumOrTrial = rawLicense.isOneOf(['platinum', 'enterprise', 'trial']); return { showLogin: true, allowLogin: true, From 8a109db99188a2793759485f330ae2f9b1012ba5 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 9 Dec 2019 12:15:51 +0100 Subject: [PATCH 3/5] update uptime license list --- x-pack/legacy/plugins/uptime/server/lib/domains/license.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/legacy/plugins/uptime/server/lib/domains/license.ts b/x-pack/legacy/plugins/uptime/server/lib/domains/license.ts index 9c52667aeeab4..947bad75075ef 100644 --- a/x-pack/legacy/plugins/uptime/server/lib/domains/license.ts +++ b/x-pack/legacy/plugins/uptime/server/lib/domains/license.ts @@ -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, From 6536a6284a3ad26c9cd3e27a4aa38679f14551e2 Mon Sep 17 00:00:00 2001 From: restrry Date: Mon, 9 Dec 2019 12:16:18 +0100 Subject: [PATCH 4/5] improve naming in security plugin --- x-pack/plugins/security/server/licensing/license_service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/security/server/licensing/license_service.ts b/x-pack/plugins/security/server/licensing/license_service.ts index 3539309c3acd1..e9e2791efbd17 100644 --- a/x-pack/plugins/security/server/licensing/license_service.ts +++ b/x-pack/plugins/security/server/licensing/license_service.ts @@ -69,14 +69,14 @@ export class SecurityLicenseService { }; } - const isLicensePlatinumOrTrial = rawLicense.isOneOf(['platinum', 'enterprise', '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, }; }, From 0c6bc32cb34e209fc53359112d00d2304ad55093 Mon Sep 17 00:00:00 2001 From: restrry Date: Thu, 12 Dec 2019 11:54:23 +0100 Subject: [PATCH 5/5] update reporting licensing --- x-pack/legacy/plugins/reporting/common/constants.ts | 1 + x-pack/legacy/plugins/reporting/export_types/csv/index.ts | 2 ++ .../reporting/export_types/csv_from_savedobject/index.ts | 2 ++ x-pack/legacy/plugins/reporting/export_types/png/index.ts | 2 ++ .../plugins/reporting/export_types/printable_pdf/index.ts | 2 ++ 5 files changed, 9 insertions(+) diff --git a/x-pack/legacy/plugins/reporting/common/constants.ts b/x-pack/legacy/plugins/reporting/common/constants.ts index 03b2d51c7b396..e602d5fc608d3 100644 --- a/x-pack/legacy/plugins/reporting/common/constants.ts +++ b/x-pack/legacy/plugins/reporting/common/constants.ts @@ -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'; diff --git a/x-pack/legacy/plugins/reporting/export_types/csv/index.ts b/x-pack/legacy/plugins/reporting/export_types/csv/index.ts index 4f8aeb2be0c99..942cb954785ac 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv/index.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv/index.ts @@ -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, ], }); diff --git a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/index.ts b/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/index.ts index 4876cea0b1b28..606630944c604 100644 --- a/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/index.ts +++ b/x-pack/legacy/plugins/reporting/export_types/csv_from_savedobject/index.ts @@ -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, ], }); diff --git a/x-pack/legacy/plugins/reporting/export_types/png/index.ts b/x-pack/legacy/plugins/reporting/export_types/png/index.ts index bc00bc428f306..b6206a8bf9599 100644 --- a/x-pack/legacy/plugins/reporting/export_types/png/index.ts +++ b/x-pack/legacy/plugins/reporting/export_types/png/index.ts @@ -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, ], }); diff --git a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/index.ts b/x-pack/legacy/plugins/reporting/export_types/printable_pdf/index.ts index 99880c1237a7a..b7b71ff5c5741 100644 --- a/x-pack/legacy/plugins/reporting/export_types/printable_pdf/index.ts +++ b/x-pack/legacy/plugins/reporting/export_types/printable_pdf/index.ts @@ -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, ], });