From 3b41f0d988e7d78ffe17f76073ff6614ce4b26cd Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Thu, 2 Apr 2020 16:44:29 -0500 Subject: [PATCH] Allow Enterprise license for service map (#62371) We were previously only allowing "platinum" and "trial". Change this to allow `hasAtLeast('platinum')` which includes "platinum", "enterprise", and "trial". Fixes #62243. --- x-pack/plugins/apm/common/service_map.test.ts | 97 +++++++++++++++++++ x-pack/plugins/apm/common/service_map.ts | 5 +- 2 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 x-pack/plugins/apm/common/service_map.test.ts diff --git a/x-pack/plugins/apm/common/service_map.test.ts b/x-pack/plugins/apm/common/service_map.test.ts new file mode 100644 index 0000000000000..40b220ffe68f1 --- /dev/null +++ b/x-pack/plugins/apm/common/service_map.test.ts @@ -0,0 +1,97 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { License } from '../../licensing/common/license'; +import * as serviceMap from './service_map'; + +describe('service map helpers', () => { + describe('isValidPlatinumLicense', () => { + describe('with an expired license', () => { + it('returns false', () => { + const license = new License({ + license: { + uid: 'test uid', + expiryDateInMillis: 0, + mode: 'platinum', + type: 'platinum', + status: 'expired' + }, + signature: 'test signature' + }); + + expect(serviceMap.isValidPlatinumLicense(license)).toEqual(false); + }); + }); + + describe('with a basic license', () => { + it('returns false', () => { + const license = new License({ + license: { + uid: 'test uid', + expiryDateInMillis: 0, + mode: 'basic', + type: 'basic', + status: 'active' + }, + signature: 'test signature' + }); + + expect(serviceMap.isValidPlatinumLicense(license)).toEqual(false); + }); + }); + + describe('with a platinum license', () => { + it('returns true', () => { + const license = new License({ + license: { + uid: 'test uid', + expiryDateInMillis: 0, + mode: 'platinum', + type: 'platinum', + status: 'active' + }, + signature: 'test signature' + }); + + expect(serviceMap.isValidPlatinumLicense(license)).toEqual(true); + }); + }); + + describe('with an enterprise license', () => { + it('returns true', () => { + const license = new License({ + license: { + uid: 'test uid', + expiryDateInMillis: 0, + mode: 'enterprise', + type: 'enterprise', + status: 'active' + }, + signature: 'test signature' + }); + + expect(serviceMap.isValidPlatinumLicense(license)).toEqual(true); + }); + }); + + describe('with a trial license', () => { + it('returns true', () => { + const license = new License({ + license: { + uid: 'test uid', + expiryDateInMillis: 0, + mode: 'trial', + type: 'trial', + status: 'active' + }, + signature: 'test signature' + }); + + expect(serviceMap.isValidPlatinumLicense(license)).toEqual(true); + }); + }); + }); +}); diff --git a/x-pack/plugins/apm/common/service_map.ts b/x-pack/plugins/apm/common/service_map.ts index 4a8608199c037..75c1c945c5d26 100644 --- a/x-pack/plugins/apm/common/service_map.ts +++ b/x-pack/plugins/apm/common/service_map.ts @@ -45,10 +45,7 @@ export interface ServiceNodeMetrics { } export function isValidPlatinumLicense(license: ILicense) { - return ( - license.isActive && - (license.type === 'platinum' || license.type === 'trial') - ); + return license.isActive && license.hasAtLeast('platinum'); } export const invalidLicenseMessage = i18n.translate(