Skip to content

Commit

Permalink
Rename isValidPlatinumLicense to isActivePlatinumLicense
Browse files Browse the repository at this point in the history
  • Loading branch information
dgieselaar committed Sep 10, 2020
1 parent 3027310 commit 137d0b1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions x-pack/plugins/apm/common/service_map.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { License } from '../../licensing/common/license';
import * as serviceMap from './service_map';

describe('service map helpers', () => {
describe('isValidPlatinumLicense', () => {
describe('isActivePlatinumLicense', () => {
describe('with an expired license', () => {
it('returns false', () => {
const license = new License({
Expand All @@ -22,7 +22,7 @@ describe('service map helpers', () => {
signature: 'test signature',
});

expect(serviceMap.isValidPlatinumLicense(license)).toEqual(false);
expect(serviceMap.isActivePlatinumLicense(license)).toEqual(false);
});
});

Expand All @@ -39,7 +39,7 @@ describe('service map helpers', () => {
signature: 'test signature',
});

expect(serviceMap.isValidPlatinumLicense(license)).toEqual(false);
expect(serviceMap.isActivePlatinumLicense(license)).toEqual(false);
});
});

Expand All @@ -56,7 +56,7 @@ describe('service map helpers', () => {
signature: 'test signature',
});

expect(serviceMap.isValidPlatinumLicense(license)).toEqual(true);
expect(serviceMap.isActivePlatinumLicense(license)).toEqual(true);
});
});

Expand All @@ -73,7 +73,7 @@ describe('service map helpers', () => {
signature: 'test signature',
});

expect(serviceMap.isValidPlatinumLicense(license)).toEqual(true);
expect(serviceMap.isActivePlatinumLicense(license)).toEqual(true);
});
});

Expand All @@ -90,7 +90,7 @@ describe('service map helpers', () => {
signature: 'test signature',
});

expect(serviceMap.isValidPlatinumLicense(license)).toEqual(true);
expect(serviceMap.isActivePlatinumLicense(license)).toEqual(true);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/common/service_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface ServiceNodeStats {
avgErrorRate: number | null;
}

export function isValidPlatinumLicense(license: ILicense) {
export function isActivePlatinumLicense(license: ILicense) {
return license.isActive && license.hasAtLeast('platinum');
}

Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/apm/public/components/app/ServiceMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { useTheme } from '../../../hooks/useTheme';
import {
invalidLicenseMessage,
isValidPlatinumLicense,
isActivePlatinumLicense,
} from '../../../../common/service_map';
import { useFetcher } from '../../../hooks/useFetcher';
import { useLicense } from '../../../hooks/useLicense';
Expand All @@ -36,7 +36,7 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {

const { data = { elements: [] } } = useFetcher(() => {
// When we don't have a license or a valid license, don't make the request.
if (!license || !isValidPlatinumLicense(license)) {
if (!license || !isActivePlatinumLicense(license)) {
return;
}

Expand Down Expand Up @@ -66,7 +66,7 @@ export function ServiceMap({ serviceName }: ServiceMapProps) {
return null;
}

return isValidPlatinumLicense(license) ? (
return isActivePlatinumLicense(license) ? (
<div
style={{
height: height - parseInt(theme.eui.gutterTypes.gutterLarge, 10),
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/apm/server/lib/helpers/setup_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import moment from 'moment';
import { isValidPlatinumLicense } from '../../../common/service_map';
import { isActivePlatinumLicense } from '../../../common/service_map';
import { UI_SETTINGS } from '../../../../../../src/plugins/data/common';
import { KibanaRequest } from '../../../../../../src/core/server';
import { APMConfig } from '../..';
Expand Down Expand Up @@ -100,7 +100,7 @@ export async function setupRequest<TParams extends SetupRequestParams>(
request,
}),
ml:
context.plugins.ml && isValidPlatinumLicense(context.licensing.license)
context.plugins.ml && isActivePlatinumLicense(context.licensing.license)
? getMlSetup(
context.plugins.ml,
context.core.savedObjects.client,
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/apm/server/routes/service_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Boom from 'boom';
import * as t from 'io-ts';
import {
invalidLicenseMessage,
isValidPlatinumLicense,
isActivePlatinumLicense,
} from '../../common/service_map';
import { setupRequest } from '../lib/helpers/setup_request';
import { getServiceMap } from '../lib/service_map/get_service_map';
Expand All @@ -33,7 +33,7 @@ export const serviceMapRoute = createRoute(() => ({
if (!context.config['xpack.apm.serviceMapEnabled']) {
throw Boom.notFound();
}
if (!isValidPlatinumLicense(context.licensing.license)) {
if (!isActivePlatinumLicense(context.licensing.license)) {
throw Boom.forbidden(invalidLicenseMessage);
}
context.licensing.featureUsage.notifyUsage(APM_SERVICE_MAPS_FEATURE_NAME);
Expand All @@ -59,7 +59,7 @@ export const serviceMapServiceNodeRoute = createRoute(() => ({
if (!context.config['xpack.apm.serviceMapEnabled']) {
throw Boom.notFound();
}
if (!isValidPlatinumLicense(context.licensing.license)) {
if (!isActivePlatinumLicense(context.licensing.license)) {
throw Boom.forbidden(invalidLicenseMessage);
}
const logger = context.logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import * as t from 'io-ts';
import Boom from 'boom';
import { isValidPlatinumLicense } from '../../../common/service_map';
import { isActivePlatinumLicense } from '../../../common/service_map';
import { ML_ERRORS } from '../../../common/anomaly_detection';
import { createRoute } from '../create_route';
import { getAnomalyDetectionJobs } from '../../lib/anomaly_detection/get_anomaly_detection_jobs';
Expand All @@ -25,7 +25,7 @@ export const anomalyDetectionJobsRoute = createRoute(() => ({
handler: async ({ context, request }) => {
const setup = await setupRequest(context, request);

if (!isValidPlatinumLicense(context.licensing.license)) {
if (!isActivePlatinumLicense(context.licensing.license)) {
throw Boom.forbidden(ML_ERRORS.INVALID_LICENSE);
}

Expand Down Expand Up @@ -56,7 +56,7 @@ export const createAnomalyDetectionJobsRoute = createRoute(() => ({
const { environments } = context.params.body;
const setup = await setupRequest(context, request);

if (!isValidPlatinumLicense(context.licensing.license)) {
if (!isActivePlatinumLicense(context.licensing.license)) {
throw Boom.forbidden(ML_ERRORS.INVALID_LICENSE);
}

Expand Down

0 comments on commit 137d0b1

Please sign in to comment.