rename legacy client mocks

This commit is contained in:
pgayvallet 2020-06-30 23:06:41 +02:00
parent 71a27bb886
commit e48f3ad6a4
58 changed files with 167 additions and 162 deletions

View file

@ -183,8 +183,8 @@ export const elasticsearchServiceMock = {
createInternalSetup: createInternalSetupContractMock,
createSetup: createSetupContractMock,
createStart: createStartContractMock,
createClusterClient: createClusterClientMock,
createCustomClusterClient: createCustomClusterClientMock,
createScopedClusterClient: createScopedClusterClientMock,
createElasticsearchClient: createElasticsearchClientMock,
createLegacyClusterClient: createClusterClientMock,
createLegacyCustomClusterClient: createCustomClusterClientMock,
createLegacyScopedClusterClient: createScopedClusterClientMock,
createLegacyElasticsearchClient: createElasticsearchClientMock,
};

View file

@ -59,7 +59,7 @@ let coreContext: CoreContext;
const logger = loggingSystemMock.create();
let mockClusterClientInstance: ReturnType<typeof elasticsearchClientMock.createCustomClusterClient>;
let mockLegacyClusterClientInstance: ReturnType<typeof elasticsearchServiceMock.createCustomClusterClient>;
let mockLegacyClusterClientInstance: ReturnType<typeof elasticsearchServiceMock.createLegacyCustomClusterClient>;
beforeEach(() => {
env = Env.createDefault(getEnvOptions());
@ -70,7 +70,7 @@ beforeEach(() => {
MockLegacyClusterClient.mockClear();
MockClusterClient.mockClear();
mockLegacyClusterClientInstance = elasticsearchServiceMock.createCustomClusterClient();
mockLegacyClusterClientInstance = elasticsearchServiceMock.createLegacyCustomClusterClient();
MockLegacyClusterClient.mockImplementation(() => mockLegacyClusterClientInstance);
mockClusterClientInstance = elasticsearchClientMock.createCustomClusterClient();
MockClusterClient.mockImplementation(() => mockClusterClientInstance);

View file

@ -21,7 +21,7 @@ import { elasticsearchServiceMock } from '../../elasticsearch/elasticsearch_serv
export const clusterClientMock = jest.fn();
jest.doMock('../../elasticsearch/legacy/scoped_cluster_client', () => ({
LegacyScopedClusterClient: clusterClientMock.mockImplementation(function () {
return elasticsearchServiceMock.createScopedClusterClient();
return elasticsearchServiceMock.createLegacyScopedClusterClient();
}),
}));
@ -31,7 +31,7 @@ jest.doMock('elasticsearch', () => {
...realES,
// eslint-disable-next-line object-shorthand
Client: function () {
return elasticsearchServiceMock.createElasticsearchClient();
return elasticsearchServiceMock.createLegacyElasticsearchClient();
},
};
});

View file

@ -190,7 +190,7 @@ function createCoreRequestHandlerContextMock() {
},
elasticsearch: {
legacy: {
client: elasticsearchServiceMock.createScopedClusterClient(),
client: elasticsearchServiceMock.createLegacyScopedClusterClient(),
},
},
uiSettings: {

View file

@ -25,7 +25,7 @@ import { KibanaRequest } from 'kibana/server';
const defaultKibanaIndex = '.kibana';
const savedObjectsClient = savedObjectsClientMock.create();
const scopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const scopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
const actionExecutor = actionExecutorMock.create();
const executionEnqueuer = jest.fn();
const request = {} as KibanaRequest;

View file

@ -37,7 +37,7 @@ const createServicesMock = () => {
savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
}
> = {
callCluster: elasticsearchServiceMock.createScopedClusterClient().callAsCurrentUser,
callCluster: elasticsearchServiceMock.createLegacyScopedClusterClient().callAsCurrentUser,
getScopedCallCluster: jest.fn(),
savedObjectsClient: savedObjectsClientMock.create(),
};

View file

@ -58,7 +58,7 @@ const createAlertServicesMock = () => {
alertInstanceFactory: jest
.fn<jest.Mocked<AlertInstance>, [string]>()
.mockReturnValue(alertInstanceFactoryMock),
callCluster: elasticsearchServiceMock.createScopedClusterClient().callAsCurrentUser,
callCluster: elasticsearchServiceMock.createLegacyScopedClusterClient().callAsCurrentUser,
getScopedCallCluster: jest.fn(),
savedObjectsClient: savedObjectsClientMock.create(),
};

View file

@ -20,7 +20,7 @@ export function mockHandlerArguments(
{
alertsClient = alertsClientMock.create(),
listTypes: listTypesRes = [],
esClient = elasticsearchServiceMock.createClusterClient(),
esClient = elasticsearchServiceMock.createLegacyClusterClient(),
}: {
alertsClient?: AlertsClientMock;
listTypes?: AlertType[];

View file

@ -43,7 +43,7 @@ describe('healthRoute', () => {
healthRoute(router, licenseState, encryptedSavedObjects);
const [, handler] = router.get.mock.calls[0];
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockReturnValue(Promise.resolve({}));
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
@ -72,7 +72,7 @@ describe('healthRoute', () => {
healthRoute(router, licenseState, encryptedSavedObjects);
const [, handler] = router.get.mock.calls[0];
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockReturnValue(Promise.resolve({}));
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
@ -96,7 +96,7 @@ describe('healthRoute', () => {
healthRoute(router, licenseState, encryptedSavedObjects);
const [, handler] = router.get.mock.calls[0];
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockReturnValue(Promise.resolve({}));
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
@ -120,7 +120,7 @@ describe('healthRoute', () => {
healthRoute(router, licenseState, encryptedSavedObjects);
const [, handler] = router.get.mock.calls[0];
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockReturnValue(Promise.resolve({ security: {} }));
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
@ -144,7 +144,7 @@ describe('healthRoute', () => {
healthRoute(router, licenseState, encryptedSavedObjects);
const [, handler] = router.get.mock.calls[0];
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockReturnValue(Promise.resolve({ security: { enabled: true } }));
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
@ -168,7 +168,7 @@ describe('healthRoute', () => {
healthRoute(router, licenseState, encryptedSavedObjects);
const [, handler] = router.get.mock.calls[0];
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockReturnValue(
Promise.resolve({ security: { enabled: true, ssl: {} } })
);
@ -194,7 +194,7 @@ describe('healthRoute', () => {
healthRoute(router, licenseState, encryptedSavedObjects);
const [, handler] = router.get.mock.calls[0];
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockReturnValue(
Promise.resolve({ security: { enabled: true, ssl: { http: { enabled: true } } } })
);

View file

@ -15,7 +15,9 @@ import {
const mockRouteContext = ({
core: {
elasticsearch: { legacy: { client: elasticsearchServiceMock.createScopedClusterClient() } },
elasticsearch: {
legacy: { client: elasticsearchServiceMock.createLegacyScopedClusterClient() },
},
},
} as unknown) as RequestHandlerContext;

View file

@ -18,7 +18,7 @@ let clusterClientAdapter: IClusterClientAdapter;
beforeEach(() => {
logger = loggingSystemMock.createLogger();
clusterClient = elasticsearchServiceMock.createClusterClient();
clusterClient = elasticsearchServiceMock.createLegacyClusterClient();
clusterClientAdapter = new ClusterClientAdapter({
logger,
clusterClientPromise: Promise.resolve(clusterClient),

View file

@ -17,7 +17,7 @@ let clusterClient: EsClusterClient;
beforeEach(() => {
logger = loggingSystemMock.createLogger();
clusterClient = elasticsearchServiceMock.createClusterClient();
clusterClient = elasticsearchServiceMock.createLegacyClusterClient();
});
describe('createEsContext', () => {

View file

@ -31,11 +31,14 @@ const flushPromises = (ms = 50) => new Promise((res) => setTimeout(res, ms));
function createCoreSetupWith(esClient: ILegacyClusterClient) {
const coreSetup = coreMock.createSetup();
const coreStart = coreMock.createStart();
coreSetup.getStartServices.mockResolvedValue([
{
...coreMock.createStart(),
elasticsearch: { legacy: { client: esClient, createClient: jest.fn() } },
...coreStart,
elasticsearch: {
...coreStart.elasticsearch,
legacy: { client: esClient, createClient: jest.fn() },
},
},
{},
{},
@ -61,7 +64,7 @@ describe('licensing plugin', () => {
});
it('returns license', async () => {
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockResolvedValue({
license: buildRawLicense(),
features: {},
@ -77,7 +80,7 @@ describe('licensing plugin', () => {
it('observable receives updated licenses', async () => {
const types: LicenseType[] = ['basic', 'gold', 'platinum'];
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockImplementation(() =>
Promise.resolve({
license: buildRawLicense({ type: types.shift() }),
@ -96,7 +99,7 @@ describe('licensing plugin', () => {
});
it('returns a license with error when request fails', async () => {
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockRejectedValue(new Error('test'));
const coreSetup = createCoreSetupWith(esClient);
@ -109,7 +112,7 @@ describe('licensing plugin', () => {
});
it('generate error message when x-pack plugin was not installed', async () => {
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
const error: ElasticsearchError = new Error('reason');
error.status = 400;
esClient.callAsInternalUser.mockRejectedValue(error);
@ -127,7 +130,7 @@ describe('licensing plugin', () => {
const error1 = new Error('reason-1');
const error2 = new Error('reason-2');
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser
.mockRejectedValueOnce(error1)
@ -145,7 +148,7 @@ describe('licensing plugin', () => {
});
it('fetch license immediately without subscriptions', async () => {
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockResolvedValue({
license: buildRawLicense(),
features: {},
@ -161,7 +164,7 @@ describe('licensing plugin', () => {
});
it('logs license details without subscriptions', async () => {
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockResolvedValue({
license: buildRawLicense(),
features: {},
@ -187,7 +190,7 @@ describe('licensing plugin', () => {
it('generates signature based on fetched license content', async () => {
const types: LicenseType[] = ['basic', 'gold', 'basic'];
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockImplementation(() =>
Promise.resolve({
license: buildRawLicense({ type: types.shift() }),
@ -218,7 +221,7 @@ describe('licensing plugin', () => {
api_polling_frequency: moment.duration(50000),
})
);
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockResolvedValue({
license: buildRawLicense(),
features: {},
@ -253,7 +256,7 @@ describe('licensing plugin', () => {
})
);
const esClient = elasticsearchServiceMock.createClusterClient();
const esClient = elasticsearchServiceMock.createLegacyClusterClient();
esClient.callAsInternalUser.mockResolvedValue({
license: buildRawLicense(),
features: {},
@ -262,7 +265,7 @@ describe('licensing plugin', () => {
await plugin.setup(coreSetup);
const { createLicensePoller, license$ } = await plugin.start();
const customClient = elasticsearchServiceMock.createClusterClient();
const customClient = elasticsearchServiceMock.createLegacyClusterClient();
customClient.callAsInternalUser.mockResolvedValue({
license: buildRawLicense({ type: 'gold' }),
features: {},
@ -297,7 +300,7 @@ describe('licensing plugin', () => {
await plugin.setup(coreSetup);
const { createLicensePoller } = await plugin.start();
const customClient = elasticsearchServiceMock.createClusterClient();
const customClient = elasticsearchServiceMock.createLegacyClusterClient();
customClient.callAsInternalUser.mockResolvedValue({
license: buildRawLicense({ type: 'gold' }),
features: {},

View file

@ -49,7 +49,7 @@ const defaultMockTaskDocs = [getMockTaskInstance()];
export const getMockEs = async (
mockCallWithInternal: LegacyAPICaller = getMockCallWithInternal()
) => {
const client = elasticsearchServiceMock.createClusterClient();
const client = elasticsearchServiceMock.createLegacyClusterClient();
(client.callAsInternalUser as any) = mockCallWithInternal;
return client;
};

View file

@ -28,7 +28,7 @@ describe('ADD remote clusters', () => {
{ licenseCheckResult = { valid: true }, apiResponses = [], asserts, payload }: TestOptions
) => {
test(description, async () => {
const elasticsearchMock = elasticsearchServiceMock.createClusterClient();
const elasticsearchMock = elasticsearchServiceMock.createLegacyClusterClient();
const mockRouteDependencies = {
router: httpServiceMock.createRouter(),
@ -40,10 +40,10 @@ describe('ADD remote clusters', () => {
},
};
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
elasticsearchServiceMock
.createClusterClient()
.createLegacyClusterClient()
.asScoped.mockReturnValue(mockScopedClusterClient);
for (const apiResponse of apiResponses) {

View file

@ -30,7 +30,7 @@ describe('DELETE remote clusters', () => {
{ licenseCheckResult = { valid: true }, apiResponses = [], asserts, params }: TestOptions
) => {
test(description, async () => {
const elasticsearchMock = elasticsearchServiceMock.createClusterClient();
const elasticsearchMock = elasticsearchServiceMock.createLegacyClusterClient();
const mockRouteDependencies = {
router: httpServiceMock.createRouter(),
@ -42,10 +42,10 @@ describe('DELETE remote clusters', () => {
},
};
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
elasticsearchServiceMock
.createClusterClient()
.createLegacyClusterClient()
.asScoped.mockReturnValue(mockScopedClusterClient);
for (const apiResponse of apiResponses) {

View file

@ -29,7 +29,7 @@ describe('GET remote clusters', () => {
{ licenseCheckResult = { valid: true }, apiResponses = [], asserts }: TestOptions
) => {
test(description, async () => {
const elasticsearchMock = elasticsearchServiceMock.createClusterClient();
const elasticsearchMock = elasticsearchServiceMock.createLegacyClusterClient();
const mockRouteDependencies = {
router: httpServiceMock.createRouter(),
@ -41,10 +41,10 @@ describe('GET remote clusters', () => {
},
};
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
elasticsearchServiceMock
.createClusterClient()
.createLegacyClusterClient()
.asScoped.mockReturnValue(mockScopedClusterClient);
for (const apiResponse of apiResponses) {

View file

@ -37,7 +37,7 @@ describe('UPDATE remote clusters', () => {
}: TestOptions
) => {
test(description, async () => {
const elasticsearchMock = elasticsearchServiceMock.createClusterClient();
const elasticsearchMock = elasticsearchServiceMock.createLegacyClusterClient();
const mockRouteDependencies = {
router: httpServiceMock.createRouter(),
@ -49,10 +49,10 @@ describe('UPDATE remote clusters', () => {
},
};
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
elasticsearchServiceMock
.createClusterClient()
.createLegacyClusterClient()
.asScoped.mockReturnValue(mockScopedClusterClient);
for (const apiResponse of apiResponses) {

View file

@ -24,8 +24,8 @@ describe('API Keys', () => {
let mockLicense: jest.Mocked<SecurityLicense>;
beforeEach(() => {
mockClusterClient = elasticsearchServiceMock.createClusterClient();
mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
mockClusterClient = elasticsearchServiceMock.createLegacyClusterClient();
mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockClusterClient.asScoped.mockReturnValue(
(mockScopedClusterClient as unknown) as jest.Mocked<ILegacyScopedClusterClient>
);

View file

@ -45,7 +45,7 @@ function getMockOptions({
return {
auditLogger: securityAuditLoggerMock.create(),
getCurrentUser: jest.fn(),
clusterClient: elasticsearchServiceMock.createClusterClient(),
clusterClient: elasticsearchServiceMock.createLegacyClusterClient(),
basePath: httpServiceMock.createSetupContract().basePath,
license: licenseMock.create(),
loggers: loggingSystemMock.create(),

View file

@ -69,7 +69,7 @@ describe('setupAuthentication()', () => {
loggingSystemMock.create().get(),
{ isTLSEnabled: false }
),
clusterClient: elasticsearchServiceMock.createClusterClient(),
clusterClient: elasticsearchServiceMock.createLegacyClusterClient(),
license: licenseMock.create(),
loggers: loggingSystemMock.create(),
getFeatureUsageService: jest
@ -77,7 +77,7 @@ describe('setupAuthentication()', () => {
.mockReturnValue(securityFeatureUsageServiceMock.createStartContract()),
};
mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockSetupAuthenticationParams.clusterClient.asScoped.mockReturnValue(
(mockScopedClusterClient as unknown) as jest.Mocked<LegacyScopedClusterClient>
);

View file

@ -16,7 +16,7 @@ export type MockAuthenticationProviderOptions = ReturnType<
export function mockAuthenticationProviderOptions(options?: { name: string }) {
return {
client: elasticsearchServiceMock.createClusterClient(),
client: elasticsearchServiceMock.createLegacyClusterClient(),
logger: loggingSystemMock.create().get(),
basePath: httpServiceMock.createBasePath(),
tokens: { refresh: jest.fn(), invalidate: jest.fn() },

View file

@ -43,7 +43,7 @@ describe('BasicAuthenticationProvider', () => {
const credentials = { username: 'user', password: 'password' };
const authorization = generateAuthorizationHeader(credentials.username, credentials.password);
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -65,7 +65,7 @@ describe('BasicAuthenticationProvider', () => {
const authorization = generateAuthorizationHeader(credentials.username, credentials.password);
const authenticationError = new Error('Some error');
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(authenticationError);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -147,7 +147,7 @@ describe('BasicAuthenticationProvider', () => {
const user = mockAuthenticatedUser();
const authorization = generateAuthorizationHeader('user', 'password');
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -163,7 +163,7 @@ describe('BasicAuthenticationProvider', () => {
const authorization = generateAuthorizationHeader('user', 'password');
const authenticationError = new Error('Forbidden');
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(authenticationError);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);

View file

@ -126,7 +126,7 @@ describe('HTTPAuthenticationProvider', () => {
]) {
const request = httpServerMock.createKibanaRequest({ headers: { authorization: header } });
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
mockOptions.client.asScoped.mockClear();
@ -156,7 +156,7 @@ describe('HTTPAuthenticationProvider', () => {
]) {
const request = httpServerMock.createKibanaRequest({ headers: { authorization: header } });
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
mockOptions.client.asScoped.mockClear();

View file

@ -47,7 +47,7 @@ describe('KerberosAuthenticationProvider', () => {
it('does not handle requests that can be authenticated without `Negotiate` header.', async () => {
const request = httpServerMock.createKibanaRequest({ headers: {} });
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue({});
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -61,7 +61,7 @@ describe('KerberosAuthenticationProvider', () => {
it('does not handle requests if backend does not support Kerberos.', async () => {
const request = httpServerMock.createKibanaRequest({ headers: {} });
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -82,7 +82,7 @@ describe('KerberosAuthenticationProvider', () => {
body: { error: { header: { 'WWW-Authenticate': 'Negotiate' } } },
})
);
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -101,7 +101,7 @@ describe('KerberosAuthenticationProvider', () => {
const request = httpServerMock.createKibanaRequest({ headers: {} });
const failureReason = new errors.ServiceUnavailable();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -118,7 +118,7 @@ describe('KerberosAuthenticationProvider', () => {
headers: { authorization: 'negotiate spnego' },
});
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
mockOptions.client.callAsInternalUser.mockResolvedValue({
@ -153,7 +153,7 @@ describe('KerberosAuthenticationProvider', () => {
headers: { authorization: 'negotiate spnego' },
});
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
mockOptions.client.callAsInternalUser.mockResolvedValue({
@ -257,7 +257,7 @@ describe('KerberosAuthenticationProvider', () => {
});
const failureReason = LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error());
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
mockOptions.client.callAsInternalUser.mockResolvedValue({
@ -323,7 +323,7 @@ describe('KerberosAuthenticationProvider', () => {
const tokenPair = { accessToken: 'token', refreshToken: 'refresh-token' };
const failureReason = LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error());
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
mockOptions.tokens.refresh.mockResolvedValue(null);
@ -355,7 +355,7 @@ describe('KerberosAuthenticationProvider', () => {
};
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -378,7 +378,7 @@ describe('KerberosAuthenticationProvider', () => {
mockOptions.client.asScoped.mockImplementation((scopeableRequest) => {
if (scopeableRequest?.headers.authorization === `Bearer ${tokenPair.accessToken}`) {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -386,7 +386,7 @@ describe('KerberosAuthenticationProvider', () => {
}
if (scopeableRequest?.headers.authorization === 'Bearer newfoo') {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
return mockScopedClusterClient;
}
@ -423,7 +423,7 @@ describe('KerberosAuthenticationProvider', () => {
};
const failureReason = new errors.InternalServerError('Token is not valid!');
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -450,7 +450,7 @@ describe('KerberosAuthenticationProvider', () => {
body: { error: { header: { 'WWW-Authenticate': 'Negotiate' } } },
})
);
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -475,7 +475,7 @@ describe('KerberosAuthenticationProvider', () => {
body: { error: { header: { 'WWW-Authenticate': 'Negotiate' } } },
})
);
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);

View file

@ -389,7 +389,7 @@ describe('OIDCAuthenticationProvider', () => {
};
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -446,7 +446,7 @@ describe('OIDCAuthenticationProvider', () => {
const authorization = `Bearer ${tokenPair.accessToken}`;
const failureReason = new Error('Token is not valid!');
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -466,7 +466,7 @@ describe('OIDCAuthenticationProvider', () => {
mockOptions.client.asScoped.mockImplementation((scopeableRequest) => {
if (scopeableRequest?.headers.authorization === `Bearer ${tokenPair.accessToken}`) {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -474,7 +474,7 @@ describe('OIDCAuthenticationProvider', () => {
}
if (scopeableRequest?.headers.authorization === 'Bearer new-access-token') {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
return mockScopedClusterClient;
}
@ -514,7 +514,7 @@ describe('OIDCAuthenticationProvider', () => {
const tokenPair = { accessToken: 'expired-token', refreshToken: 'invalid-refresh-token' };
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -554,7 +554,7 @@ describe('OIDCAuthenticationProvider', () => {
'&redirect_uri=https%3A%2F%2Ftest-hostname:1234%2Ftest-base-path%2Fapi%2Fsecurity%2Fv1%2F/oidc',
});
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -602,7 +602,7 @@ describe('OIDCAuthenticationProvider', () => {
const tokenPair = { accessToken: 'expired-token', refreshToken: 'expired-refresh-token' };
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -631,7 +631,7 @@ describe('OIDCAuthenticationProvider', () => {
const tokenPair = { accessToken: 'expired-token', refreshToken: 'expired-refresh-token' };
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);

View file

@ -120,7 +120,7 @@ describe('PKIAuthenticationProvider', () => {
}),
});
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
mockOptions.client.callAsInternalUser.mockResolvedValue({ access_token: 'access-token' });
@ -162,7 +162,7 @@ describe('PKIAuthenticationProvider', () => {
}),
});
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
mockOptions.client.callAsInternalUser.mockResolvedValue({ access_token: 'access-token' });
@ -220,7 +220,7 @@ describe('PKIAuthenticationProvider', () => {
});
const failureReason = LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error());
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
mockOptions.client.callAsInternalUser.mockResolvedValue({ access_token: 'access-token' });
@ -349,7 +349,7 @@ describe('PKIAuthenticationProvider', () => {
});
const state = { accessToken: 'existing-token', peerCertificateFingerprint256: '3A:9A:C5:DD' };
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
mockOptions.client.callAsInternalUser.mockResolvedValue({ access_token: 'access-token' });
@ -392,7 +392,7 @@ describe('PKIAuthenticationProvider', () => {
});
const state = { accessToken: 'existing-token', peerCertificateFingerprint256: '2A:7A:C2:DD' };
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser
// In response to call with an expired token.
.mockRejectedValueOnce(
@ -436,7 +436,7 @@ describe('PKIAuthenticationProvider', () => {
});
const state = { accessToken: 'existing-token', peerCertificateFingerprint256: '2A:7A:C2:DD' };
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValueOnce(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -454,7 +454,7 @@ describe('PKIAuthenticationProvider', () => {
const request = httpServerMock.createKibanaRequest({ socket: getMockSocket() });
const state = { accessToken: 'existing-token', peerCertificateFingerprint256: '2A:7A:C2:DD' };
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -480,7 +480,7 @@ describe('PKIAuthenticationProvider', () => {
}),
});
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -509,7 +509,7 @@ describe('PKIAuthenticationProvider', () => {
});
const failureReason = new errors.ServiceUnavailable();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);

View file

@ -319,7 +319,7 @@ describe('SAMLAuthenticationProvider', () => {
beforeEach(() => {
mockOptions.basePath.get.mockReturnValue(mockOptions.basePath.serverBasePath);
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockImplementation(() =>
Promise.resolve(mockAuthenticatedUser())
);
@ -448,7 +448,7 @@ describe('SAMLAuthenticationProvider', () => {
const authorization = 'Bearer some-valid-token';
const user = mockAuthenticatedUser();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -489,7 +489,7 @@ describe('SAMLAuthenticationProvider', () => {
const authorization = `Bearer ${state.accessToken}`;
const user = mockAuthenticatedUser();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -543,7 +543,7 @@ describe('SAMLAuthenticationProvider', () => {
};
const authorization = `Bearer ${state.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockImplementation(() => response);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -598,7 +598,7 @@ describe('SAMLAuthenticationProvider', () => {
};
const authorization = `Bearer ${state.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockImplementation(() => response);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -663,7 +663,7 @@ describe('SAMLAuthenticationProvider', () => {
};
const authorization = `Bearer ${state.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockImplementation(() => response);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -1061,7 +1061,7 @@ describe('SAMLAuthenticationProvider', () => {
};
const authorization = `Bearer ${state.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -1088,7 +1088,7 @@ describe('SAMLAuthenticationProvider', () => {
const authorization = `Bearer ${state.accessToken}`;
const failureReason = { statusCode: 500, message: 'Token is not valid!' };
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(failureReason);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -1113,7 +1113,7 @@ describe('SAMLAuthenticationProvider', () => {
mockOptions.client.asScoped.mockImplementation((scopeableRequest) => {
if (scopeableRequest?.headers.authorization === `Bearer ${state.accessToken}`) {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -1121,7 +1121,7 @@ describe('SAMLAuthenticationProvider', () => {
}
if (scopeableRequest?.headers.authorization === 'Bearer new-access-token') {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
return mockScopedClusterClient;
}
@ -1165,7 +1165,7 @@ describe('SAMLAuthenticationProvider', () => {
};
const authorization = `Bearer ${state.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -1199,7 +1199,7 @@ describe('SAMLAuthenticationProvider', () => {
};
const authorization = `Bearer ${state.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -1231,7 +1231,7 @@ describe('SAMLAuthenticationProvider', () => {
};
const authorization = `Bearer ${state.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -1263,7 +1263,7 @@ describe('SAMLAuthenticationProvider', () => {
};
const authorization = `Bearer ${state.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -1304,7 +1304,7 @@ describe('SAMLAuthenticationProvider', () => {
redirect: 'https://idp-host/path/login?SAMLRequest=some%20request%20',
});
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);

View file

@ -49,7 +49,7 @@ describe('TokenAuthenticationProvider', () => {
const tokenPair = { accessToken: 'foo', refreshToken: 'bar' };
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -106,7 +106,7 @@ describe('TokenAuthenticationProvider', () => {
});
const authenticationError = new Error('Some error');
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(authenticationError);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -190,7 +190,7 @@ describe('TokenAuthenticationProvider', () => {
const user = mockAuthenticatedUser();
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -213,7 +213,7 @@ describe('TokenAuthenticationProvider', () => {
mockOptions.client.asScoped.mockImplementation((scopeableRequest) => {
if (scopeableRequest?.headers.authorization === `Bearer ${tokenPair.accessToken}`) {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -221,7 +221,7 @@ describe('TokenAuthenticationProvider', () => {
}
if (scopeableRequest?.headers.authorization === 'Bearer newfoo') {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(user);
return mockScopedClusterClient;
}
@ -256,7 +256,7 @@ describe('TokenAuthenticationProvider', () => {
const authorization = `Bearer ${tokenPair.accessToken}`;
const authenticationError = new errors.InternalServerError('something went wrong');
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(authenticationError);
mockOptions.client.asScoped.mockReturnValue(mockScopedClusterClient);
@ -274,7 +274,7 @@ describe('TokenAuthenticationProvider', () => {
const tokenPair = { accessToken: 'foo', refreshToken: 'bar' };
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -300,7 +300,7 @@ describe('TokenAuthenticationProvider', () => {
const tokenPair = { accessToken: 'foo', refreshToken: 'bar' };
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -331,7 +331,7 @@ describe('TokenAuthenticationProvider', () => {
const tokenPair = { accessToken: 'foo', refreshToken: 'bar' };
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -362,7 +362,7 @@ describe('TokenAuthenticationProvider', () => {
const tokenPair = { accessToken: 'foo', refreshToken: 'bar' };
const authorization = `Bearer ${tokenPair.accessToken}`;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -389,7 +389,7 @@ describe('TokenAuthenticationProvider', () => {
const authenticationError = new errors.AuthenticationException('Some error');
mockOptions.client.asScoped.mockImplementation((scopeableRequest) => {
if (scopeableRequest?.headers.authorization === `Bearer ${tokenPair.accessToken}`) {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
LegacyElasticsearchErrorHelpers.decorateNotAuthorizedError(new Error())
);
@ -397,7 +397,7 @@ describe('TokenAuthenticationProvider', () => {
}
if (scopeableRequest?.headers.authorization === 'Bearer newfoo') {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(authenticationError);
return mockScopedClusterClient;
}

View file

@ -18,7 +18,7 @@ describe('Tokens', () => {
let tokens: Tokens;
let mockClusterClient: jest.Mocked<ILegacyClusterClient>;
beforeEach(() => {
mockClusterClient = elasticsearchServiceMock.createClusterClient();
mockClusterClient = elasticsearchServiceMock.createLegacyClusterClient();
const tokensOptions = {
client: mockClusterClient,

View file

@ -56,7 +56,7 @@ afterEach(() => {
});
it(`#setup returns exposed services`, () => {
const mockClusterClient = elasticsearchServiceMock.createClusterClient();
const mockClusterClient = elasticsearchServiceMock.createLegacyClusterClient();
const mockGetSpacesService = jest
.fn()
.mockReturnValue({ getSpaceId: jest.fn(), namespaceToSpaceId: jest.fn() });
@ -119,7 +119,7 @@ describe('#start', () => {
let licenseSubject: BehaviorSubject<SecurityLicenseFeatures>;
let mockLicense: jest.Mocked<SecurityLicense>;
beforeEach(() => {
const mockClusterClient = elasticsearchServiceMock.createClusterClient();
const mockClusterClient = elasticsearchServiceMock.createLegacyClusterClient();
licenseSubject = new BehaviorSubject(({} as unknown) as SecurityLicenseFeatures);
mockLicense = licenseMock.create();
@ -221,7 +221,7 @@ describe('#start', () => {
});
it('#stop unsubscribes from license and ES updates.', () => {
const mockClusterClient = elasticsearchServiceMock.createClusterClient();
const mockClusterClient = elasticsearchServiceMock.createLegacyClusterClient();
const licenseSubject = new BehaviorSubject(({} as unknown) as SecurityLicenseFeatures);
const mockLicense = licenseMock.create();

View file

@ -21,10 +21,10 @@ const mockActions = {
const savedObjectTypes = ['foo-type', 'bar-type'];
const createMockClusterClient = (response: any) => {
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(response);
const mockClusterClient = elasticsearchServiceMock.createClusterClient();
const mockClusterClient = elasticsearchServiceMock.createLegacyClusterClient();
mockClusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
return { mockClusterClient, mockScopedClusterClient };

View file

@ -100,7 +100,7 @@ const registerPrivilegesWithClusterTest = (
};
test(description, async () => {
const mockClusterClient = elasticsearchServiceMock.createClusterClient();
const mockClusterClient = elasticsearchServiceMock.createLegacyClusterClient();
mockClusterClient.callAsInternalUser.mockImplementation(async (api) => {
switch (api) {
case 'shield.getPrivilege': {

View file

@ -43,7 +43,7 @@ describe('Security Plugin', () => {
protocol: 'https',
});
mockClusterClient = elasticsearchServiceMock.createCustomClusterClient();
mockClusterClient = elasticsearchServiceMock.createLegacyCustomClusterClient();
mockCoreSetup.elasticsearch.legacy.createClient.mockReturnValue(mockClusterClient);
mockDependencies = ({

View file

@ -27,7 +27,7 @@ describe('Get API keys', () => {
test(description, async () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
if (apiResponse) {
mockScopedClusterClient.callAsCurrentUser.mockImplementation(apiResponse);

View file

@ -27,7 +27,7 @@ describe('Invalidate API keys', () => {
) => {
test(description, async () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
for (const apiResponse of apiResponses) {
mockScopedClusterClient.callAsCurrentUser.mockImplementationOnce(apiResponse);

View file

@ -48,7 +48,7 @@ describe('Check API keys privileges', () => {
apiKeys.areAPIKeysEnabled()
);
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
for (const apiResponse of callAsCurrentUserResponses) {
mockScopedClusterClient.callAsCurrentUser.mockImplementationOnce(apiResponse);

View file

@ -30,7 +30,7 @@ describe('DELETE role', () => {
test(description, async () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
if (apiResponse) {
mockScopedClusterClient.callAsCurrentUser.mockImplementation(apiResponse);

View file

@ -33,7 +33,7 @@ describe('GET role', () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
mockRouteDefinitionParams.authz.applicationName = application;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
if (apiResponse) {
mockScopedClusterClient.callAsCurrentUser.mockImplementation(apiResponse);

View file

@ -33,7 +33,7 @@ describe('GET all roles', () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
mockRouteDefinitionParams.authz.applicationName = application;
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
if (apiResponse) {
mockScopedClusterClient.callAsCurrentUser.mockImplementation(apiResponse);

View file

@ -72,7 +72,7 @@ const putRoleTest = (
mockRouteDefinitionParams.authz.applicationName = application;
mockRouteDefinitionParams.authz.privileges.get.mockReturnValue(privilegeMap);
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
for (const apiResponse of apiResponses) {
mockScopedClusterClient.callAsCurrentUser.mockImplementationOnce(apiResponse);

View file

@ -21,7 +21,7 @@ export const routeDefinitionParamsMock = {
basePath: httpServiceMock.createBasePath(),
csp: httpServiceMock.createSetupContract().csp,
logger: loggingSystemMock.create().get(),
clusterClient: elasticsearchServiceMock.createClusterClient(),
clusterClient: elasticsearchServiceMock.createLegacyClusterClient(),
config: createConfig(ConfigSchema.validate(config), loggingSystemMock.create().get(), {
isTLSEnabled: false,
}),

View file

@ -13,7 +13,7 @@ describe('DELETE role mappings', () => {
it('allows a role mapping to be deleted', async () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue({ acknowledged: true });

View file

@ -76,7 +76,7 @@ describe('GET role mappings feature check', () => {
test(description, async () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
mockRouteDefinitionParams.clusterClient.callAsInternalUser.mockImplementation(
internalUserClusterClientImpl

View file

@ -53,7 +53,7 @@ describe('GET role mappings', () => {
it('returns all role mappings', async () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue(mockRoleMappingResponse);
@ -128,7 +128,7 @@ describe('GET role mappings', () => {
it('returns role mapping by name', async () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue({
mapping1: {
@ -216,7 +216,7 @@ describe('GET role mappings', () => {
it('returns a 404 when the role mapping is not found', async () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
mockScopedClusterClient.callAsCurrentUser.mockRejectedValue(
Boom.notFound('role mapping not found!')

View file

@ -13,7 +13,7 @@ describe('POST role mappings', () => {
it('allows a role mapping to be created', async () => {
const mockRouteDefinitionParams = routeDefinitionParamsMock.create();
const mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockRouteDefinitionParams.clusterClient.asScoped.mockReturnValue(mockScopedClusterClient);
mockScopedClusterClient.callAsCurrentUser.mockResolvedValue({ created: true });

View file

@ -56,7 +56,7 @@ describe('Change password', () => {
provider: { type: 'basic', name: 'basic' },
});
mockScopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
mockScopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockClusterClient = routeParamsMock.clusterClient;
mockClusterClient.asScoped.mockReturnValue(mockScopedClusterClient);

View file

@ -22,8 +22,8 @@ describe('test alerts route', () => {
let endpointAppContextService: EndpointAppContextService;
beforeEach(() => {
mockClusterClient = elasticsearchServiceMock.createClusterClient();
mockScopedClient = elasticsearchServiceMock.createScopedClusterClient();
mockClusterClient = elasticsearchServiceMock.createLegacyClusterClient();
mockScopedClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockClusterClient.asScoped.mockReturnValue(mockScopedClient);
routerMock = httpServiceMock.createRouter();

View file

@ -59,10 +59,10 @@ describe('test endpoint route', () => {
} as unknown) as SearchResponse<HostId>);
beforeEach(() => {
mockClusterClient = elasticsearchServiceMock.createClusterClient() as jest.Mocked<
mockClusterClient = elasticsearchServiceMock.createLegacyClusterClient() as jest.Mocked<
ILegacyClusterClient
>;
mockScopedClient = elasticsearchServiceMock.createScopedClusterClient();
mockScopedClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockSavedObjectClient = savedObjectsClientMock.create();
mockClusterClient.asScoped.mockReturnValue(mockScopedClient);
routerMock = httpServiceMock.createRouter();

View file

@ -29,7 +29,7 @@ describe('test find all unenrolled HostId', () => {
it('can find all hits with scroll', async () => {
const firstHostId = '1fdca33f-799f-49f4-939c-ea4383c77671';
const secondHostId = '2fdca33f-799f-49f4-939c-ea4383c77672';
mockScopedClient = elasticsearchServiceMock.createScopedClusterClient();
mockScopedClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClient.callAsCurrentUser
.mockImplementationOnce(() => Promise.resolve(createSearchResponse(secondHostId, 'scrollId')))
.mockImplementationOnce(noUnenrolledEndpoint);
@ -46,7 +46,7 @@ describe('test find all unenrolled HostId', () => {
it('can find all unerolled endpoint host ids', async () => {
const firstEndpointHostId = '1fdca33f-799f-49f4-939c-ea4383c77671';
const secondEndpointHostId = '2fdca33f-799f-49f4-939c-ea4383c77672';
mockScopedClient = elasticsearchServiceMock.createScopedClusterClient();
mockScopedClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClient.callAsCurrentUser
.mockImplementationOnce(() =>
Promise.resolve(createSearchResponse(firstEndpointHostId, 'initialScrollId'))
@ -86,7 +86,7 @@ describe('test find unenrolled endpoint host id by hostId', () => {
it('can find unenrolled endpoint by the host id when unenrolled', async () => {
const firstEndpointHostId = '1fdca33f-799f-49f4-939c-ea4383c77671';
mockScopedClient = elasticsearchServiceMock.createScopedClusterClient();
mockScopedClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClient.callAsCurrentUser.mockImplementationOnce(() =>
Promise.resolve(createSearchResponse(firstEndpointHostId, 'initialScrollId'))
);
@ -119,7 +119,7 @@ describe('test find unenrolled endpoint host id by hostId', () => {
it('find unenrolled endpoint host by the host id return undefined when no unenrolled host', async () => {
const firstHostId = '1fdca33f-799f-49f4-939c-ea4383c77671';
mockScopedClient = elasticsearchServiceMock.createScopedClusterClient();
mockScopedClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockScopedClient.callAsCurrentUser.mockImplementationOnce(noUnenrolledEndpoint);
const hostId = await findUnenrolledHostByHostId(mockScopedClient, firstHostId);
expect(hostId).toBeFalsy();

View file

@ -32,7 +32,7 @@ describe('test policy response handler', () => {
let mockResponse: jest.Mocked<KibanaResponseFactory>;
beforeEach(() => {
mockScopedClient = elasticsearchServiceMock.createScopedClusterClient();
mockScopedClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
mockSavedObjectClient = savedObjectsClientMock.create();
mockResponse = httpServerMock.createResponseFactory();
endpointAppContextService = new EndpointAppContextService();

View file

@ -16,7 +16,7 @@ import { siemMock } from '../../../../mocks';
const createMockClients = () => ({
alertsClient: alertsClientMock.create(),
clusterClient: elasticsearchServiceMock.createScopedClusterClient(),
clusterClient: elasticsearchServiceMock.createLegacyScopedClusterClient(),
licensing: { license: licensingMock.createLicenseMock() },
savedObjectsClient: savedObjectsClientMock.create(),
appClient: siemMock.createClient(),

View file

@ -7,7 +7,7 @@
import { MlPluginSetup } from '../../../../ml/server';
import { elasticsearchServiceMock } from '../../../../../../src/core/server/mocks';
const createMockClient = () => elasticsearchServiceMock.createClusterClient();
const createMockClient = () => elasticsearchServiceMock.createLegacyClusterClient();
const createMockMlSystemProvider = () =>
jest.fn(() => ({
mlCapabilities: jest.fn(),

View file

@ -12,7 +12,7 @@ import {
describe('getDeprecationLoggingStatus', () => {
it('calls cluster.getSettings', async () => {
const dataClient = elasticsearchServiceMock.createScopedClusterClient();
const dataClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
await getDeprecationLoggingStatus(dataClient);
expect(dataClient.callAsCurrentUser).toHaveBeenCalledWith('cluster.getSettings', {
includeDefaults: true,
@ -23,7 +23,7 @@ describe('getDeprecationLoggingStatus', () => {
describe('setDeprecationLogging', () => {
describe('isEnabled = true', () => {
it('calls cluster.putSettings with logger.deprecation = WARN', async () => {
const dataClient = elasticsearchServiceMock.createScopedClusterClient();
const dataClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
await setDeprecationLogging(dataClient, true);
expect(dataClient.callAsCurrentUser).toHaveBeenCalledWith('cluster.putSettings', {
body: { transient: { 'logger.deprecation': 'WARN' } },
@ -33,7 +33,7 @@ describe('setDeprecationLogging', () => {
describe('isEnabled = false', () => {
it('calls cluster.putSettings with logger.deprecation = ERROR', async () => {
const dataClient = elasticsearchServiceMock.createScopedClusterClient();
const dataClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
await setDeprecationLogging(dataClient, false);
expect(dataClient.callAsCurrentUser).toHaveBeenCalledWith('cluster.putSettings', {
body: { transient: { 'logger.deprecation': 'ERROR' } },

View file

@ -14,7 +14,7 @@ import fakeDeprecations from './__fixtures__/fake_deprecations.json';
describe('getUpgradeAssistantStatus', () => {
let deprecationsResponse: DeprecationAPIResponse;
const dataClient = elasticsearchServiceMock.createScopedClusterClient();
const dataClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
(dataClient.callAsCurrentUser as jest.Mock).mockImplementation(async (api, { path, index }) => {
if (path === '/_migration/deprecations') {
return deprecationsResponse;

View file

@ -21,7 +21,7 @@ describe('Upgrade Assistant Usage Collector', () => {
let clusterClient: ILegacyClusterClient;
beforeEach(() => {
clusterClient = elasticsearchServiceMock.createClusterClient();
clusterClient = elasticsearchServiceMock.createLegacyClusterClient();
(clusterClient.callAsInternalUser as jest.Mock).mockResolvedValue({
persistent: {},
transient: {

View file

@ -13,7 +13,7 @@ export const routeHandlerContextMock = ({
core: {
elasticsearch: {
legacy: {
client: elasticsearchServiceMock.createScopedClusterClient(),
client: elasticsearchServiceMock.createLegacyScopedClusterClient(),
},
},
savedObjects: { client: savedObjectsClientMock.create() },

View file

@ -51,7 +51,7 @@ type MockCallES = (method: any, params: any) => Promise<any>;
const setupMock = (
criteria: MultiPageCriteria[]
): [MockCallES, jest.Mocked<Pick<LegacyScopedClusterClient, 'callAsCurrentUser'>>] => {
const esMock = elasticsearchServiceMock.createScopedClusterClient();
const esMock = elasticsearchServiceMock.createLegacyScopedClusterClient();
criteria.forEach(({ after_key, bucketCriteria }) => {
const mockResponse = {