From 09a365850e18822b4474fac1a1c033ab6da511a8 Mon Sep 17 00:00:00 2001 From: Tre Date: Thu, 29 Aug 2024 14:46:35 +0100 Subject: [PATCH] [FTR] Refactor test/common/services/* -> packages/kbn-ftr-common-functional-[ui-]services/* (#189051) ## Summary Moving common services to respective new homes. Resolves: https://github.com/elastic/kibana/issues/188541 --------- Co-authored-by: Elastic Machine --- .../development-functional-tests.asciidoc | 10 ++-- .../index.ts | 9 ++++ .../services/all.ts | 14 +++++ .../services/bsearch.ts | 3 +- .../services/console.ts | 4 +- .../services/deployment.ts | 2 +- .../services/es_delete_all_indices.ts | 2 +- .../services/index_patterns.ts | 7 +-- .../services/randomness.ts | 2 +- .../services/saved_object_info/index.ts | 0 .../saved_object_info/saved_object_info.ts | 2 +- .../saved_objects_info_svc.md | 0 .../services/saved_object_info/use_with_jq.md | 0 .../services/saved_object_info/utils.ts | 0 .../tsconfig.json | 7 +++ .../index.ts | 1 + .../services/all.ts | 2 + .../services/ftr_provider_context.ts | 8 ++- .../services/security/index.ts | 2 +- .../services/security/role.ts | 0 .../services/security/role_mappings.ts | 0 .../services/security/security.ts | 2 +- .../services/security/system_indices_user.ts | 2 +- .../services/security/test_user.ts | 5 +- .../services/security/user.ts | 0 scripts/saved_objs_info.js | 2 +- test/analytics/services/index.ts | 7 ++- .../apis/console/autocomplete_entities.ts | 46 +++++++---------- test/api_integration/services/index.ts | 7 +-- test/common/config.js | 2 - test/common/ftr_provider_context.ts | 14 ----- test/common/services/console.ts | 15 ------ test/common/services/index.ts | 43 +++++++++------- .../apps/discover/ftr_provider_context.d.ts | 8 ++- test/functional/services/index.ts | 4 +- test/health_gateway/services/index.ts | 6 ++- test/server_integration/config.base.js | 4 +- test/server_integration/services/types.d.ts | 9 +++- test/tsconfig.json | 3 -- .../apis/cloud_security_posture/helper.ts | 2 +- .../apis/telemetry/telemetry.ts | 2 +- x-pack/test/common/services/bsearch_secure.ts | 4 +- x-pack/test/common/services/index.ts | 6 ++- .../fleet_api_integration/apis/test_users.ts | 2 +- x-pack/test/fleet_cypress/services.ts | 7 ++- x-pack/test/osquery_cypress/services.ts | 8 ++- .../helpers/create_or_update_user.ts | 2 +- .../common/create_profiling_users/index.ts | 2 +- .../test/saved_objects_field_count/config.ts | 5 ++ .../security_solution_serverless_utils.ts | 2 +- .../config/services/types.ts | 2 +- .../entity_analytics/utils/users_and_roles.ts | 2 +- .../tests/host_details.ts | 2 +- .../tests/hosts.ts | 2 +- .../tests/uncommon_processes.ts | 2 +- .../tests/network_details.ts | 2 +- .../tests/network_dns.ts | 2 +- .../tests/network_top_n_flow.ts | 2 +- .../trial_license_complete_tier/tests/tls.ts | 3 +- .../tests/overview_host.ts | 2 +- .../tests/overview_network.ts | 2 +- .../tests/authentications.ts | 2 +- .../tests/users.ts | 3 +- .../tests/events.ts | 3 +- .../tests/timeline_details.ts | 3 +- .../tsconfig.json | 2 +- .../threat_intelligence_cypress/config.ts | 5 +- .../upgrade_assistant_integration/config.js | 7 ++- .../common/console/autocomplete_entities.ts | 51 ++++++------------- .../shared/services/bsearch_secure.ts | 4 +- 70 files changed, 214 insertions(+), 185 deletions(-) rename {test/common => packages/kbn-ftr-common-functional-services}/services/bsearch.ts (98%) rename test/api_integration/apis/console/helpers.ts => packages/kbn-ftr-common-functional-services/services/console.ts (95%) rename {test/common => packages/kbn-ftr-common-functional-services}/services/deployment.ts (96%) rename {test/common => packages/kbn-ftr-common-functional-services}/services/es_delete_all_indices.ts (97%) rename {test/common => packages/kbn-ftr-common-functional-services}/services/index_patterns.ts (91%) rename {test/common => packages/kbn-ftr-common-functional-services}/services/randomness.ts (97%) rename {test/common => packages/kbn-ftr-common-functional-services}/services/saved_object_info/index.ts (100%) rename {test/common => packages/kbn-ftr-common-functional-services}/services/saved_object_info/saved_object_info.ts (97%) rename {test/common => packages/kbn-ftr-common-functional-services}/services/saved_object_info/saved_objects_info_svc.md (100%) rename {test/common => packages/kbn-ftr-common-functional-services}/services/saved_object_info/use_with_jq.md (100%) rename {test/common => packages/kbn-ftr-common-functional-services}/services/saved_object_info/utils.ts (100%) rename {test/common => packages/kbn-ftr-common-functional-ui-services}/services/security/index.ts (83%) rename {test/common => packages/kbn-ftr-common-functional-ui-services}/services/security/role.ts (100%) rename {test/common => packages/kbn-ftr-common-functional-ui-services}/services/security/role_mappings.ts (100%) rename {test/common => packages/kbn-ftr-common-functional-ui-services}/services/security/security.ts (95%) rename {test/common => packages/kbn-ftr-common-functional-ui-services}/services/security/system_indices_user.ts (97%) rename {test/common => packages/kbn-ftr-common-functional-ui-services}/services/security/test_user.ts (96%) rename {test/common => packages/kbn-ftr-common-functional-ui-services}/services/security/user.ts (100%) delete mode 100644 test/common/ftr_provider_context.ts delete mode 100644 test/common/services/console.ts diff --git a/docs/developer/contributing/development-functional-tests.asciidoc b/docs/developer/contributing/development-functional-tests.asciidoc index 23d43480eb090..88163ebb6804b 100644 --- a/docs/developer/contributing/development-functional-tests.asciidoc +++ b/docs/developer/contributing/development-functional-tests.asciidoc @@ -203,7 +203,7 @@ Tests should run at the positive security boundary condition, meaning that they The functional UI tests now default to logging in with a user named `test_user` and the roles of this user can be changed dynamically without logging in and out. -In order to achieve this a new service was introduced called `createTestUserService` (see `test/common/services/security/test_user.ts`). The purpose of this test user service is to create roles defined in the test config files and setRoles() or restoreDefaults(). +In order to achieve this a new service was introduced called `createTestUserService` (see `packages/kbn-ftr-common-functional-ui-services/services/security/test_user.ts`). The purpose of this test user service is to create roles defined in the test config files and setRoles() or restoreDefaults(). An example of how to set the role like how its defined below: @@ -366,14 +366,14 @@ await testSubjects.click(‘containerButton’); ** `find.allByCssSelector()` **retry:**::: -// * Source: {kibana-blob}test/common/services/retry/retry.ts[test/common/services/retry/retry.ts] +// * Source: {kibana-blob}packages/kbn-ftr-common-functional-services/services/retry/retry.ts[packages/kbn-ftr-common-functional-services/services/retry/retry.ts] * Helpers for retrying operations * Popular methods: ** `retry.try(fn, onFailureBlock)` - Execute `fn` in a loop until it succeeds or the default timeout elapses. The optional `onFailureBlock` is executed before each retry attempt. ** `retry.tryForTime(ms, fn, onFailureBlock)` - Execute `fn` in a loop until it succeeds or `ms` milliseconds elapses. The optional `onFailureBlock` is executed before each retry attempt. **kibanaServer:**::: -// * Source: {kibana-blob}test/common/services/kibana_server/kibana_server.js[test/common/services/kibana_server/kibana_server.js] +// * Source: {kibana-blob}packages/kbn-ftr-common-functional-services/services/kibana_server/kibana_server.ts[packages/kbn-ftr-common-functional-services/services/kibana_server/kibana_server.ts] * Helpers for interacting with {kib}'s server * Commonly used methods: ** `kibanaServer.uiSettings.update()` @@ -381,7 +381,7 @@ await testSubjects.click(‘containerButton’); ** `kibanaServer.status.getOverallState()` **esArchiver:**::: -// * Source: {kibana-blob}test/common/services/es_archiver.ts[test/common/services/es_archiver.ts] +// * Source: {kibana-blob}packages/kbn-ftr-common-functional-services/services/es_archiver.ts[packages/kbn-ftr-common-functional-services/services/es_archiver.ts] * Load/unload archives created with the `esArchiver` * Popular methods: ** `esArchiver.load(path)` @@ -393,7 +393,7 @@ Full list of services that are used in functional tests can be found here: {kiba **Low-level utilities:**::: * es -// ** Source: {kibana-blob}test/common/services/es.ts[test/common/services/es.ts] +// ** Source: {kibana-blob}packages/kbn-ftr-common-functional-services/services/es.ts[packages/kbn-ftr-common-functional-services/services/es.ts] ** {es} client ** Higher level options: `kibanaServer.uiSettings` or `esArchiver` * remote diff --git a/packages/kbn-ftr-common-functional-services/index.ts b/packages/kbn-ftr-common-functional-services/index.ts index 3cc6df44adf01..36d76c7e2ffd7 100644 --- a/packages/kbn-ftr-common-functional-services/index.ts +++ b/packages/kbn-ftr-common-functional-services/index.ts @@ -10,6 +10,7 @@ import { ProvidedType } from '@kbn/test'; export { services as commonFunctionalServices } from './services/all'; import { KibanaServerProvider } from './services/kibana_server'; +export { KibanaServerProvider } from './services/kibana_server'; export type KibanaServer = ProvidedType; export { RetryService } from './services/retry'; @@ -18,6 +19,7 @@ import { EsArchiverProvider } from './services/es_archiver'; export type EsArchiver = ProvidedType; import { EsProvider } from './services/es'; +export { EsProvider } from './services/es'; export type Es = ProvidedType; import { SupertestWithoutAuthProvider } from './services/supertest_without_auth'; @@ -29,3 +31,10 @@ import { SamlAuthProvider } from './services/saml_auth/saml_auth_provider'; 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 { SavedObjectInfoService } from './services/saved_object_info'; +export { DeploymentService } from './services/deployment'; +export { IndexPatternsService } from './services/index_patterns'; +export { RandomnessService } from './services/randomness'; diff --git a/packages/kbn-ftr-common-functional-services/services/all.ts b/packages/kbn-ftr-common-functional-services/services/all.ts index 49308faeb3dd0..c6c0fb792bb81 100644 --- a/packages/kbn-ftr-common-functional-services/services/all.ts +++ b/packages/kbn-ftr-common-functional-services/services/all.ts @@ -10,6 +10,13 @@ import { EsArchiverProvider } from './es_archiver'; import { EsProvider } from './es'; import { KibanaServerProvider } from './kibana_server'; import { RetryService } from './retry'; +import { BsearchService } from './bsearch'; +import { ConsoleProvider } from './console'; +import { DeploymentService } from './deployment'; +import { EsDeleteAllIndicesProvider } from './es_delete_all_indices'; +import { IndexPatternsService } from './index_patterns'; +import { SavedObjectInfoService } from './saved_object_info'; +import { RandomnessService } from './randomness'; import { SupertestWithoutAuthProvider } from './supertest_without_auth'; import { SamlAuthProvider } from './saml_auth'; @@ -18,6 +25,13 @@ export const services = { kibanaServer: KibanaServerProvider, esArchiver: EsArchiverProvider, retry: RetryService, + bsearch: BsearchService, + console: ConsoleProvider, + deployment: DeploymentService, + esDeleteAllIndices: EsDeleteAllIndicesProvider, + indexPatterns: IndexPatternsService, + savedObjectInfo: SavedObjectInfoService, + randomness: RandomnessService, supertestWithoutAuth: SupertestWithoutAuthProvider, samlAuth: SamlAuthProvider, }; diff --git a/test/common/services/bsearch.ts b/packages/kbn-ftr-common-functional-services/services/bsearch.ts similarity index 98% rename from test/common/services/bsearch.ts rename to packages/kbn-ftr-common-functional-services/services/bsearch.ts index 81063813cec5f..b36834dedbca5 100644 --- a/test/common/services/bsearch.ts +++ b/packages/kbn-ftr-common-functional-services/services/bsearch.ts @@ -12,7 +12,7 @@ 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'; +import { FtrService } from './ftr_provider_context'; /** * Function copied from here: @@ -62,6 +62,7 @@ export interface SendOptions { * }); * expect(response).eql({ ... your value ... }); */ + export class BsearchService extends FtrService { private readonly retry = this.ctx.getService('retry'); diff --git a/test/api_integration/apis/console/helpers.ts b/packages/kbn-ftr-common-functional-services/services/console.ts similarity index 95% rename from test/api_integration/apis/console/helpers.ts rename to packages/kbn-ftr-common-functional-services/services/console.ts index cfd1365f212fa..1ca5128d83f7c 100644 --- a/test/api_integration/apis/console/helpers.ts +++ b/packages/kbn-ftr-common-functional-services/services/console.ts @@ -6,9 +6,9 @@ * Side Public License, v 1. */ -import type { FtrProviderContext } from '../../ftr_provider_context'; +import type { FtrProviderContext } from './ftr_provider_context'; -export function helpers(getService: FtrProviderContext['getService']) { +export function ConsoleProvider({ getService }: FtrProviderContext) { const client = getService('es'); const createIndex = async (indexName: string) => { diff --git a/test/common/services/deployment.ts b/packages/kbn-ftr-common-functional-services/services/deployment.ts similarity index 96% rename from test/common/services/deployment.ts rename to packages/kbn-ftr-common-functional-services/services/deployment.ts index e61d6b360da19..28474a6bc60e2 100644 --- a/test/common/services/deployment.ts +++ b/packages/kbn-ftr-common-functional-services/services/deployment.ts @@ -11,7 +11,7 @@ import { Agent } from 'https'; import fetch from 'node-fetch'; import { getUrl } from '@kbn/test'; -import { FtrService } from '../ftr_provider_context'; +import { FtrService } from './ftr_provider_context'; export class DeploymentService extends FtrService { private readonly config = this.ctx.getService('config'); diff --git a/test/common/services/es_delete_all_indices.ts b/packages/kbn-ftr-common-functional-services/services/es_delete_all_indices.ts similarity index 97% rename from test/common/services/es_delete_all_indices.ts rename to packages/kbn-ftr-common-functional-services/services/es_delete_all_indices.ts index 5f0ecba2cbde8..cf3f93d9ef6aa 100644 --- a/test/common/services/es_delete_all_indices.ts +++ b/packages/kbn-ftr-common-functional-services/services/es_delete_all_indices.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import { FtrProviderContext } from '../ftr_provider_context'; +import { FtrProviderContext } from './ftr_provider_context'; export function EsDeleteAllIndicesProvider({ getService }: FtrProviderContext) { const log = getService('log'); diff --git a/test/common/services/index_patterns.ts b/packages/kbn-ftr-common-functional-services/services/index_patterns.ts similarity index 91% rename from test/common/services/index_patterns.ts rename to packages/kbn-ftr-common-functional-services/services/index_patterns.ts index 3fe02863b8568..6113040b927b3 100644 --- a/test/common/services/index_patterns.ts +++ b/packages/kbn-ftr-common-functional-services/services/index_patterns.ts @@ -6,10 +6,11 @@ * Side Public License, v 1. */ -import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; +import type { DataViewSpec } from '@kbn/data-plugin/common'; + import { INITIAL_REST_VERSION } from '@kbn/data-views-plugin/server/constants'; -import { DataViewSpec } from '@kbn/data-plugin/common'; -import { FtrService } from '../ftr_provider_context'; +import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; +import { FtrService } from './ftr_provider_context'; export class IndexPatternsService extends FtrService { private readonly kibanaServer = this.ctx.getService('kibanaServer'); diff --git a/test/common/services/randomness.ts b/packages/kbn-ftr-common-functional-services/services/randomness.ts similarity index 97% rename from test/common/services/randomness.ts rename to packages/kbn-ftr-common-functional-services/services/randomness.ts index c799c34539f15..d3ea0c74ff5de 100644 --- a/test/common/services/randomness.ts +++ b/packages/kbn-ftr-common-functional-services/services/randomness.ts @@ -9,7 +9,7 @@ import Chance from 'chance'; import { ToolingLog } from '@kbn/tooling-log'; -import { FtrService } from '../ftr_provider_context'; +import { FtrService } from './ftr_provider_context'; let __CACHED_SEED__: number | undefined; function getSeed(log: ToolingLog) { diff --git a/test/common/services/saved_object_info/index.ts b/packages/kbn-ftr-common-functional-services/services/saved_object_info/index.ts similarity index 100% rename from test/common/services/saved_object_info/index.ts rename to packages/kbn-ftr-common-functional-services/services/saved_object_info/index.ts diff --git a/test/common/services/saved_object_info/saved_object_info.ts b/packages/kbn-ftr-common-functional-services/services/saved_object_info/saved_object_info.ts similarity index 97% rename from test/common/services/saved_object_info/saved_object_info.ts rename to packages/kbn-ftr-common-functional-services/services/saved_object_info/saved_object_info.ts index a1b98cbd408bf..289c730cac17a 100644 --- a/test/common/services/saved_object_info/saved_object_info.ts +++ b/packages/kbn-ftr-common-functional-services/services/saved_object_info/saved_object_info.ts @@ -13,7 +13,7 @@ import { flow, pipe } from 'fp-ts/function'; import * as TE from 'fp-ts/lib/TaskEither'; import * as T from 'fp-ts/lib/Task'; import { ToolingLog } from '@kbn/tooling-log'; -import { FtrService } from '../../ftr_provider_context'; +import { FtrService } from '../ftr_provider_context'; import { print } from './utils'; const pluck = diff --git a/test/common/services/saved_object_info/saved_objects_info_svc.md b/packages/kbn-ftr-common-functional-services/services/saved_object_info/saved_objects_info_svc.md similarity index 100% rename from test/common/services/saved_object_info/saved_objects_info_svc.md rename to packages/kbn-ftr-common-functional-services/services/saved_object_info/saved_objects_info_svc.md diff --git a/test/common/services/saved_object_info/use_with_jq.md b/packages/kbn-ftr-common-functional-services/services/saved_object_info/use_with_jq.md similarity index 100% rename from test/common/services/saved_object_info/use_with_jq.md rename to packages/kbn-ftr-common-functional-services/services/saved_object_info/use_with_jq.md diff --git a/test/common/services/saved_object_info/utils.ts b/packages/kbn-ftr-common-functional-services/services/saved_object_info/utils.ts similarity index 100% rename from test/common/services/saved_object_info/utils.ts rename to packages/kbn-ftr-common-functional-services/services/saved_object_info/utils.ts diff --git a/packages/kbn-ftr-common-functional-services/tsconfig.json b/packages/kbn-ftr-common-functional-services/tsconfig.json index 56a442ad2f5a9..490eed5f7ac0e 100644 --- a/packages/kbn-ftr-common-functional-services/tsconfig.json +++ b/packages/kbn-ftr-common-functional-services/tsconfig.json @@ -16,8 +16,15 @@ "@kbn/es-archiver", "@kbn/test", "@kbn/expect", + "@kbn/search-types", + "@kbn/core-http-common", + "@kbn/bfetch-plugin", + "@kbn/data-plugin", + "@kbn/dev-cli-runner", + "@kbn/dev-cli-errors", "@kbn/repo-info", "@kbn/es", + "@kbn/data-views-plugin" ], "exclude": [ "target/**/*", diff --git a/packages/kbn-ftr-common-functional-ui-services/index.ts b/packages/kbn-ftr-common-functional-ui-services/index.ts index cd383a03e5f5d..f5f5b9df5b8ae 100644 --- a/packages/kbn-ftr-common-functional-ui-services/index.ts +++ b/packages/kbn-ftr-common-functional-ui-services/index.ts @@ -22,3 +22,4 @@ export { } from './services/remote/network_profiles'; export type { TimeoutOpt } from './types'; export { TestSubjects } from './services/test_subjects'; +export { SecurityService } from './services/security'; diff --git a/packages/kbn-ftr-common-functional-ui-services/services/all.ts b/packages/kbn-ftr-common-functional-ui-services/services/all.ts index bffa7468e14ea..610697c69dfbf 100644 --- a/packages/kbn-ftr-common-functional-ui-services/services/all.ts +++ b/packages/kbn-ftr-common-functional-ui-services/services/all.ts @@ -12,6 +12,7 @@ import { FindProvider } from './find'; import { TestSubjects } from './test_subjects'; import { BrowserProvider } from './browser'; import { ToastsService } from './toasts'; +import { SecurityServiceProvider } from './security'; export const services = { retryOnStale: RetryOnStaleProvider, @@ -20,4 +21,5 @@ export const services = { testSubjects: TestSubjects, browser: BrowserProvider, toasts: ToastsService, + security: SecurityServiceProvider, }; diff --git a/packages/kbn-ftr-common-functional-ui-services/services/ftr_provider_context.ts b/packages/kbn-ftr-common-functional-ui-services/services/ftr_provider_context.ts index 992fe27059e45..6f589ac6d1bb4 100644 --- a/packages/kbn-ftr-common-functional-ui-services/services/ftr_provider_context.ts +++ b/packages/kbn-ftr-common-functional-ui-services/services/ftr_provider_context.ts @@ -7,12 +7,18 @@ */ import { GenericFtrProviderContext, GenericFtrService } from '@kbn/test'; -import { RetryService } from '@kbn/ftr-common-functional-services'; +import { + RetryService, + EsProvider, + KibanaServerProvider, +} from '@kbn/ftr-common-functional-services'; import { services as commonFunctionalUiServices } from './all'; const services = { ...commonFunctionalUiServices, retry: RetryService, + es: EsProvider, + kibanaServer: KibanaServerProvider, }; export type FtrProviderContext = GenericFtrProviderContext; diff --git a/test/common/services/security/index.ts b/packages/kbn-ftr-common-functional-ui-services/services/security/index.ts similarity index 83% rename from test/common/services/security/index.ts rename to packages/kbn-ftr-common-functional-ui-services/services/security/index.ts index d34246c0c4411..308b2f8b075a0 100644 --- a/test/common/services/security/index.ts +++ b/packages/kbn-ftr-common-functional-ui-services/services/security/index.ts @@ -6,4 +6,4 @@ * Side Public License, v 1. */ -export { SecurityServiceProvider } from './security'; +export { SecurityService, SecurityServiceProvider } from './security'; diff --git a/test/common/services/security/role.ts b/packages/kbn-ftr-common-functional-ui-services/services/security/role.ts similarity index 100% rename from test/common/services/security/role.ts rename to packages/kbn-ftr-common-functional-ui-services/services/security/role.ts diff --git a/test/common/services/security/role_mappings.ts b/packages/kbn-ftr-common-functional-ui-services/services/security/role_mappings.ts similarity index 100% rename from test/common/services/security/role_mappings.ts rename to packages/kbn-ftr-common-functional-ui-services/services/security/role_mappings.ts diff --git a/test/common/services/security/security.ts b/packages/kbn-ftr-common-functional-ui-services/services/security/security.ts similarity index 95% rename from test/common/services/security/security.ts rename to packages/kbn-ftr-common-functional-ui-services/services/security/security.ts index a182f225f2388..5a5ff531acd5e 100644 --- a/test/common/services/security/security.ts +++ b/packages/kbn-ftr-common-functional-ui-services/services/security/security.ts @@ -9,7 +9,7 @@ import { Role } from './role'; import { User } from './user'; import { RoleMappings } from './role_mappings'; -import { FtrProviderContext } from '../../ftr_provider_context'; +import { FtrProviderContext } from '../ftr_provider_context'; import { createTestUserService, TestUserSupertestProvider, TestUser } from './test_user'; import { createSystemIndicesUser } from './system_indices_user'; diff --git a/test/common/services/security/system_indices_user.ts b/packages/kbn-ftr-common-functional-ui-services/services/security/system_indices_user.ts similarity index 97% rename from test/common/services/security/system_indices_user.ts rename to packages/kbn-ftr-common-functional-ui-services/services/security/system_indices_user.ts index 52e166c645093..9d6016ebb17e9 100644 --- a/test/common/services/security/system_indices_user.ts +++ b/packages/kbn-ftr-common-functional-ui-services/services/security/system_indices_user.ts @@ -13,7 +13,7 @@ import { createEsClientForFtrConfig, createRemoteEsClientForFtrConfig, } from '@kbn/test'; -import { FtrProviderContext } from '../../ftr_provider_context'; +import { FtrProviderContext } from '../ftr_provider_context'; const SYSTEM_INDICES_SUPERUSER_ROLE = 'system_indices_superuser'; diff --git a/test/common/services/security/test_user.ts b/packages/kbn-ftr-common-functional-ui-services/services/security/test_user.ts similarity index 96% rename from test/common/services/security/test_user.ts rename to packages/kbn-ftr-common-functional-ui-services/services/security/test_user.ts index f3012304a95bd..10a6da9f707dd 100644 --- a/test/common/services/security/test_user.ts +++ b/packages/kbn-ftr-common-functional-ui-services/services/security/test_user.ts @@ -9,10 +9,11 @@ import { format as formatUrl } from 'url'; import supertest from 'supertest'; -import { type Browser, TestSubjects } from '@kbn/ftr-common-functional-ui-services'; +import type { Browser } from '../browser'; +import type { TestSubjects } from '../test_subjects'; import { Role } from './role'; import { User } from './user'; -import { FtrService, FtrProviderContext } from '../../ftr_provider_context'; +import { FtrService, FtrProviderContext } from '../ftr_provider_context'; const TEST_USER_NAME = 'test_user'; const TEST_USER_PASSWORD = 'changeme'; diff --git a/test/common/services/security/user.ts b/packages/kbn-ftr-common-functional-ui-services/services/security/user.ts similarity index 100% rename from test/common/services/security/user.ts rename to packages/kbn-ftr-common-functional-ui-services/services/security/user.ts diff --git a/scripts/saved_objs_info.js b/scripts/saved_objs_info.js index f17a2897b83da..229565921ba90 100644 --- a/scripts/saved_objs_info.js +++ b/scripts/saved_objs_info.js @@ -7,4 +7,4 @@ */ require('../src/setup_node_env'); -require('@kbn/test-suites-src/common/services/saved_object_info').runSavedObjInfoSvc(); +require('@kbn/ftr-common-functional-services').runSavedObjInfoSvc(); diff --git a/test/analytics/services/index.ts b/test/analytics/services/index.ts index 0c75df9bc2050..0d3465986249a 100644 --- a/test/analytics/services/index.ts +++ b/test/analytics/services/index.ts @@ -7,14 +7,17 @@ */ import { GenericFtrProviderContext } from '@kbn/test'; -import { services as commonServices } from '../../common/services'; +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; +import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services'; + import { services as functionalServices } from '../../functional/services'; import { pageObjects } from '../../functional/page_objects'; import { KibanaEBTServerProvider, KibanaEBTUIProvider } from './kibana_ebt'; export const services = { - ...commonServices, + ...commonFunctionalServices, + ...commonFunctionalUIServices, ...functionalServices, kibana_ebt_server: KibanaEBTServerProvider, kibana_ebt_ui: KibanaEBTUIProvider, diff --git a/test/api_integration/apis/console/autocomplete_entities.ts b/test/api_integration/apis/console/autocomplete_entities.ts index a410e50950cd1..1993ef1f7fe19 100644 --- a/test/api_integration/apis/console/autocomplete_entities.ts +++ b/test/api_integration/apis/console/autocomplete_entities.ts @@ -8,25 +8,11 @@ import expect from '@kbn/expect'; import type { FtrProviderContext } from '../../ftr_provider_context'; -import { helpers } from './helpers'; export default ({ getService }: FtrProviderContext) => { - const { - createIndex, - createAlias, - createLegacyTemplate, - createIndexTemplate, - createComponentTemplate, - createDataStream, - deleteIndex, - deleteAlias, - deleteLegacyTemplate, - deleteIndexTemplate, - deleteComponentTemplate, - deleteDataStream, - } = helpers(getService); - + const console = getService('console'); const supertest = getService('supertest'); + const sendRequest = (query: object) => supertest.get('/api/console/autocomplete_entities').query(query); @@ -40,22 +26,26 @@ export default ({ getService }: FtrProviderContext) => { before(async () => { // Setup indices, aliases, templates, and data streams - await createIndex(indexName); - await createAlias(indexName, aliasName); - await createComponentTemplate(componentTemplateName); - await createIndexTemplate(indexTemplateName, [dataStreamName], [componentTemplateName]); - await createDataStream(dataStreamName); - await createLegacyTemplate(legacyTemplateName); + await console.createIndex(indexName); + await console.createAlias(indexName, aliasName); + await console.createComponentTemplate(componentTemplateName); + await console.createIndexTemplate( + indexTemplateName, + [dataStreamName], + [componentTemplateName] + ); + await console.createDataStream(dataStreamName); + await console.createLegacyTemplate(legacyTemplateName); }); after(async () => { // Cleanup indices, aliases, templates, and data streams - await deleteAlias(indexName, aliasName); - await deleteIndex(indexName); - await deleteDataStream(dataStreamName); - await deleteIndexTemplate(indexTemplateName); - await deleteComponentTemplate(componentTemplateName); - await deleteLegacyTemplate(legacyTemplateName); + await console.deleteAlias(indexName, aliasName); + await console.deleteIndex(indexName); + await console.deleteDataStream(dataStreamName); + await console.deleteIndexTemplate(indexTemplateName); + await console.deleteComponentTemplate(componentTemplateName); + await console.deleteLegacyTemplate(legacyTemplateName); }); it('should not succeed if no settings are provided in query params', async () => { diff --git a/test/api_integration/services/index.ts b/test/api_integration/services/index.ts index 42a2616b781ac..f72460b7ffc5f 100644 --- a/test/api_integration/services/index.ts +++ b/test/api_integration/services/index.ts @@ -6,12 +6,13 @@ * Side Public License, v 1. */ -import { services as commonServices } from '../../common/services'; - +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; +import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services'; import { KibanaSupertestProvider, ElasticsearchSupertestProvider } from './supertest'; export const services = { - ...commonServices, + ...commonFunctionalServices, + ...commonFunctionalUIServices, supertest: KibanaSupertestProvider, esSupertest: ElasticsearchSupertestProvider, }; diff --git a/test/common/config.js b/test/common/config.js index 163703a693356..8f2d6b7e14018 100644 --- a/test/common/config.js +++ b/test/common/config.js @@ -9,7 +9,6 @@ import path from 'path'; import { format as formatUrl } from 'url'; import { esTestConfig, kbnTestConfig, kibanaServerTestUser } from '@kbn/test'; -import { services } from './services'; export default function () { const servers = { @@ -85,6 +84,5 @@ export default function () { })}`, ], }, - services, }; } diff --git a/test/common/ftr_provider_context.ts b/test/common/ftr_provider_context.ts deleted file mode 100644 index 6d21aedfe1d5e..0000000000000 --- a/test/common/ftr_provider_context.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { GenericFtrProviderContext, GenericFtrService } from '@kbn/test'; - -import { services } from './services'; - -export type FtrProviderContext = GenericFtrProviderContext; -export class FtrService extends GenericFtrService {} diff --git a/test/common/services/console.ts b/test/common/services/console.ts deleted file mode 100644 index a864952fa081b..0000000000000 --- a/test/common/services/console.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import type { FtrProviderContext } from '../ftr_provider_context'; -import { helpers } from '../../api_integration/apis/console/helpers'; -export function ConsoleProvider({ getService }: FtrProviderContext) { - return { - helpers: helpers(getService), - }; -} diff --git a/test/common/services/index.ts b/test/common/services/index.ts index ccc786d4ccc6e..18855d9dee114 100644 --- a/test/common/services/index.ts +++ b/test/common/services/index.ts @@ -7,17 +7,26 @@ */ import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; -import { DeploymentService } from './deployment'; -import { RandomnessService } from './randomness'; -import { SecurityServiceProvider } from './security'; -import { EsDeleteAllIndicesProvider } from './es_delete_all_indices'; -import { SavedObjectInfoService } from './saved_object_info'; -import { IndexPatternsService } from './index_patterns'; -import { BsearchService } from './bsearch'; -import { ConsoleProvider } from './console'; +import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services'; // pick only services that work for any FTR config, e.g. 'samlAuth' requires SAML setup in config file -const { es, esArchiver, kibanaServer, retry, supertestWithoutAuth } = commonFunctionalServices; +const { + es, + esArchiver, + kibanaServer, + retry, + supertestWithoutAuth, + deployment, + randomness, + esDeleteAllIndices, + savedObjectInfo, + indexPatterns, + bsearch, + console, +} = commonFunctionalServices; + +// pick what was there previously +const { security } = commonFunctionalUIServices; export const services = { es, @@ -25,12 +34,12 @@ export const services = { kibanaServer, retry, supertestWithoutAuth, - deployment: DeploymentService, - randomness: RandomnessService, - security: SecurityServiceProvider, - esDeleteAllIndices: EsDeleteAllIndicesProvider, - savedObjectInfo: SavedObjectInfoService, - indexPatterns: IndexPatternsService, - bsearch: BsearchService, - console: ConsoleProvider, + deployment, + randomness, + security, + esDeleteAllIndices, + savedObjectInfo, + indexPatterns, + bsearch, + console, }; diff --git a/test/functional/apps/discover/ftr_provider_context.d.ts b/test/functional/apps/discover/ftr_provider_context.d.ts index 5bf34af1bf9f3..b006a98a73d7c 100644 --- a/test/functional/apps/discover/ftr_provider_context.d.ts +++ b/test/functional/apps/discover/ftr_provider_context.d.ts @@ -7,7 +7,13 @@ */ import { GenericFtrProviderContext } from '@kbn/test'; -import { services } from '../../services'; +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; +import { services as functionalServces } from '../../services'; import { pageObjects } from '../../page_objects'; +const services = { + ...functionalServces, + ...commonFunctionalServices, +}; + export type FtrProviderContext = GenericFtrProviderContext; diff --git a/test/functional/services/index.ts b/test/functional/services/index.ts index 83672889eff75..01df9b5fdcbbf 100644 --- a/test/functional/services/index.ts +++ b/test/functional/services/index.ts @@ -7,7 +7,7 @@ */ import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services'; -import { services as commonServiceProviders } from '../../common/services'; +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; import { AppsMenuService } from './apps_menu'; import { @@ -57,7 +57,7 @@ import { ESQLService } from './esql'; import { DataViewsService } from './data_views'; export const services = { - ...commonServiceProviders, + ...commonFunctionalServices, ...commonFunctionalUIServices, filterBar: FilterBarService, queryBar: QueryBarService, diff --git a/test/health_gateway/services/index.ts b/test/health_gateway/services/index.ts index b9c44e227adae..5a89fb849f952 100644 --- a/test/health_gateway/services/index.ts +++ b/test/health_gateway/services/index.ts @@ -6,11 +6,13 @@ * Side Public License, v 1. */ -import { services as commonServices } from '../../common/services'; +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; +import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services'; import { HealthGatewayService } from './health_gateway'; export const services = { - ...commonServices, + ...commonFunctionalServices, + ...commonFunctionalUIServices, healthGateway: HealthGatewayService, }; diff --git a/test/server_integration/config.base.js b/test/server_integration/config.base.js index 71006c258c423..61243595505eb 100644 --- a/test/server_integration/config.base.js +++ b/test/server_integration/config.base.js @@ -12,13 +12,15 @@ import { ElasticsearchSupertestProvider, } from './services'; +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; + export default async function ({ readConfigFile }) { const commonConfig = await readConfigFile(require.resolve('../common/config')); const functionalConfig = await readConfigFile(require.resolve('../functional/config.base.js')); return { services: { - ...commonConfig.get('services'), + ...commonFunctionalServices, supertest: createKibanaSupertestProvider(), supertestWithoutAuth: KibanaSupertestWithoutAuthProvider, esSupertest: ElasticsearchSupertestProvider, diff --git a/test/server_integration/services/types.d.ts b/test/server_integration/services/types.d.ts index 2df95f0297f90..204c0ae0106e5 100644 --- a/test/server_integration/services/types.d.ts +++ b/test/server_integration/services/types.d.ts @@ -7,7 +7,14 @@ */ import { GenericFtrProviderContext } from '@kbn/test'; -import { services as kibanaCommonServices } from '../../common/services'; +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; +import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services'; + +export const kibanaCommonServices = { + ...commonFunctionalServices, + ...commonFunctionalUIServices, +} as const; + import { services as kibanaApiIntegrationServices } from '../../api_integration/services'; export type FtrProviderContext = GenericFtrProviderContext< diff --git a/test/tsconfig.json b/test/tsconfig.json index 9f9f062a16492..8b0d946bded62 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -47,8 +47,6 @@ "@kbn/controls-plugin", "@kbn/field-formats-plugin", "@kbn/axe-config", - "@kbn/dev-cli-runner", - "@kbn/dev-cli-errors", "@kbn/data-view-field-editor-plugin", "@kbn/data-views-plugin", "@kbn/guided-onboarding-plugin", @@ -71,7 +69,6 @@ "@kbn/links-plugin", "@kbn/ftr-common-functional-ui-services", "@kbn/monaco", - "@kbn/search-types", "@kbn/console-plugin", "@kbn/core-chrome-browser", "@kbn/default-nav-ml", diff --git a/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts b/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts index 13bc2ee7de9d2..7c21e6df09f8c 100644 --- a/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts +++ b/x-pack/test/api_integration/apis/cloud_security_posture/helper.ts @@ -11,7 +11,7 @@ import expect from '@kbn/expect'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; import type { IndexDetails } from '@kbn/cloud-security-posture-common'; import { CLOUD_SECURITY_PLUGIN_VERSION } from '@kbn/cloud-security-posture-plugin/common/constants'; -import { SecurityService } from '@kbn/test-suites-src/common/services/security/security'; +import { SecurityService } from '@kbn/ftr-common-functional-ui-services'; export interface RoleCredentials { apiKey: { id: string; name: string }; diff --git a/x-pack/test/api_integration/apis/telemetry/telemetry.ts b/x-pack/test/api_integration/apis/telemetry/telemetry.ts index 9c0a9b16bd835..e0fa1f185c3d2 100644 --- a/x-pack/test/api_integration/apis/telemetry/telemetry.ts +++ b/x-pack/test/api_integration/apis/telemetry/telemetry.ts @@ -25,7 +25,7 @@ import { ELASTIC_HTTP_VERSION_HEADER, X_ELASTIC_INTERNAL_ORIGIN_REQUEST, } from '@kbn/core-http-common'; -import type { SecurityService } from '@kbn/test-suites-src/common/services/security/security'; +import type { SecurityService } from '@kbn/ftr-common-functional-ui-services'; import basicClusterFixture from './fixtures/basiccluster.json'; import multiClusterFixture from './fixtures/multicluster.json'; import type { FtrProviderContext } from '../../ftr_provider_context'; diff --git a/x-pack/test/common/services/bsearch_secure.ts b/x-pack/test/common/services/bsearch_secure.ts index f454aa3818ea6..ccd1866ddd66e 100644 --- a/x-pack/test/common/services/bsearch_secure.ts +++ b/x-pack/test/common/services/bsearch_secure.ts @@ -5,8 +5,8 @@ * 2.0. */ -// NOTE: This is pretty much a copy/paste from test/common/services/bsearch.ts but with the ability -// to provide custom auth +// NOTE: This is pretty much a copy/paste from packages/kbn-ftr-common-functional-services/services/bsearch.ts +// but with the ability to provide custom auth import expect from '@kbn/expect'; import request from 'superagent'; diff --git a/x-pack/test/common/services/index.ts b/x-pack/test/common/services/index.ts index 5e931b440654a..edf64c828e944 100644 --- a/x-pack/test/common/services/index.ts +++ b/x-pack/test/common/services/index.ts @@ -6,7 +6,8 @@ */ import { services as kibanaApiIntegrationServices } from '@kbn/test-suites-src/api_integration/services'; -import { services as kibanaCommonServices } from '@kbn/test-suites-src/common/services'; +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'; @@ -14,7 +15,8 @@ import { ApmSynthtraceKibanaClientProvider } from './apm_synthtrace_kibana_clien import { InfraSynthtraceKibanaClientProvider } from './infra_synthtrace_kibana_client'; export const services = { - ...kibanaCommonServices, + ...commonFunctionalServices, + ...commonFunctionalUIServices, infraLogViews: InfraLogViewsServiceProvider, supertest: kibanaApiIntegrationServices.supertest, spaces: SpacesServiceProvider, diff --git a/x-pack/test/fleet_api_integration/apis/test_users.ts b/x-pack/test/fleet_api_integration/apis/test_users.ts index f84c1f72fb657..74581fd681af7 100644 --- a/x-pack/test/fleet_api_integration/apis/test_users.ts +++ b/x-pack/test/fleet_api_integration/apis/test_users.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { SecurityService } from '@kbn/test-suites-src/common/services/security/security'; +import type { SecurityService } from '@kbn/ftr-common-functional-ui-services'; export const testUsers: { [rollName: string]: { username: string; password: string; permissions?: any }; diff --git a/x-pack/test/fleet_cypress/services.ts b/x-pack/test/fleet_cypress/services.ts index 272cf7eb8da4e..8986c0928d750 100644 --- a/x-pack/test/fleet_cypress/services.ts +++ b/x-pack/test/fleet_cypress/services.ts @@ -4,5 +4,10 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; +import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services'; -export * from '@kbn/test-suites-src/common/services'; +export const services = { + ...commonFunctionalServices, + ...commonFunctionalUIServices, +} as const; diff --git a/x-pack/test/osquery_cypress/services.ts b/x-pack/test/osquery_cypress/services.ts index 272cf7eb8da4e..95fd493e6f668 100644 --- a/x-pack/test/osquery_cypress/services.ts +++ b/x-pack/test/osquery_cypress/services.ts @@ -5,4 +5,10 @@ * 2.0. */ -export * from '@kbn/test-suites-src/common/services'; +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; +import { commonFunctionalUIServices } from '@kbn/ftr-common-functional-ui-services'; + +export const services = { + ...commonFunctionalServices, + ...commonFunctionalUIServices, +} as const; diff --git a/x-pack/test/profiling_api_integration/common/create_profiling_users/helpers/create_or_update_user.ts b/x-pack/test/profiling_api_integration/common/create_profiling_users/helpers/create_or_update_user.ts index 679a750af410b..2f467d4507e7f 100644 --- a/x-pack/test/profiling_api_integration/common/create_profiling_users/helpers/create_or_update_user.ts +++ b/x-pack/test/profiling_api_integration/common/create_profiling_users/helpers/create_or_update_user.ts @@ -8,7 +8,7 @@ /* eslint-disable no-console */ import { difference, union } from 'lodash'; -import { SecurityService } from '@kbn/test-suites-src/common/services/security/security'; +import type { SecurityService } from '@kbn/ftr-common-functional-ui-services'; import { Elasticsearch, Kibana } from '..'; import { callKibana, isAxiosError } from './call_kibana'; diff --git a/x-pack/test/profiling_api_integration/common/create_profiling_users/index.ts b/x-pack/test/profiling_api_integration/common/create_profiling_users/index.ts index d7c101dd52eaa..18a056b001c56 100644 --- a/x-pack/test/profiling_api_integration/common/create_profiling_users/index.ts +++ b/x-pack/test/profiling_api_integration/common/create_profiling_users/index.ts @@ -5,7 +5,7 @@ * 2.0. */ import { asyncForEach } from '@kbn/std'; -import { SecurityService } from '@kbn/test-suites-src/common/services/security/security'; +import type { SecurityService } from '@kbn/ftr-common-functional-ui-services'; import { ProfilingUsername, profilingUsers } from './authentication'; import { AbortError, callKibana } from './helpers/call_kibana'; import { createOrUpdateUser } from './helpers/create_or_update_user'; diff --git a/x-pack/test/saved_objects_field_count/config.ts b/x-pack/test/saved_objects_field_count/config.ts index eb2aeb1df90a9..603a325ca0479 100644 --- a/x-pack/test/saved_objects_field_count/config.ts +++ b/x-pack/test/saved_objects_field_count/config.ts @@ -6,6 +6,7 @@ */ import { FtrConfigProviderContext } from '@kbn/test'; +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; export default async function ({ readConfigFile }: FtrConfigProviderContext) { const kibanaCommonTestsConfig = await readConfigFile( @@ -15,6 +16,10 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { return { ...kibanaCommonTestsConfig.getAll(), + services: { + ...commonFunctionalServices, + }, + testFiles: [require.resolve('./test')], esTestCluster: { 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 da57ccf64860e..00df4f0374c27 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 @@ -9,7 +9,7 @@ import supertest from 'supertest'; 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/test-suites-src/common/services/bsearch'; +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 { FtrProviderContext } from '../../ftr_provider_context'; import type { SecuritySolutionUtilsInterface } from './types'; 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 72397582dad00..838f31e69412e 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 @@ -9,7 +9,7 @@ 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/test-suites-src/common/services/bsearch'; +import type { BsearchService, SendOptions } from '@kbn/ftr-common-functional-services'; export interface SecuritySolutionServerlessBsearch extends Omit { send: (options: SendOptions) => Promise; diff --git a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/users_and_roles.ts b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/users_and_roles.ts index 3bccaf4a00fe3..a9663cd943a78 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/users_and_roles.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/entity_analytics/utils/users_and_roles.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { SecurityService } from '@kbn/test-suites-src/common/services/security/security'; +import type { SecurityService } from '@kbn/ftr-common-functional-ui-services'; export const usersAndRolesFactory = (security: SecurityService) => ({ createRole: async ({ name, privileges }: { name: string; privileges: any }) => { 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 1c74a987e4fec..cf2ac65f1086b 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/test-suites-src/common/services/bsearch'; +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; import { hostDetailsFilebeatExpectedResult } from '../mocks/host_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 a39da25c81aa3..80052ef3ddf56 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/test-suites-src/common/services/bsearch'; +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; 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 19710d4eedf45..22001c26b66b5 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/test-suites-src/common/services/bsearch'; +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; const FROM = '2000-01-01T00:00:00.000Z'; 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 5e9040424713b..166af42ba5702 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/test-suites-src/common/services/bsearch'; +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; 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 7254dc6e99a5e..22edc8cff64de 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/test-suites-src/common/services/bsearch'; +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; export default function ({ getService }: FtrProviderContextWithSpaces) { 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 2306861471073..8b1adb16975f6 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/test-suites-src/common/services/bsearch'; +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; 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 4c555ca0d6555..36b2b677a1949 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 @@ -14,7 +14,8 @@ import { NetworkTlsStrategyResponse, } from '@kbn/security-solution-plugin/common/search_strategy'; import TestAgent from 'supertest/lib/agent'; -import { BsearchService } from '@kbn/test-suites-src/common/services/bsearch'; + +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; 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 d99fbd296ba3e..ffb287239ac0f 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/test-suites-src/common/services/bsearch'; +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; export default function ({ getService }: FtrProviderContextWithSpaces) { 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 952e3eed8f8af..f8d4aa80c0e3d 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/test-suites-src/common/services/bsearch'; +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; export default function ({ getService }: FtrProviderContextWithSpaces) { 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 d7329a597e2e0..39dddc7a0c046 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/test-suites-src/common/services/bsearch'; +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; const FROM = '2000-01-01T00:00:00.000Z'; 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 65b44bf4cbc5e..6765e6d2bb164 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 @@ -14,7 +14,8 @@ import { NetworkUsersStrategyResponse, } from '@kbn/security-solution-plugin/common/search_strategy'; import TestAgent from 'supertest/lib/agent'; -import { BsearchService } from '@kbn/test-suites-src/common/services/bsearch'; + +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; diff --git a/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/tests/events.ts b/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/tests/events.ts index c66978bbe1b42..c42ac64de4a23 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/tests/events.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/tests/events.ts @@ -14,8 +14,9 @@ import { TimelineEventsAllStrategyResponse, } from '@kbn/security-solution-plugin/common/search_strategy'; import TestAgent from 'supertest/lib/agent'; -import { BsearchService } from '@kbn/test-suites-src/common/services/bsearch'; +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; + import { getFieldsToRequest, getFilterValue } from '../../../../utils'; const TO = '3000-01-01T00:00:00.000Z'; diff --git a/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/tests/timeline_details.ts b/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/tests/timeline_details.ts index 1e3119260455d..12539d43a145f 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/tests/timeline_details.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/investigation/timeline/trial_license_complete_tier/tests/timeline_details.ts @@ -13,7 +13,8 @@ import { TimelineKpiStrategyResponse, } from '@kbn/security-solution-plugin/common/search_strategy'; import TestAgent from 'supertest/lib/agent'; -import { BsearchService } from '@kbn/test-suites-src/common/services/bsearch'; + +import { BsearchService } from '@kbn/ftr-common-functional-services'; import { FtrProviderContextWithSpaces } from '../../../../../ftr_provider_context_with_spaces'; import { timelineDetailsFilebeatExpectedResults as EXPECTED_DATA } from '../mocks/timeline_details'; diff --git a/x-pack/test/security_solution_api_integration/tsconfig.json b/x-pack/test/security_solution_api_integration/tsconfig.json index 2f420920027d5..1f558e3c3f051 100644 --- a/x-pack/test/security_solution_api_integration/tsconfig.json +++ b/x-pack/test/security_solution_api_integration/tsconfig.json @@ -49,6 +49,6 @@ "@kbn/dev-cli-runner", "@kbn/search-types", "@kbn/security-plugin", - "@kbn/test-suites-src", + "@kbn/ftr-common-functional-ui-services", ] } diff --git a/x-pack/test/threat_intelligence_cypress/config.ts b/x-pack/test/threat_intelligence_cypress/config.ts index 963cfab55dad5..c2e9a6ac8b180 100644 --- a/x-pack/test/threat_intelligence_cypress/config.ts +++ b/x-pack/test/threat_intelligence_cypress/config.ts @@ -6,9 +6,8 @@ */ import { FtrConfigProviderContext } from '@kbn/test'; - import { CA_CERT_PATH } from '@kbn/dev-utils'; - +import { services } from './services'; export default async function ({ readConfigFile }: FtrConfigProviderContext) { const kibanaCommonTestsConfig = await readConfigFile( require.resolve('@kbn/test-suites-src/common/config') @@ -20,6 +19,8 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { return { ...kibanaCommonTestsConfig.getAll(), + services, + esTestCluster: { ...xpackFunctionalTestsConfig.get('esTestCluster'), serverArgs: [ diff --git a/x-pack/test/upgrade_assistant_integration/config.js b/x-pack/test/upgrade_assistant_integration/config.js index dbdf0ade8affe..9529e4bc568d3 100644 --- a/x-pack/test/upgrade_assistant_integration/config.js +++ b/x-pack/test/upgrade_assistant_integration/config.js @@ -5,6 +5,8 @@ * 2.0. */ +import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; + export default async function ({ readConfigFile }) { // Read the Kibana API integration tests config file so that we can utilize its services. const kibanaAPITestsConfig = await readConfigFile( @@ -13,15 +15,12 @@ export default async function ({ readConfigFile }) { const xPackFunctionalTestsConfig = await readConfigFile( require.resolve('../functional/config.base.js') ); - const kibanaCommonConfig = await readConfigFile( - require.resolve('@kbn/test-suites-src/common/config') - ); return { testFiles: [require.resolve('./upgrade_assistant')], servers: xPackFunctionalTestsConfig.get('servers'), services: { - ...kibanaCommonConfig.get('services'), + ...commonFunctionalServices, supertest: kibanaAPITestsConfig.get('services.supertest'), }, junit: { diff --git a/x-pack/test_serverless/api_integration/test_suites/common/console/autocomplete_entities.ts b/x-pack/test_serverless/api_integration/test_suites/common/console/autocomplete_entities.ts index 72640103c0ef9..3ec162ad28ffd 100644 --- a/x-pack/test_serverless/api_integration/test_suites/common/console/autocomplete_entities.ts +++ b/x-pack/test_serverless/api_integration/test_suites/common/console/autocomplete_entities.ts @@ -11,7 +11,7 @@ import { InternalRequestHeader, RoleCredentials } from '../../../../shared/servi export default ({ getService }: FtrProviderContext) => { const svlCommonApi = getService('svlCommonApi'); - const consoleService = getService('console'); + const console = getService('console'); const svlUserManager = getService('svlUserManager'); const supertestWithoutAuth = getService('supertestWithoutAuth'); @@ -27,17 +27,6 @@ export default ({ getService }: FtrProviderContext) => { }; describe('/api/console/autocomplete_entities', function () { - let createIndex: (typeof consoleService)['helpers']['createIndex']; - let createAlias: (typeof consoleService)['helpers']['createAlias']; - let createIndexTemplate: (typeof consoleService)['helpers']['createIndexTemplate']; - let createComponentTemplate: (typeof consoleService)['helpers']['createComponentTemplate']; - let createDataStream: (typeof consoleService)['helpers']['createDataStream']; - let deleteIndex: (typeof consoleService)['helpers']['deleteIndex']; - let deleteAlias: (typeof consoleService)['helpers']['deleteAlias']; - let deleteIndexTemplate: (typeof consoleService)['helpers']['deleteIndexTemplate']; - let deleteComponentTemplate: (typeof consoleService)['helpers']['deleteComponentTemplate']; - let deleteDataStream: (typeof consoleService)['helpers']['deleteDataStream']; - const indexName = 'test-index-1'; const aliasName = 'test-alias-1'; const indexTemplateName = 'test-index-template-1'; @@ -47,36 +36,26 @@ export default ({ getService }: FtrProviderContext) => { before(async () => { roleAuthc = await svlUserManager.createM2mApiKeyWithRoleScope('admin'); internalRequestHeader = svlCommonApi.getInternalRequestHeader(); - ({ - helpers: { - createIndex, - createAlias, - createIndexTemplate, - createComponentTemplate, - createDataStream, - deleteIndex, - deleteAlias, - deleteIndexTemplate, - deleteComponentTemplate, - deleteDataStream, - }, - } = consoleService); // Setup indices, aliases, templates, and data streams - await createIndex(indexName); - await createAlias(indexName, aliasName); - await createComponentTemplate(componentTemplateName); - await createIndexTemplate(indexTemplateName, [dataStreamName], [componentTemplateName]); - await createDataStream(dataStreamName); + await console.createIndex(indexName); + await console.createAlias(indexName, aliasName); + await console.createComponentTemplate(componentTemplateName); + await console.createIndexTemplate( + indexTemplateName, + [dataStreamName], + [componentTemplateName] + ); + await console.createDataStream(dataStreamName); }); after(async () => { // Cleanup indices, aliases, templates, and data streams - await deleteAlias(indexName, aliasName); - await deleteIndex(indexName); - await deleteDataStream(dataStreamName); - await deleteIndexTemplate(indexTemplateName); - await deleteComponentTemplate(componentTemplateName); + await console.deleteAlias(indexName, aliasName); + await console.deleteIndex(indexName); + await console.deleteDataStream(dataStreamName); + await console.deleteIndexTemplate(indexTemplateName); + await console.deleteComponentTemplate(componentTemplateName); await svlUserManager.invalidateM2mApiKeyWithRoleScope(roleAuthc); }); diff --git a/x-pack/test_serverless/shared/services/bsearch_secure.ts b/x-pack/test_serverless/shared/services/bsearch_secure.ts index 7ebe89bed8247..03f8241c9e12a 100644 --- a/x-pack/test_serverless/shared/services/bsearch_secure.ts +++ b/x-pack/test_serverless/shared/services/bsearch_secure.ts @@ -5,8 +5,8 @@ * 2.0. */ -// NOTE: This is pretty much a copy/paste from test/common/services/bsearch.ts but with the ability -// to provide custom auth +// NOTE: This is pretty much a copy/paste from packages/kbn-ftr-common-functional-services/services/bsearch.ts +// but with the ability to provide custom auth import expect from '@kbn/expect'; import { GenericFtrService } from '@kbn/test';