File tree Expand file tree Collapse file tree 4 files changed +29
-9
lines changed Expand file tree Collapse file tree 4 files changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import { licensingMock } from './plugins/licensing/server/mocks';
99function createCoreRequestHandlerContextMock ( ) {
1010 return {
1111 core : coreMock . createRequestHandlerContext ( ) ,
12- licensing : { license : licensingMock . createLicense ( ) } ,
12+ licensing : licensingMock . createRequestHandlerContext ( ) ,
1313 } ;
1414}
1515
Original file line number Diff line number Diff line change @@ -16,9 +16,7 @@ import { FeatureConfig } from '../../common';
1616function createContextMock ( licenseType : LicenseType = 'gold' ) {
1717 return {
1818 core : coreMock . createRequestHandlerContext ( ) ,
19- licensing : {
20- license : licensingMock . createLicense ( { license : { type : licenseType } } ) ,
21- } ,
19+ licensing : licensingMock . createRequestHandlerContext ( { license : { type : licenseType } } ) ,
2220 } ;
2321}
2422
Original file line number Diff line number Diff line change 44 * you may not use this file except in compliance with the Elastic License.
55 */
66import { BehaviorSubject } from 'rxjs' ;
7- import { LicensingPluginSetup , LicensingPluginStart } from './types' ;
7+ import {
8+ LicensingPluginSetup ,
9+ LicensingPluginStart ,
10+ LicensingRequestHandlerContext ,
11+ } from './types' ;
812import { licenseMock } from '../common/licensing.mock' ;
913import { featureUsageMock } from './services/feature_usage_service.mock' ;
1014
@@ -43,8 +47,20 @@ const createStartMock = (): jest.Mocked<LicensingPluginStart> => {
4347 return mock ;
4448} ;
4549
50+ const createRequestHandlerContextMock = (
51+ ...options : Parameters < typeof licenseMock . createLicense >
52+ ) : jest . Mocked < LicensingRequestHandlerContext > => {
53+ const mock : jest . Mocked < LicensingRequestHandlerContext > = {
54+ license : licenseMock . createLicense ( ...options ) ,
55+ featureUsage : featureUsageMock . createStart ( ) ,
56+ } ;
57+
58+ return mock ;
59+ } ;
60+
4661export const licensingMock = {
4762 createSetup : createSetupMock ,
4863 createStart : createStartMock ,
64+ createRequestHandlerContext : createRequestHandlerContextMock ,
4965 ...licenseMock ,
5066} ;
Original file line number Diff line number Diff line change @@ -40,12 +40,18 @@ export interface RawLicense {
4040 mode : LicenseType ;
4141}
4242
43+ /**
44+ * The APIs exposed on the `licensing` key of {@link RequestHandlerContext} for plugins that depend on licensing.
45+ * @public
46+ */
47+ export interface LicensingRequestHandlerContext {
48+ featureUsage : FeatureUsageServiceStart ;
49+ license : ILicense ;
50+ }
51+
4352declare module 'src/core/server' {
4453 interface RequestHandlerContext {
45- licensing : {
46- featureUsage : FeatureUsageServiceStart ;
47- license : ILicense ;
48- } ;
54+ licensing : LicensingRequestHandlerContext ;
4955 }
5056}
5157
You can’t perform that action at this time.
0 commit comments