Move consumers off bsearch endpoint (#196962)

## Summary

Part of https://github.com/elastic/kibana/issues/186139.

Moves direct consumers off of the `internal/bsearch` endpoint and onto
the `internal/search`.

This is in preparation for removing the `internal/bsearch` endpoint
entirely.

Updates automated tests to mock/use the correct service moving forward.

### Checklist

- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Dzmitry Lemechko <dzmitry.lemechko@elastic.co>
This commit is contained in:
Lukas Olson 2024-11-07 18:04:18 +01:00 committed by GitHub
parent 3f236b1499
commit 257688d9a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 177 additions and 233 deletions

View file

@ -39,7 +39,7 @@ export type SamlAuthProviderType = ProvidedType<typeof SamlAuthProvider>;
export type { FtrProviderContext } from './services/ftr_provider_context';
export { runSavedObjInfoSvc } from './services/saved_object_info';
export type { BsearchService, SendOptions } from './services/bsearch';
export type { SearchService, SendOptions } from './services/search';
export { SavedObjectInfoService } from './services/saved_object_info';
export { DeploymentService } from './services/deployment';
export { IndexPatternsService } from './services/index_patterns';

View file

@ -11,7 +11,7 @@ import { EsArchiverProvider } from './es_archiver';
import { EsProvider } from './es';
import { KibanaServerProvider } from './kibana_server';
import { RetryService } from './retry';
import { BsearchService } from './bsearch';
import { SearchService } from './search';
import { ConsoleProvider } from './console';
import { DeploymentService } from './deployment';
import { EsDeleteAllIndicesProvider } from './es_delete_all_indices';
@ -27,7 +27,7 @@ export const services = {
kibanaServer: KibanaServerProvider,
esArchiver: EsArchiverProvider,
retry: RetryService,
bsearch: BsearchService,
search: SearchService,
console: ConsoleProvider,
deployment: DeploymentService,
esDeleteAllIndices: EsDeleteAllIndicesProvider,

View file

@ -8,26 +8,11 @@
*/
import expect from '@kbn/expect';
import request from 'superagent';
import type SuperTest from 'supertest';
import type { IEsSearchResponse } from '@kbn/search-types';
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { BFETCH_ROUTE_VERSION_LATEST } from '@kbn/bfetch-plugin/common';
import { FtrService } from './ftr_provider_context';
/**
* Function copied from here:
* test/api_integration/apis/search/bsearch.ts without the compress
*
* Splits the JSON lines from bsearch
*/
const parseBfetchResponse = (resp: request.Response): Array<Record<string, any>> => {
return resp.text
.trim()
.split('\n')
.map((item) => JSON.parse(item));
};
/**
* Function copied from here:
* x-pack/test/rule_registry/common/lib/authentication/spaces.ts
@ -48,13 +33,13 @@ export interface SendOptions {
}
/**
* Bsearch Service that can reduce flake on the CI systems when they are under
* pressure and bsearch returns an async search response or a sync response.
* Search Service that can reduce flake on the CI systems when they are under
* pressure and search returns an async search response or a sync response.
*
* @example
* const supertest = getService('supertest');
* const bsearch = getService('bsearch');
* const response = await bsearch.send<MyType>({
* const search = getService('search');
* const response = await search.send<MyType>({
* supertest,
* options: {
* defaultIndex: ['large_volume_dns_data'],
@ -64,7 +49,7 @@ export interface SendOptions {
* expect(response).eql({ ... your value ... });
*/
export class BsearchService extends FtrService {
export class SearchService extends FtrService {
private readonly retry = this.ctx.getService('retry');
/** Send method to send in your supertest, url, options, and strategy name */
@ -85,26 +70,13 @@ export class BsearchService extends FtrService {
const result = await this.retry.try(async () => {
const resp = await supertest
.post(`${spaceUrl}/internal/bsearch`)
.post(`${spaceUrl}/internal/search/${strategy}/${body.id}`)
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, BFETCH_ROUTE_VERSION_LATEST)
.send({
batch: [
{
request: {
id: body.id,
...options,
},
options: {
strategy,
},
},
],
})
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.send()
.expect(200);
const [parsedResponse] = parseBfetchResponse(resp);
expect(parsedResponse.result.isRunning).equal(false);
return parsedResponse.result as T;
expect(resp.body.isRunning).equal(false);
return resp.body as T;
});
return result;
}

View file

@ -19,7 +19,6 @@
"@kbn/expect",
"@kbn/search-types",
"@kbn/core-http-common",
"@kbn/bfetch-plugin",
"@kbn/data-plugin",
"@kbn/dev-cli-runner",
"@kbn/dev-cli-errors",

View file

@ -21,7 +21,7 @@ const {
esDeleteAllIndices,
savedObjectInfo,
indexPatterns,
bsearch,
search,
console,
supertest,
esSupertest,
@ -42,7 +42,7 @@ export const services = {
esDeleteAllIndices,
savedObjectInfo,
indexPatterns,
bsearch,
search,
console,
supertest,
esSupertest,

View file

@ -151,7 +151,7 @@ export const generateFindingHit = (finding: CspFinding) => {
};
};
const getFindingsBsearchResponse = (findings: CspFinding[]) => {
const getFindingsSearchResponse = (findings: CspFinding[]) => {
const buckets = findings.reduce(
(acc, finding) => {
if (finding.result.evaluation === 'failed') {
@ -174,28 +174,26 @@ const getFindingsBsearchResponse = (findings: CspFinding[]) => {
);
return {
id: 0,
result: {
rawResponse: {
took: 1,
timed_out: false,
_shards: {
total: 1,
successful: 1,
skipped: 0,
failed: 0,
},
hits: {
total: findings.length,
max_score: null,
hits: findings.map(generateFindingHit),
},
aggregations: {
count: {
doc_count_error_upper_bound: 0,
sum_other_doc_count: 0,
buckets,
},
id: '1',
rawResponse: {
took: 1,
timed_out: false,
_shards: {
total: 1,
successful: 1,
skipped: 0,
failed: 0,
},
hits: {
total: findings.length,
max_score: null,
hits: findings.map(generateFindingHit),
},
aggregations: {
count: {
doc_count_error_upper_bound: 0,
sum_other_doc_count: 0,
buckets,
},
},
isPartial: false,
@ -214,8 +212,8 @@ export const rulesGetStatesHandler = http.get(
}
);
export const bsearchFindingsHandler = (findings: CspFinding[]) =>
http.post('internal/bsearch', async ({ request }) => {
export const searchFindingsHandler = (findings: CspFinding[]) =>
http.post('internal/search', async ({ request }) => {
const jsonRequest = (await request.json()) as Partial<estypes.SearchRequest>;
const filter = jsonRequest?.query?.bool?.filter;
@ -233,7 +231,7 @@ export const bsearchFindingsHandler = (findings: CspFinding[]) =>
return finding.rule.section === termValue;
});
return HttpResponse.json(getFindingsBsearchResponse(filteredFindings));
return HttpResponse.json(getFindingsSearchResponse(filteredFindings));
}
const hasRuleSectionFilter =
@ -244,7 +242,7 @@ export const bsearchFindingsHandler = (findings: CspFinding[]) =>
return finding.rule.section === filter?.[0]?.match_phrase?.['rule.section'];
});
return HttpResponse.json(getFindingsBsearchResponse(filteredFindings));
return HttpResponse.json(getFindingsSearchResponse(filteredFindings));
}
const hasResultEvaluationFilter =
@ -255,8 +253,8 @@ export const bsearchFindingsHandler = (findings: CspFinding[]) =>
return finding.result.evaluation === filter?.[0]?.match_phrase?.['result.evaluation'];
});
return HttpResponse.json(getFindingsBsearchResponse(filteredFindings));
return HttpResponse.json(getFindingsSearchResponse(filteredFindings));
}
return HttpResponse.json(getFindingsBsearchResponse(findings));
return HttpResponse.json(getFindingsSearchResponse(findings));
});

View file

@ -20,7 +20,7 @@ import { FilterManager } from '@kbn/data-plugin/public';
import { CspClientPluginStartDeps } from '@kbn/cloud-security-posture';
import * as statusHandlers from '../../../server/routes/status/status.handlers.mock';
import {
bsearchFindingsHandler,
searchFindingsHandler,
generateCspFinding,
generateMultipleCspFindings,
rulesGetStatesHandler,
@ -58,7 +58,7 @@ describe('<Findings />', () => {
const finding2 = generateCspFinding('0004', 'passed');
server.use(statusHandlers.notInstalledHasMisconfigurationsFindingsHandler);
server.use(bsearchFindingsHandler([finding1, finding2]));
server.use(searchFindingsHandler([finding1, finding2]));
renderFindingsPage();
// Loading while checking the status API and fetching the findings
@ -89,7 +89,7 @@ describe('<Findings />', () => {
const finding2 = generateCspFinding('0002', 'passed');
server.use(statusHandlers.indexedHandler);
server.use(bsearchFindingsHandler([finding1, finding2]));
server.use(searchFindingsHandler([finding1, finding2]));
renderFindingsPage();
// Loading while checking the status API
@ -118,7 +118,7 @@ describe('<Findings />', () => {
const finding2 = generateCspFinding('0002', 'passed');
server.use(statusHandlers.indexedHandler);
server.use(bsearchFindingsHandler([finding1, finding2]));
server.use(searchFindingsHandler([finding1, finding2]));
renderFindingsPage();
@ -148,7 +148,7 @@ describe('<Findings />', () => {
const finding2 = generateCspFinding('0002', 'passed');
server.use(statusHandlers.indexedHandler);
server.use(bsearchFindingsHandler([finding1, finding2]));
server.use(searchFindingsHandler([finding1, finding2]));
renderFindingsPage();
@ -180,7 +180,7 @@ describe('<Findings />', () => {
const finding2 = generateCspFinding('0002', 'passed');
server.use(statusHandlers.indexedHandler);
server.use(bsearchFindingsHandler([finding1, finding2]));
server.use(searchFindingsHandler([finding1, finding2]));
renderFindingsPage();
@ -259,7 +259,7 @@ describe('<Findings />', () => {
};
server.use(statusHandlers.indexedHandler);
server.use(bsearchFindingsHandler([finding1, finding2]));
server.use(searchFindingsHandler([finding1, finding2]));
renderFindingsPage(mockDependenciesWithFilter);
@ -286,7 +286,7 @@ describe('<Findings />', () => {
it('renders the distribution bar', async () => {
server.use(statusHandlers.indexedHandler);
server.use(
bsearchFindingsHandler(
searchFindingsHandler(
generateMultipleCspFindings({
count: 10,
failedCount: 3,
@ -316,7 +316,7 @@ describe('<Findings />', () => {
it('filters by passed findings when clicking on the passed findings button', async () => {
server.use(statusHandlers.indexedHandler);
server.use(
bsearchFindingsHandler(
searchFindingsHandler(
generateMultipleCspFindings({
count: 2,
failedCount: 1,
@ -352,7 +352,7 @@ describe('<Findings />', () => {
it('filters by failed findings when clicking on the failed findings button', async () => {
server.use(statusHandlers.indexedHandler);
server.use(
bsearchFindingsHandler(
searchFindingsHandler(
generateMultipleCspFindings({
count: 2,
failedCount: 1,

View file

@ -28,7 +28,7 @@ jest.mock('rxjs', () => {
...actual,
lastValueFrom: async (source: Promise<any>) => {
const value = await source;
return value.result;
return value;
},
};
});
@ -97,7 +97,7 @@ export const getMockServerDependencies = () => {
search: {
...getMockDependencies().data.search,
search: async ({ params }: { params: any }) => {
const response = await fetch(`${MOCK_SERVER_BASE_URL}/internal/bsearch`, {
const response = await fetch(`${MOCK_SERVER_BASE_URL}/internal/search`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',

View file

@ -64,7 +64,7 @@ export const useEsSearch = <DocumentSource extends unknown, TParams extends esty
operationName: name,
kibanaRequest: {
route: {
path: '/internal/bsearch',
path: '/internal/search',
method: 'POST',
},
} as any,
@ -95,7 +95,7 @@ export const useEsSearch = <DocumentSource extends unknown, TParams extends esty
operationName: name,
kibanaRequest: {
route: {
path: '/internal/bsearch',
path: '/internal/search',
method: 'POST',
},
} as any,

View file

@ -50,7 +50,7 @@ export const executeEsQueryAPI = async ({
operationName: name,
kibanaRequest: {
route: {
path: '/internal/bsearch',
path: '/internal/search',
method: 'POST',
},
} as any,
@ -82,7 +82,7 @@ export const executeEsQueryAPI = async ({
operationName: name,
kibanaRequest: {
route: {
path: '/internal/bsearch',
path: '/internal/search',
method: 'POST',
},
} as any,

View file

@ -10,7 +10,7 @@ import { commonFunctionalServices } from '@kbn/ftr-common-functional-services';
import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services';
import { InfraLogViewsServiceProvider } from './infra_log_views';
import { SpacesServiceProvider } from './spaces';
import { BsearchSecureService } from './bsearch_secure';
import { SearchSecureService } from './search_secure';
import { ApmSynthtraceKibanaClientProvider } from './apm_synthtrace_kibana_client';
import { InfraSynthtraceKibanaClientProvider } from './infra_synthtrace_kibana_client';
@ -20,7 +20,7 @@ export const services = {
infraLogViews: InfraLogViewsServiceProvider,
supertest: kibanaApiIntegrationServices.supertest,
spaces: SpacesServiceProvider,
secureBsearch: BsearchSecureService,
secureSearch: SearchSecureService,
apmSynthtraceKibanaClient: ApmSynthtraceKibanaClientProvider,
infraSynthtraceKibanaClient: InfraSynthtraceKibanaClientProvider,
};

View file

@ -38,7 +38,7 @@ interface SendOptions {
internalOrigin: string;
}
export class BsearchSecureService extends FtrService {
export class SearchSecureService extends FtrService {
private readonly retry = this.ctx.getService('retry');
async send<T extends IEsSearchResponse>({
@ -109,24 +109,12 @@ export class BsearchSecureService extends FtrService {
const result = await this.retry.try(async () => {
const resp = await supertestWithoutAuth
.post(`${spaceUrl}/internal/bsearch`)
.post(`${spaceUrl}/internal/search/${strategy}/${body.id}`)
.auth(auth.username, auth.password)
.set('kbn-xsrf', 'true')
.set('x-elastic-internal-origin', 'Kibana')
.set(ELASTIC_HTTP_VERSION_HEADER, BFETCH_ROUTE_VERSION_LATEST)
.send({
batch: [
{
request: {
id: body.id,
...options,
},
options: {
strategy,
},
},
],
})
.send()
.expect(200);
const [parsedResponse] = parseBfetchResponse(resp);
expect(parsedResponse.result.isRunning).equal(false);

View file

@ -26,7 +26,7 @@ type RuleRegistrySearchResponseWithErrors = RuleRegistrySearchResponse & {
export default ({ getService }: FtrProviderContext) => {
const esArchiver = getService('esArchiver');
const supertestWithoutAuth = getService('supertestWithoutAuth');
const secureBsearch = getService('secureBsearch');
const secureSearch = getService('secureSearch');
const kbnClient = getService('kibanaServer');
describe('ruleRegistryAlertsSearchStrategy', () => {
@ -44,7 +44,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should return alerts from log rules', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: logsOnlySpacesAll.username,
@ -66,7 +66,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should support pagination and sorting', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: logsOnlySpacesAll.username,
@ -113,7 +113,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should return alerts from siem rules', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: secOnlySpacesAllEsReadAll.username,
@ -135,7 +135,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should throw an error when trying to to search for more than just siem', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponseWithErrors>({
const result = await secureSearch.send<RuleRegistrySearchResponseWithErrors>({
supertestWithoutAuth,
auth: {
username: secOnlySpacesAllEsReadAll.username,
@ -158,7 +158,7 @@ export default ({ getService }: FtrProviderContext) => {
it('should be able to handle runtime fields on alerts from siem rules', async () => {
const runtimeFieldValue = 'hello world';
const runtimeFieldKey = 'hello_world';
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: secOnlySpacesAllEsReadAll.username,
@ -197,7 +197,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should return alerts from apm rules', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: obsOnlySpacesAll.username,
@ -220,7 +220,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should not by pass our RBAC authz filter with a should filter', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: obsOnlySpacesAll.username,
@ -264,7 +264,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should return an empty response with must filter and our RBAC authz filter', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: obsOnlySpacesAll.username,
@ -304,7 +304,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should not by pass our RBAC authz filter with must_not filter', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: obsOnlySpacesAll.username,
@ -357,7 +357,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should return alerts from .es-query rule type with consumer discover with access only to stack rules', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: stackAlertsOnlyAllSpacesAll.username,
@ -382,7 +382,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should return alerts from .es-query rule type with consumer discover as superuser', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: superUser.username,
@ -407,7 +407,7 @@ export default ({ getService }: FtrProviderContext) => {
});
it('should not return alerts from .es-query rule type with consumer discover without access to stack rules', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponseWithErrors>({
const result = await secureSearch.send<RuleRegistrySearchResponseWithErrors>({
supertestWithoutAuth,
auth: {
username: logsOnlySpacesAll.username,
@ -429,7 +429,7 @@ export default ({ getService }: FtrProviderContext) => {
describe('empty response', () => {
it('should return an empty response', async () => {
const result = await secureBsearch.send<RuleRegistrySearchResponse>({
const result = await secureSearch.send<RuleRegistrySearchResponse>({
supertestWithoutAuth,
auth: {
username: obsOnlySpacesAll.username,

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { BsearchSecureService } from '@kbn/test-suites-serverless/shared/services/bsearch_secure';
import { SearchSecureService } from '@kbn/test-suites-serverless/shared/services/search_secure';
import { services as serverlessServices } from '@kbn/test-suites-serverless/api_integration/services';
import { SpacesServiceProvider } from '../../../common/services/spaces';
import { SecuritySolutionServerlessUtils } from '../services/security_solution_serverless_utils';
@ -14,7 +14,7 @@ import { SecuritySolutionServerlessSuperTest } from '../services/security_soluti
export const services = {
...serverlessServices,
spaces: SpacesServiceProvider,
secureBsearch: BsearchSecureService,
secureSearch: SearchSecureService,
securitySolutionUtils: SecuritySolutionServerlessUtils,
supertest: SecuritySolutionServerlessSuperTest,
};

View file

@ -14,13 +14,13 @@ export function SecuritySolutionESSUtils({
getService,
}: FtrProviderContextWithSpaces): SecuritySolutionESSUtilsInterface {
const config = getService('config');
const bsearch = getService('bsearch');
const search = getService('search');
const supertestWithoutAuth = getService('supertest');
return {
getUsername: (_role?: string) =>
Promise.resolve(config.get('servers.kibana.username') as string),
createBsearch: (_role?: string) => Promise.resolve(bsearch),
createSearch: (_role?: string) => Promise.resolve(search),
createSuperTest: async (role?: string, password: string = 'changeme') => {
if (!role) {
return supertestWithoutAuth;

View file

@ -7,8 +7,8 @@
import { FtrProviderContext } from '../../ftr_provider_context';
export async function SecuritySolutionServerlessBsearchCreator({ getService }: FtrProviderContext) {
const { createBsearch } = getService('securitySolutionUtils');
export async function SecuritySolutionServerlessSearchCreator({ getService }: FtrProviderContext) {
const { createSearch } = getService('securitySolutionUtils');
return await createBsearch('admin');
return await createSearch('admin');
}

View file

@ -10,7 +10,7 @@ import { format as formatUrl } from 'url';
import { IEsSearchResponse } from '@kbn/search-types';
import { RoleCredentials } from '@kbn/test-suites-serverless/shared/services';
import type { SendOptions } from '@kbn/ftr-common-functional-services';
import type { SendOptions as SecureBsearchSendOptions } from '@kbn/test-suites-serverless/shared/services/bsearch_secure';
import type { SendOptions as SecureSearchSendOptions } from '@kbn/test-suites-serverless/shared/services/search_secure';
import type { FtrProviderContext } from '../../ftr_provider_context';
import type { SecuritySolutionUtilsInterface } from './types';
@ -22,7 +22,7 @@ export function SecuritySolutionServerlessUtils({
const svlCommonApi = getService('svlCommonApi');
const config = getService('config');
const log = getService('log');
const SecureBsearch = getService('secureBsearch');
const SecureSearch = getService('secureSearch');
const rolesCredentials = new Map<string, RoleCredentials>();
const commonRequestHeader = svlCommonApi.getCommonRequestHeader();
@ -71,16 +71,16 @@ export function SecuritySolutionServerlessUtils({
*/
createSuperTest,
createBsearch: async (role = 'admin') => {
createSearch: async (role = 'admin') => {
const apiKeyHeader = rolesCredentials.get(role)?.apiKeyHeader;
if (!apiKeyHeader) {
log.error(`API key for role [${role}] is not available, SecureBsearch cannot be created`);
log.error(`API key for role [${role}] is not available, SecureSearch cannot be created`);
}
const send = <T extends IEsSearchResponse>(sendOptions: SendOptions): Promise<T> => {
const { supertest: _, ...rest } = sendOptions;
const serverlessSendOptions: SecureBsearchSendOptions = {
const serverlessSendOptions: SecureSearchSendOptions = {
...rest,
// We need super test WITHOUT auth to make the request here, as we are setting the auth header in bsearch `apiKeyHeader`
supertestWithoutAuth: supertest.agent(kbnUrl),
@ -89,12 +89,12 @@ export function SecuritySolutionServerlessUtils({
};
log.debug(
`Sending request to SecureBsearch with options: ${JSON.stringify(serverlessSendOptions)}`
`Sending request to SecureSearch with options: ${JSON.stringify(serverlessSendOptions)}`
);
return SecureBsearch.send(serverlessSendOptions);
return SecureSearch.send(serverlessSendOptions);
};
return { ...SecureBsearch, send };
return { ...SecureSearch, send };
},
};
}

View file

@ -8,21 +8,21 @@
import TestAgent from 'supertest/lib/agent';
import type { IEsSearchResponse } from '@kbn/search-types';
import type { BsearchSecureService } from '@kbn/test-suites-serverless/shared/services/bsearch_secure';
import type { BsearchService, SendOptions } from '@kbn/ftr-common-functional-services';
import type { SearchSecureService } from '@kbn/test-suites-serverless/shared/services/search_secure';
import type { SearchService, SendOptions } from '@kbn/ftr-common-functional-services';
export interface SecuritySolutionServerlessBsearch extends Omit<BsearchSecureService, 'send'> {
export interface SecuritySolutionServerlessSearch extends Omit<SearchSecureService, 'send'> {
send: <T extends IEsSearchResponse>(options: SendOptions) => Promise<T>;
}
export interface SecuritySolutionUtilsInterface {
getUsername: (role?: string) => Promise<string>;
createSuperTest: (role?: string) => Promise<TestAgent<any>>;
createBsearch: (role?: string) => Promise<SecuritySolutionServerlessBsearch>;
createSearch: (role?: string) => Promise<SecuritySolutionServerlessSearch>;
}
export interface SecuritySolutionESSUtilsInterface {
getUsername: (role?: string) => Promise<string>;
createBsearch: (role?: string) => Promise<BsearchService>;
createSearch: (role?: string) => Promise<SearchService>;
createSuperTest: (role?: string, password?: string) => Promise<TestAgent<any>>;
}

View file

@ -11,7 +11,7 @@ import {
HostsQueries,
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
import { hostDetailsFilebeatExpectedResult } from '../mocks/host_details';
@ -21,11 +21,11 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('Host Details', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
describe('With filebeat', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/filebeat/default');
});
after(
@ -36,7 +36,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
const TO = '3000-01-01T00:00:00.000Z';
it('Make sure that we get HostDetails data', async () => {
const { hostDetails } = await bsearch.send<HostDetailsStrategyResponse>({
const { hostDetails } = await search.send<HostDetailsStrategyResponse>({
supertest,
options: {
factoryQueryType: HostsQueries.details,

View file

@ -16,7 +16,7 @@ import {
FirstLastSeenStrategyResponse,
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
@ -35,10 +35,10 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('hosts', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});
@ -47,7 +47,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
);
it('Make sure that we get Hosts Table data', async () => {
const hosts = await bsearch.send<HostsStrategyResponse>({
const hosts = await search.send<HostsStrategyResponse>({
supertest,
options: {
factoryQueryType: HostsQueries.hosts,
@ -77,7 +77,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('Make sure that pagination is working in Hosts Table query', async () => {
const hosts = await bsearch.send<HostsStrategyResponse>({
const hosts = await search.send<HostsStrategyResponse>({
supertest,
options: {
factoryQueryType: HostsQueries.hosts,
@ -107,7 +107,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('Make sure that we get Host details data', async () => {
const { hostDetails } = await bsearch.send<HostDetailsStrategyResponse>({
const { hostDetails } = await search.send<HostDetailsStrategyResponse>({
supertest,
options: {
factoryQueryType: HostsQueries.details,
@ -146,7 +146,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('Make sure that we get First Seen for a Host', async () => {
const firstLastSeenHost = await bsearch.send<FirstLastSeenStrategyResponse>({
const firstLastSeenHost = await search.send<FirstLastSeenStrategyResponse>({
supertest,
options: {
factoryQueryType: FirstLastSeenQuery,
@ -161,7 +161,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('Make sure that we get Last Seen for a Host', async () => {
const firstLastSeenHost = await bsearch.send<FirstLastSeenStrategyResponse>({
const firstLastSeenHost = await search.send<FirstLastSeenStrategyResponse>({
supertest,
options: {
factoryQueryType: FirstLastSeenQuery,

View file

@ -12,7 +12,7 @@ import {
HostsUncommonProcessesStrategyResponse,
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
const FROM = '2000-01-01T00:00:00.000Z';
@ -27,10 +27,10 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('hosts', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/uncommon_processes');
});
after(async () => {
@ -38,7 +38,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('should return an edge of length 1 when given a pagination of length 1', async () => {
const response = await bsearch.send<HostsUncommonProcessesStrategyResponse>({
const response = await search.send<HostsUncommonProcessesStrategyResponse>({
supertest,
options: {
factoryQueryType: HostsQueries.uncommonProcesses,
@ -65,7 +65,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('when given a pagination of length 2', () => {
it('should return an edge of length 2 ', async () => {
const response = await bsearch.send<HostsUncommonProcessesStrategyResponse>({
const response = await search.send<HostsUncommonProcessesStrategyResponse>({
supertest,
options: {
factoryQueryType: HostsQueries.uncommonProcesses,
@ -93,7 +93,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('when given a pagination of length 1', () => {
let response: HostsUncommonProcessesStrategyResponse | null = null;
before(async () => {
response = await bsearch.send<HostsUncommonProcessesStrategyResponse>({
response = await search.send<HostsUncommonProcessesStrategyResponse>({
supertest,
options: {
factoryQueryType: HostsQueries.uncommonProcesses,

View file

@ -11,7 +11,7 @@ import {
NetworkQueries,
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
@ -21,11 +21,11 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('Network details', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
describe('With filebeat', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/filebeat/default');
});
after(
@ -33,7 +33,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
);
it('Make sure that we get Network details data', async () => {
const body = await bsearch.send<NetworkDetailsStrategyResponse>({
const body = await search.send<NetworkDetailsStrategyResponse>({
supertest,
options: {
ip: '151.205.0.17',
@ -53,7 +53,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('With packetbeat', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/packetbeat/default');
});
after(
@ -61,7 +61,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
);
it('Make sure that we get Network details data', async () => {
const body = await bsearch.send<NetworkDetailsStrategyResponse>({
const body = await search.send<NetworkDetailsStrategyResponse>({
supertest,
options: {
ip: '185.53.91.88',

View file

@ -14,7 +14,7 @@ import {
NetworkDnsStrategyResponse,
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
export default function ({ getService }: FtrProviderContextWithSpaces) {
@ -23,11 +23,11 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('Network DNS', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
describe('With packetbeat', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/packetbeat/dns');
});
after(
@ -38,7 +38,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
const TO = '3000-01-01T00:00:00.000Z';
it('Make sure that we get Dns data and sorting by uniqueDomains ascending', async () => {
const networkDns = await bsearch.send<NetworkDnsStrategyResponse>({
const networkDns = await search.send<NetworkDnsStrategyResponse>({
supertest,
options: {
defaultIndex: ['packetbeat-*'],
@ -66,7 +66,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('Make sure that we get Dns data and sorting by uniqueDomains descending', async () => {
const networkDns = await bsearch.send<NetworkDnsStrategyResponse>({
const networkDns = await search.send<NetworkDnsStrategyResponse>({
supertest,
options: {
ip: '151.205.0.17',

View file

@ -15,7 +15,7 @@ import {
NetworkTopNFlowStrategyResponse,
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
@ -27,11 +27,11 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('Network Top N Flow', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
describe('With filebeat', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/filebeat/default');
});
after(
@ -42,7 +42,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
const TO = '2019-02-12T01:57:24.870Z';
it('should get Source NetworkTopNFlow data with bytes_in descending sort', async () => {
const networkTopNFlow = await bsearch.send<NetworkTopNFlowStrategyResponse>({
const networkTopNFlow = await search.send<NetworkTopNFlowStrategyResponse>({
supertest,
options: {
defaultIndex: ['filebeat-*'],
@ -77,7 +77,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('should get Source NetworkTopNFlow data with bytes_in ascending sort ', async () => {
const networkTopNFlow = await bsearch.send<NetworkTopNFlowStrategyResponse>({
const networkTopNFlow = await search.send<NetworkTopNFlowStrategyResponse>({
supertest,
options: {
defaultIndex: ['filebeat-*'],
@ -114,7 +114,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('should get Destination NetworkTopNFlow data', async () => {
const networkTopNFlow = await bsearch.send<NetworkTopNFlowStrategyResponse>({
const networkTopNFlow = await search.send<NetworkTopNFlowStrategyResponse>({
supertest,
options: {
defaultIndex: ['filebeat-*'],
@ -146,7 +146,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('should paginate NetworkTopNFlow query', async () => {
const networkTopNFlow = await bsearch.send<NetworkTopNFlowStrategyResponse>({
const networkTopNFlow = await search.send<NetworkTopNFlowStrategyResponse>({
supertest,
options: {
defaultIndex: ['filebeat-*'],

View file

@ -15,7 +15,7 @@ import {
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
@ -90,11 +90,11 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('Tls Test with Packetbeat', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
describe('Tls Test', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/packetbeat/tls');
});
after(
@ -102,7 +102,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
);
it('Ensure data is returned for FlowTarget.Source', async () => {
const tls = await bsearch.send<NetworkTlsStrategyResponse>({
const tls = await search.send<NetworkTlsStrategyResponse>({
supertest,
options: {
factoryQueryType: NetworkQueries.tls,
@ -131,7 +131,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('Ensure data is returned for FlowTarget.Destination', async () => {
const tls = await bsearch.send<NetworkTlsStrategyResponse>({
const tls = await search.send<NetworkTlsStrategyResponse>({
supertest,
options: {
factoryQueryType: NetworkQueries.tls,
@ -163,7 +163,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('Tls Overview Test', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/packetbeat/tls');
});
after(
@ -171,7 +171,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
);
it('Ensure data is returned for FlowTarget.Source', async () => {
const tls = await bsearch.send<NetworkTlsStrategyResponse>({
const tls = await search.send<NetworkTlsStrategyResponse>({
supertest,
options: {
factoryQueryType: NetworkQueries.tls,
@ -200,7 +200,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('Ensure data is returned for FlowTarget.Destination', async () => {
const tls = await bsearch.send<NetworkTlsStrategyResponse>({
const tls = await search.send<NetworkTlsStrategyResponse>({
supertest,
options: {
factoryQueryType: NetworkQueries.tls,

View file

@ -12,7 +12,7 @@ import {
HostsOverviewStrategyResponse,
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
export default function ({ getService }: FtrProviderContextWithSpaces) {
@ -21,11 +21,11 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('Overview Host', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
describe('With auditbeat', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/overview');
});
after(
@ -54,7 +54,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
};
it('Make sure that we get OverviewHost data', async () => {
const { overviewHost } = await bsearch.send<HostsOverviewStrategyResponse>({
const { overviewHost } = await search.send<HostsOverviewStrategyResponse>({
supertest,
options: {
defaultIndex: ['auditbeat-*'],

View file

@ -11,7 +11,7 @@ import {
NetworkQueries,
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
export default function ({ getService }: FtrProviderContextWithSpaces) {
@ -20,11 +20,11 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('Overview Network', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
describe('With filebeat', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/filebeat/default');
});
after(
@ -47,7 +47,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
};
it('Make sure that we get OverviewNetwork data', async () => {
const { overviewNetwork } = await bsearch.send<NetworkOverviewStrategyResponse>({
const { overviewNetwork } = await search.send<NetworkOverviewStrategyResponse>({
supertest,
options: {
defaultIndex: ['filebeat-*'],
@ -68,7 +68,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('With packetbeat', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/packetbeat/overview');
});
after(
@ -91,7 +91,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
};
it('Make sure that we get OverviewNetwork data', async () => {
const { overviewNetwork } = await bsearch.send<NetworkOverviewStrategyResponse>({
const { overviewNetwork } = await search.send<NetworkOverviewStrategyResponse>({
supertest,
options: {
defaultIndex: ['packetbeat-*'],
@ -112,7 +112,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('With auditbeat', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/overview');
});
after(
@ -134,7 +134,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
};
it('Make sure that we get OverviewNetwork data', async () => {
const { overviewNetwork } = await bsearch.send<NetworkOverviewStrategyResponse>({
const { overviewNetwork } = await search.send<NetworkOverviewStrategyResponse>({
supertest,
options: {
defaultIndex: ['auditbeat-*'],

View file

@ -15,7 +15,7 @@ import {
import type { UserAuthenticationsRequestOptions } from '@kbn/security-solution-plugin/common/api/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
const FROM = '2000-01-01T00:00:00.000Z';
@ -33,11 +33,11 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('authentications', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});
@ -65,7 +65,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
filterQuery: '',
};
const authentications = await bsearch.send<UserAuthenticationsStrategyResponse>({
const authentications = await search.send<UserAuthenticationsStrategyResponse>({
supertest,
options: requestOptions,
strategy: 'securitySolutionSearchStrategy',
@ -96,7 +96,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
filterQuery: '',
};
const authentications = await bsearch.send<UserAuthenticationsStrategyResponse>({
const authentications = await search.send<UserAuthenticationsStrategyResponse>({
supertest,
options: requestOptions,
strategy: 'securitySolutionSearchStrategy',

View file

@ -15,7 +15,7 @@ import {
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces';
@ -29,11 +29,11 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('Users', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
describe('With auditbeat', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/users');
});
after(
@ -41,7 +41,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
);
it('Ensure data is returned from auditbeat', async () => {
const users = await bsearch.send<NetworkUsersStrategyResponse>({
const users = await search.send<NetworkUsersStrategyResponse>({
supertest,
options: {
factoryQueryType: NetworkQueries.users,

View file

@ -14,7 +14,7 @@ import {
TimelineEventsAllStrategyResponse,
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../ftr_provider_context_with_spaces';
import { getFieldsToRequest, getFilterValue } from '../../../utils';
@ -62,11 +62,11 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
describe('@skipInServerless Timeline', () => {
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/auditbeat/hosts');
});
after(async () => {
@ -74,7 +74,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('returns Timeline data', async () => {
const timeline = await bsearch.send<TimelineEventsAllStrategyResponse>({
const timeline = await search.send<TimelineEventsAllStrategyResponse>({
supertest,
options: {
...getPostBody(),
@ -89,7 +89,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
});
it('returns paginated Timeline query', async () => {
const timeline = await bsearch.send<TimelineEventsAllStrategyResponse>({
const timeline = await search.send<TimelineEventsAllStrategyResponse>({
supertest,
options: {
...getPostBody(),

View file

@ -13,7 +13,7 @@ import {
TimelineKpiStrategyResponse,
} from '@kbn/security-solution-plugin/common/search_strategy';
import TestAgent from 'supertest/lib/agent';
import { BsearchService } from '@kbn/ftr-common-functional-services';
import { SearchService } from '@kbn/ftr-common-functional-services';
import { FtrProviderContextWithSpaces } from '../../../../ftr_provider_context_with_spaces';
import { timelineDetailsFilebeatExpectedResults as EXPECTED_DATA } from '../mocks/timeline_details';
@ -33,12 +33,12 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
const esArchiver = getService('esArchiver');
const utils = getService('securitySolutionUtils');
let supertest: TestAgent;
let bsearch: BsearchService;
let search: SearchService;
describe('@skipInServerless Timeline Details', () => {
before(async () => {
supertest = await utils.createSuperTest();
bsearch = await utils.createBsearch();
search = await utils.createSearch();
await esArchiver.load('x-pack/test/functional/es_archives/filebeat/default');
});
@ -47,7 +47,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
);
it('Make sure that we get Event Details data', async () => {
const { data: detailsData } = await bsearch.send<TimelineEventsDetailsStrategyResponse>({
const { data: detailsData } = await search.send<TimelineEventsDetailsStrategyResponse>({
supertest,
options: {
factoryQueryType: TimelineEventsQueries.details,
@ -62,7 +62,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
it('Make sure that we get kpi data', async () => {
const { destinationIpCount, hostCount, processCount, sourceIpCount, userCount } =
await bsearch.send<TimelineKpiStrategyResponse>({
await search.send<TimelineKpiStrategyResponse>({
supertest,
options: {
factoryQueryType: TimelineEventsQueries.kpi,

View file

@ -983,7 +983,7 @@ export const interceptEsqlQueryFieldsRequest = (
}
});
} else {
cy.intercept('POST', '/internal/bsearch?*', (req) => {
cy.intercept('POST', '/internal/search?*', (req) => {
if (req.body?.batch?.[0]?.request?.params?.query?.includes?.(esqlQuery)) {
req.alias = alias;
}

View file

@ -13,7 +13,6 @@ import { GenericFtrService } from '@kbn/test';
import request from 'superagent';
import type { IEsSearchResponse } from '@kbn/search-types';
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { BFETCH_ROUTE_VERSION_LATEST } from '@kbn/bfetch-plugin/common';
import { SupertestWithoutAuthProviderType } from '@kbn/ftr-common-functional-services';
import { FtrProviderContext } from '../../functional/ftr_provider_context';
@ -35,7 +34,7 @@ export interface SendOptions {
internalOrigin: string;
}
export class BsearchSecureService extends GenericFtrService<FtrProviderContext> {
export class SearchSecureService extends GenericFtrService<FtrProviderContext> {
private readonly retry = this.ctx.getService('retry');
async send<T extends IEsSearchResponse>({
@ -104,24 +103,12 @@ export class BsearchSecureService extends GenericFtrService<FtrProviderContext>
const result = await this.retry.try(async () => {
const resp = await supertestWithoutAuth
.post(`/internal/bsearch`)
.post(`/internal/search/${strategy}/${body.id}`)
.set(apiKeyHeader)
.set('kbn-xsrf', 'true')
.set('x-elastic-internal-origin', 'Kibana')
.set(ELASTIC_HTTP_VERSION_HEADER, BFETCH_ROUTE_VERSION_LATEST)
.send({
batch: [
{
request: {
id: body.id,
...options,
},
options: {
strategy,
},
},
],
})
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.send()
.expect(200);
const [parsedResponse] = parseBfetchResponse(resp);
expect(parsedResponse.result.isRunning).equal(false);