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

Allow Enterprise license for service map #62371

Merged
merged 1 commit into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions x-pack/plugins/apm/common/service_map.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
});
});
5 changes: 1 addition & 4 deletions x-pack/plugins/apm/common/service_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down