diff --git a/src/platform/packages/shared/kbn-ftr-common-functional-services/index.ts b/src/platform/packages/shared/kbn-ftr-common-functional-services/index.ts index 890258ecfeedc..ac57172f85dc5 100644 --- a/src/platform/packages/shared/kbn-ftr-common-functional-services/index.ts +++ b/src/platform/packages/shared/kbn-ftr-common-functional-services/index.ts @@ -46,3 +46,4 @@ export { IndexPatternsService } from './services/index_patterns'; export { RandomnessService } from './services/randomness'; export { KibanaSupertestProvider, ElasticsearchSupertestProvider } from './services/supertest'; export { retryForSuccess } from './services/retry/retry_for_success'; +export { SecurityService } from './services/security'; diff --git a/src/platform/packages/shared/kbn-ftr-common-functional-services/services/all.ts b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/all.ts index dd11b2b914b08..aaba4aa6f8ff5 100644 --- a/src/platform/packages/shared/kbn-ftr-common-functional-services/services/all.ts +++ b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/all.ts @@ -21,6 +21,7 @@ import { RandomnessService } from './randomness'; import { SupertestWithoutAuthProvider } from './supertest_without_auth'; import { SamlAuthProvider } from './saml_auth'; import { KibanaSupertestProvider, ElasticsearchSupertestProvider } from './supertest'; +import { SecurityServiceProvider } from './security'; export const services = { es: EsProvider, @@ -38,4 +39,5 @@ export const services = { supertest: KibanaSupertestProvider, esSupertest: ElasticsearchSupertestProvider, supertestWithoutAuth: SupertestWithoutAuthProvider, + security: SecurityServiceProvider, }; diff --git a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/index.ts b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/index.ts similarity index 100% rename from src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/index.ts rename to src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/index.ts diff --git a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/role.ts b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/role.ts similarity index 100% rename from src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/role.ts rename to src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/role.ts diff --git a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/role_mappings.ts b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/role_mappings.ts similarity index 100% rename from src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/role_mappings.ts rename to src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/role_mappings.ts diff --git a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/security.ts b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/security.ts similarity index 100% rename from src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/security.ts rename to src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/security.ts diff --git a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/system_indices_user.ts b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/system_indices_user.ts similarity index 100% rename from src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/system_indices_user.ts rename to src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/system_indices_user.ts diff --git a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/test_user.ts b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/test_user.ts similarity index 91% rename from src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/test_user.ts rename to src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/test_user.ts index d5b9758cdfe55..469ae5adbb72e 100644 --- a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/test_user.ts +++ b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/test_user.ts @@ -10,8 +10,6 @@ import { format as formatUrl } from 'url'; import supertest from 'supertest'; -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'; @@ -23,15 +21,13 @@ export class TestUser extends FtrService { private readonly config = this.ctx.getService('config'); private readonly log = this.ctx.getService('log'); - private readonly browser: Browser | void = + private readonly browser = // browser service is not normally available in common. - this.ctx.hasService('browser') ? (this.ctx.getService('browser' as any) as Browser) : undefined; + this.ctx.hasService('browser') ? this.ctx.getService('browser' as any) : undefined; - private readonly testSubjects: TestSubjects | undefined = + private readonly testSubjects = // testSubject service is not normally available in common. - this.ctx.hasService('testSubjects') - ? (this.ctx.getService('testSubjects' as any) as TestSubjects) - : undefined; + this.ctx.hasService('testSubjects') ? this.ctx.getService('testSubjects' as any) : undefined; constructor( ctx: FtrProviderContext, @@ -129,7 +125,7 @@ export async function createTestUserService(ctx: FtrProviderContext, role: Role, // delete the test_user if present (will it error if the user doesn't exist?) try { - await user.delete(TEST_USER_NAME); + await user.delete(TEST_USER_NAME, { retries: 1 }); } catch (exception) { log.debug('no test user to delete'); } diff --git a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/user.ts b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/user.ts similarity index 96% rename from src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/user.ts rename to src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/user.ts index 72c046e1c4df4..38cd4357af493 100644 --- a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/security/user.ts +++ b/src/platform/packages/shared/kbn-ftr-common-functional-services/services/security/user.ts @@ -32,11 +32,12 @@ export class User { this.log.debug(`created user ${username}`); } - public async delete(username: string) { + public async delete(username: string, options?: { retries?: number }) { this.log.debug(`deleting user ${username}`); const { data, status, statusText } = await this.kbnClient.request({ path: `/internal/security/users/${username}`, method: 'DELETE', + retries: options?.retries, }); if (status !== 204) { throw new Error( diff --git a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/index.ts b/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/index.ts index c316ecf7db60e..d7b23ed67b61c 100644 --- a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/index.ts +++ b/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/index.ts @@ -23,4 +23,3 @@ 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/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/all.ts b/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/all.ts index 1f8efc610f8b7..beabb78b6aba6 100644 --- a/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/all.ts +++ b/src/platform/packages/shared/kbn-ftr-common-functional-ui-services/services/all.ts @@ -13,7 +13,6 @@ 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, @@ -22,5 +21,4 @@ export const services = { testSubjects: TestSubjects, browser: BrowserProvider, toasts: ToastsService, - security: SecurityServiceProvider, }; diff --git a/test/common/services/index.ts b/test/common/services/index.ts index c3fcdda2cf937..89b0e62a07e8a 100644 --- a/test/common/services/index.ts +++ b/test/common/services/index.ts @@ -8,7 +8,6 @@ */ import { commonFunctionalServices } from '@kbn/ftr-common-functional-services'; -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 { @@ -26,11 +25,9 @@ const { supertest, esSupertest, supertestWithoutAuth, + security, } = commonFunctionalServices; -// pick what was there previously -const { security } = commonFunctionalUIServices; - export const services = { es, esArchiver, 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 4d244391cf3d3..e828818cf3caf 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 @@ -9,8 +9,7 @@ import type { Agent as SuperTestAgent } from 'supertest'; import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; import { CLOUD_SECURITY_PLUGIN_VERSION } from '@kbn/cloud-security-posture-plugin/common/constants'; -import { SecurityService } from '@kbn/ftr-common-functional-ui-services'; -import { RoleCredentials } from '@kbn/ftr-common-functional-services'; +import { RoleCredentials, SecurityService } from '@kbn/ftr-common-functional-services'; export async function createPackagePolicy( supertest: SuperTestAgent, diff --git a/x-pack/test/api_integration/apis/telemetry/telemetry.ts b/x-pack/test/api_integration/apis/telemetry/telemetry.ts index f97848e93c3d3..af8d30069d140 100644 --- a/x-pack/test/api_integration/apis/telemetry/telemetry.ts +++ b/x-pack/test/api_integration/apis/telemetry/telemetry.ts @@ -32,7 +32,7 @@ import { ELASTIC_HTTP_VERSION_HEADER, X_ELASTIC_INTERNAL_ORIGIN_REQUEST, } from '@kbn/core-http-common'; -import type { SecurityService } from '@kbn/ftr-common-functional-ui-services'; +import type { SecurityService } from '@kbn/ftr-common-functional-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/index.ts b/x-pack/test/common/services/index.ts index 6c19691f768b7..26600a046e361 100644 --- a/x-pack/test/common/services/index.ts +++ b/x-pack/test/common/services/index.ts @@ -7,7 +7,6 @@ import { services as kibanaApiIntegrationServices } from '@kbn/test-suites-src/api_integration/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 { SearchSecureService } from './search_secure'; @@ -16,7 +15,6 @@ import { InfraSynthtraceKibanaClientProvider } from './infra_synthtrace_kibana_c export const services = { ...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 dbab463508fa2..ac944f0a1e669 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/ftr-common-functional-ui-services'; +import type { SecurityService } from '@kbn/ftr-common-functional-services'; export const testUsers: { [rollName: string]: { username: string; password: string; permissions?: any }; 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 2f467d4507e7f..3d7d650487d49 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 type { SecurityService } from '@kbn/ftr-common-functional-ui-services'; +import type { SecurityService } from '@kbn/ftr-common-functional-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 18a056b001c56..118644ea50e55 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 type { SecurityService } from '@kbn/ftr-common-functional-ui-services'; +import type { SecurityService } from '@kbn/ftr-common-functional-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/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 a9663cd943a78..1214931632c34 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 type { SecurityService } from '@kbn/ftr-common-functional-ui-services'; +import type { SecurityService } from '@kbn/ftr-common-functional-services'; export const usersAndRolesFactory = (security: SecurityService) => ({ createRole: async ({ name, privileges }: { name: string; privileges: any }) => { diff --git a/x-pack/test/security_solution_api_integration/tsconfig.json b/x-pack/test/security_solution_api_integration/tsconfig.json index 4d122d4adc29c..f395da2b562ba 100644 --- a/x-pack/test/security_solution_api_integration/tsconfig.json +++ b/x-pack/test/security_solution_api_integration/tsconfig.json @@ -49,7 +49,6 @@ "@kbn/elastic-assistant-common", "@kbn/search-types", "@kbn/security-plugin", - "@kbn/ftr-common-functional-ui-services", "@kbn/spaces-plugin", "@kbn/elastic-assistant-plugin", "@kbn/test-suites-src",