From 255404d997b41ca30037a5c3bf4e9fed7323208d Mon Sep 17 00:00:00 2001 From: Lukas Olson Date: Thu, 7 Nov 2024 18:04:18 +0100 Subject: [PATCH] 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 --- .../index.ts | 2 +- .../services/all.ts | 4 +- .../services/{bsearch.ts => search.ts} | 48 ++++------------ .../tsconfig.json | 1 - test/common/services/index.ts | 4 +- .../configurations.handlers.mock.ts | 56 +++++++++---------- .../configurations/configurations.test.tsx | 20 +++---- .../public/test/mock_server/mock_server.ts | 4 +- .../public/hooks/use_es_search.ts | 4 +- .../synthetics/state/elasticsearch/api.ts | 4 +- x-pack/test/common/services/index.ts | 4 +- .../{bsearch_secure.ts => search_secure.ts} | 18 +----- .../tests/basic/search_strategy.ts | 28 +++++----- .../config/serverless/services.ts | 4 +- .../services/security_solution_ess_utils.ts | 4 +- ...ity_solution_serverless_bsearch_creator.ts | 6 +- .../security_solution_serverless_utils.ts | 16 +++--- .../config/services/types.ts | 10 ++-- .../tests/host_details.ts | 8 +-- .../tests/hosts.ts | 16 +++--- .../tests/uncommon_processes.ts | 12 ++-- .../tests/network_details.ts | 12 ++-- .../tests/network_dns.ts | 10 ++-- .../tests/network_top_n_flow.ts | 14 ++--- .../trial_license_complete_tier/tests/tls.ts | 16 +++--- .../tests/overview_host.ts | 8 +-- .../tests/overview_network.ts | 16 +++--- .../tests/authentications.ts | 10 ++-- .../tests/users.ts | 8 +-- .../investigation/timeline/tests/events.ts | 10 ++-- .../timeline/tests/timeline_details.ts | 10 ++-- .../cypress/tasks/create_new_rule.ts | 2 +- .../{bsearch_secure.ts => search_secure.ts} | 21 ++----- 33 files changed, 177 insertions(+), 233 deletions(-) rename packages/kbn-ftr-common-functional-services/services/{bsearch.ts => search.ts} (63%) rename x-pack/test/common/services/{bsearch_secure.ts => search_secure.ts} (91%) rename x-pack/test_serverless/shared/services/{bsearch_secure.ts => search_secure.ts} (87%) diff --git a/packages/kbn-ftr-common-functional-services/index.ts b/packages/kbn-ftr-common-functional-services/index.ts index a975c175c5837..10ded3da0d352 100644 --- a/packages/kbn-ftr-common-functional-services/index.ts +++ b/packages/kbn-ftr-common-functional-services/index.ts @@ -39,7 +39,7 @@ export type SamlAuthProviderType = ProvidedType; 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'; diff --git a/packages/kbn-ftr-common-functional-services/services/all.ts b/packages/kbn-ftr-common-functional-services/services/all.ts index 2caec10c10eb8..dd11b2b914b08 100644 --- a/packages/kbn-ftr-common-functional-services/services/all.ts +++ b/packages/kbn-ftr-common-functional-services/services/all.ts @@ -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, diff --git a/packages/kbn-ftr-common-functional-services/services/bsearch.ts b/packages/kbn-ftr-common-functional-services/services/search.ts similarity index 63% rename from packages/kbn-ftr-common-functional-services/services/bsearch.ts rename to packages/kbn-ftr-common-functional-services/services/search.ts index 0fc39cb87cd8e..c087f1d8bb913 100644 --- a/packages/kbn-ftr-common-functional-services/services/bsearch.ts +++ b/packages/kbn-ftr-common-functional-services/services/search.ts @@ -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> => { - 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({ + * const search = getService('search'); + * const response = await search.send({ * 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; } diff --git a/packages/kbn-ftr-common-functional-services/tsconfig.json b/packages/kbn-ftr-common-functional-services/tsconfig.json index 2cad85eb14fb2..e5239f467ba48 100644 --- a/packages/kbn-ftr-common-functional-services/tsconfig.json +++ b/packages/kbn-ftr-common-functional-services/tsconfig.json @@ -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", diff --git a/test/common/services/index.ts b/test/common/services/index.ts index a2b80c01a18b0..c3fcdda2cf937 100644 --- a/test/common/services/index.ts +++ b/test/common/services/index.ts @@ -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, diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts b/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts index be08984c16dbe..e31ce74ee945b 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.handlers.mock.ts @@ -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; 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)); }); diff --git a/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.test.tsx b/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.test.tsx index 8f1a8f159ced5..cd834f4606356 100644 --- a/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.test.tsx +++ b/x-pack/plugins/cloud_security_posture/public/pages/configurations/configurations.test.tsx @@ -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('', () => { 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('', () => { 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('', () => { 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('', () => { 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('', () => { 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('', () => { }; server.use(statusHandlers.indexedHandler); - server.use(bsearchFindingsHandler([finding1, finding2])); + server.use(searchFindingsHandler([finding1, finding2])); renderFindingsPage(mockDependenciesWithFilter); @@ -286,7 +286,7 @@ describe('', () => { it('renders the distribution bar', async () => { server.use(statusHandlers.indexedHandler); server.use( - bsearchFindingsHandler( + searchFindingsHandler( generateMultipleCspFindings({ count: 10, failedCount: 3, @@ -316,7 +316,7 @@ describe('', () => { 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('', () => { 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, diff --git a/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server.ts b/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server.ts index 86ec3e3108f27..1c5480f339a64 100644 --- a/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server.ts +++ b/x-pack/plugins/cloud_security_posture/public/test/mock_server/mock_server.ts @@ -28,7 +28,7 @@ jest.mock('rxjs', () => { ...actual, lastValueFrom: async (source: Promise) => { 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', diff --git a/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_es_search.ts b/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_es_search.ts index ef38cf13a8c2a..1560df88c7873 100644 --- a/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_es_search.ts +++ b/x-pack/plugins/observability_solution/observability_shared/public/hooks/use_es_search.ts @@ -64,7 +64,7 @@ export const useEsSearch = ({ @@ -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); diff --git a/x-pack/test/rule_registry/security_and_spaces/tests/basic/search_strategy.ts b/x-pack/test/rule_registry/security_and_spaces/tests/basic/search_strategy.ts index 289fe4347e8f6..ffcd6fee5cf85 100644 --- a/x-pack/test/rule_registry/security_and_spaces/tests/basic/search_strategy.ts +++ b/x-pack/test/rule_registry/security_and_spaces/tests/basic/search_strategy.ts @@ -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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ 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({ + const result = await secureSearch.send({ supertestWithoutAuth, auth: { username: obsOnlySpacesAll.username, diff --git a/x-pack/test/security_solution_api_integration/config/serverless/services.ts b/x-pack/test/security_solution_api_integration/config/serverless/services.ts index 61b6c484ced3d..a7e9be3588842 100644 --- a/x-pack/test/security_solution_api_integration/config/serverless/services.ts +++ b/x-pack/test/security_solution_api_integration/config/serverless/services.ts @@ -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, }; diff --git a/x-pack/test/security_solution_api_integration/config/services/security_solution_ess_utils.ts b/x-pack/test/security_solution_api_integration/config/services/security_solution_ess_utils.ts index 158ef1e3756b3..971fe91ea8d74 100644 --- a/x-pack/test/security_solution_api_integration/config/services/security_solution_ess_utils.ts +++ b/x-pack/test/security_solution_api_integration/config/services/security_solution_ess_utils.ts @@ -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; diff --git a/x-pack/test/security_solution_api_integration/config/services/security_solution_serverless_bsearch_creator.ts b/x-pack/test/security_solution_api_integration/config/services/security_solution_serverless_bsearch_creator.ts index 3a0f7391c1ff7..b8e2c13f54be6 100644 --- a/x-pack/test/security_solution_api_integration/config/services/security_solution_serverless_bsearch_creator.ts +++ b/x-pack/test/security_solution_api_integration/config/services/security_solution_serverless_bsearch_creator.ts @@ -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'); } diff --git a/x-pack/test/security_solution_api_integration/config/services/security_solution_serverless_utils.ts b/x-pack/test/security_solution_api_integration/config/services/security_solution_serverless_utils.ts index 00df4f0374c27..1c41ba20bb6f7 100644 --- a/x-pack/test/security_solution_api_integration/config/services/security_solution_serverless_utils.ts +++ b/x-pack/test/security_solution_api_integration/config/services/security_solution_serverless_utils.ts @@ -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(); 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 = (sendOptions: SendOptions): Promise => { 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 }; }, }; } diff --git a/x-pack/test/security_solution_api_integration/config/services/types.ts b/x-pack/test/security_solution_api_integration/config/services/types.ts index 838f31e69412e..d173ffb6181fb 100644 --- a/x-pack/test/security_solution_api_integration/config/services/types.ts +++ b/x-pack/test/security_solution_api_integration/config/services/types.ts @@ -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 { +export interface SecuritySolutionServerlessSearch extends Omit { send: (options: SendOptions) => Promise; } export interface SecuritySolutionUtilsInterface { getUsername: (role?: string) => Promise; createSuperTest: (role?: string) => Promise>; - createBsearch: (role?: string) => Promise; + createSearch: (role?: string) => Promise; } export interface SecuritySolutionESSUtilsInterface { getUsername: (role?: string) => Promise; - createBsearch: (role?: string) => Promise; + createSearch: (role?: string) => Promise; createSuperTest: (role?: string, password?: string) => Promise>; } diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/host_details.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/host_details.ts index cf2ac65f1086b..51f046781268a 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/host_details.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/host_details.ts @@ -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({ + const { hostDetails } = await search.send({ supertest, options: { factoryQueryType: HostsQueries.details, diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/hosts.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/hosts.ts index 6fdbfec48f161..fc16158729bf7 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/hosts.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/hosts.ts @@ -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({ + const hosts = await search.send({ 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({ + const hosts = await search.send({ 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({ + const { hostDetails } = await search.send({ 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({ + const firstLastSeenHost = await search.send({ 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({ + const firstLastSeenHost = await search.send({ supertest, options: { factoryQueryType: FirstLastSeenQuery, diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/uncommon_processes.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/uncommon_processes.ts index 22001c26b66b5..958ac9289b5ef 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/uncommon_processes.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/hosts/trial_license_complete_tier/tests/uncommon_processes.ts @@ -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({ + const response = await search.send({ 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({ + const response = await search.send({ 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({ + response = await search.send({ supertest, options: { factoryQueryType: HostsQueries.uncommonProcesses, diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_details.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_details.ts index 166af42ba5702..6fec2ab95f1fe 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_details.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_details.ts @@ -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({ + const body = await search.send({ 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({ + const body = await search.send({ supertest, options: { ip: '185.53.91.88', diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_dns.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_dns.ts index 22edc8cff64de..cab4ee31744f6 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_dns.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_dns.ts @@ -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({ + const networkDns = await search.send({ 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({ + const networkDns = await search.send({ supertest, options: { ip: '151.205.0.17', diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_top_n_flow.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_top_n_flow.ts index 8b1adb16975f6..31eabe76ee0e1 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_top_n_flow.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/network_top_n_flow.ts @@ -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({ + const networkTopNFlow = await search.send({ 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({ + const networkTopNFlow = await search.send({ 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({ + const networkTopNFlow = await search.send({ supertest, options: { defaultIndex: ['filebeat-*'], @@ -146,7 +146,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) { }); it('should paginate NetworkTopNFlow query', async () => { - const networkTopNFlow = await bsearch.send({ + const networkTopNFlow = await search.send({ supertest, options: { defaultIndex: ['filebeat-*'], diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/tls.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/tls.ts index 36b2b677a1949..004a79b9788f4 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/tls.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/network/trial_license_complete_tier/tests/tls.ts @@ -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({ + const tls = await search.send({ 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({ + const tls = await search.send({ 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({ + const tls = await search.send({ 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({ + const tls = await search.send({ supertest, options: { factoryQueryType: NetworkQueries.tls, diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/overview/trial_license_complete_tier/tests/overview_host.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/overview/trial_license_complete_tier/tests/overview_host.ts index ffb287239ac0f..89239282376d9 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/overview/trial_license_complete_tier/tests/overview_host.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/overview/trial_license_complete_tier/tests/overview_host.ts @@ -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({ + const { overviewHost } = await search.send({ supertest, options: { defaultIndex: ['auditbeat-*'], diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/overview/trial_license_complete_tier/tests/overview_network.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/overview/trial_license_complete_tier/tests/overview_network.ts index f8d4aa80c0e3d..5d2fc9c5aafdd 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/overview/trial_license_complete_tier/tests/overview_network.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/overview/trial_license_complete_tier/tests/overview_network.ts @@ -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({ + const { overviewNetwork } = await search.send({ 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({ + const { overviewNetwork } = await search.send({ 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({ + const { overviewNetwork } = await search.send({ supertest, options: { defaultIndex: ['auditbeat-*'], diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/users/trial_license_complete_tier/tests/authentications.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/users/trial_license_complete_tier/tests/authentications.ts index 39dddc7a0c046..eaee29133ccb1 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/users/trial_license_complete_tier/tests/authentications.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/users/trial_license_complete_tier/tests/authentications.ts @@ -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({ + const authentications = await search.send({ supertest, options: requestOptions, strategy: 'securitySolutionSearchStrategy', @@ -96,7 +96,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) { filterQuery: '', }; - const authentications = await bsearch.send({ + const authentications = await search.send({ supertest, options: requestOptions, strategy: 'securitySolutionSearchStrategy', diff --git a/x-pack/test/security_solution_api_integration/test_suites/explore/users/trial_license_complete_tier/tests/users.ts b/x-pack/test/security_solution_api_integration/test_suites/explore/users/trial_license_complete_tier/tests/users.ts index 6765e6d2bb164..a1ba9a6f497a9 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/explore/users/trial_license_complete_tier/tests/users.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/explore/users/trial_license_complete_tier/tests/users.ts @@ -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({ + const users = await search.send({ supertest, options: { factoryQueryType: NetworkQueries.users, diff --git a/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/tests/events.ts b/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/tests/events.ts index 9db1a5dfceb22..9aa3fcc0de01d 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/tests/events.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/tests/events.ts @@ -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({ + const timeline = await search.send({ supertest, options: { ...getPostBody(), @@ -89,7 +89,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) { }); it('returns paginated Timeline query', async () => { - const timeline = await bsearch.send({ + const timeline = await search.send({ supertest, options: { ...getPostBody(), diff --git a/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/tests/timeline_details.ts b/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/tests/timeline_details.ts index e614f7d30d14f..dcfe8ec233e0a 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/tests/timeline_details.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/tests/timeline_details.ts @@ -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({ + const { data: detailsData } = await search.send({ 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({ + await search.send({ supertest, options: { factoryQueryType: TimelineEventsQueries.kpi, diff --git a/x-pack/test/security_solution_cypress/cypress/tasks/create_new_rule.ts b/x-pack/test/security_solution_cypress/cypress/tasks/create_new_rule.ts index e9822d1340a85..d84968a215a43 100644 --- a/x-pack/test/security_solution_cypress/cypress/tasks/create_new_rule.ts +++ b/x-pack/test/security_solution_cypress/cypress/tasks/create_new_rule.ts @@ -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; } diff --git a/x-pack/test_serverless/shared/services/bsearch_secure.ts b/x-pack/test_serverless/shared/services/search_secure.ts similarity index 87% rename from x-pack/test_serverless/shared/services/bsearch_secure.ts rename to x-pack/test_serverless/shared/services/search_secure.ts index 03f8241c9e12a..7db246dc4ccdf 100644 --- a/x-pack/test_serverless/shared/services/bsearch_secure.ts +++ b/x-pack/test_serverless/shared/services/search_secure.ts @@ -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 { +export class SearchSecureService extends GenericFtrService { private readonly retry = this.ctx.getService('retry'); async send({ @@ -104,24 +103,12 @@ export class BsearchSecureService extends GenericFtrService 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);