diff --git a/packages/kbn-ftr-common-functional-services/services/es.ts b/packages/kbn-ftr-common-functional-services/services/es.ts index fe9aafbf10736..5fe5a4b095fc1 100644 --- a/packages/kbn-ftr-common-functional-services/services/es.ts +++ b/packages/kbn-ftr-common-functional-services/services/es.ts @@ -13,9 +13,15 @@ import { FtrProviderContext } from './ftr_provider_context'; export function EsProvider({ getService }: FtrProviderContext): Client { const config = getService('config'); + const isServerless = !!config.get('serverless'); - return createEsClientForFtrConfig(config, { - // Use system indices user so tests can write to system indices - authOverride: systemIndicesSuperuser, - }); + return createEsClientForFtrConfig( + config, + isServerless + ? {} + : { + // Use system indices user so tests can write to system indices + authOverride: systemIndicesSuperuser, + } + ); } diff --git a/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts b/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts index 5b06393cf7d50..5e96bfef3954a 100644 --- a/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts +++ b/packages/kbn-test/src/functional_test_runner/functional_test_runner.ts @@ -60,7 +60,8 @@ export class FunctionalTestRunner { : this.getStubProviderCollection(coreProviders); if (realServices) { - if (providers.hasService('es')) { + // Skip ES version validation for serverless project + if (!this.config.get('serverless') && providers.hasService('es')) { await this.validateEsVersion(); } await providers.loadAll(); diff --git a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts b/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts index fbad913dc75fa..03c0cbc07e644 100644 --- a/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts +++ b/packages/kbn-test/src/functional_test_runner/lib/config/schema.ts @@ -89,6 +89,7 @@ export const schema = Joi.object() rootTags: Joi.array().items(Joi.string()), testFiles: Joi.array().items(Joi.string()), testRunner: Joi.func(), + serverless: Joi.boolean().default(false), suiteFiles: Joi.object() .keys({ @@ -200,7 +201,7 @@ export const schema = Joi.object() .keys({ license: Joi.valid('basic', 'trial', 'gold').default('basic'), from: Joi.string().default('snapshot'), - serverArgs: Joi.array().items(Joi.string()), + serverArgs: Joi.array().items(Joi.string()).default([]), esJavaOpts: Joi.string(), dataArchive: Joi.string(), ssl: Joi.boolean().default(false), diff --git a/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.ts b/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.ts index b8f6fc4714273..40d4da7d76d76 100644 --- a/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.ts +++ b/packages/kbn-test/src/functional_tests/lib/run_elasticsearch.ts @@ -34,7 +34,7 @@ function getEsConfig({ }: RunElasticsearchOptions) { const ssl = !!config.get('esTestCluster.ssl'); const license: 'basic' | 'trial' | 'gold' = config.get('esTestCluster.license'); - const esArgs: string[] = config.get('esTestCluster.serverArgs') ?? []; + const esArgs: string[] = config.get('esTestCluster.serverArgs'); const esJavaOpts: string | undefined = config.get('esTestCluster.esJavaOpts'); const isSecurityEnabled = esArgs.includes('xpack.security.enabled=true'); diff --git a/test/common/services/security/system_indices_user.ts b/test/common/services/security/system_indices_user.ts index 9bfaddd9f0306..52e166c645093 100644 --- a/test/common/services/security/system_indices_user.ts +++ b/test/common/services/security/system_indices_user.ts @@ -68,8 +68,9 @@ export async function createSystemIndicesUser(ctx: FtrProviderContext) { const enabled = !config .get('esTestCluster.serverArgs') .some((arg: string) => arg === 'xpack.security.enabled=false'); + const isServerless = !!config.get('serverless'); - if (!enabled) { + if (!enabled || isServerless) { return; } diff --git a/x-pack/test_serverless/api_integration/test_suites/common/security_users.ts b/x-pack/test_serverless/api_integration/test_suites/common/security_users.ts index fd99de273df9c..af4e97fff06bc 100644 --- a/x-pack/test_serverless/api_integration/test_suites/common/security_users.ts +++ b/x-pack/test_serverless/api_integration/test_suites/common/security_users.ts @@ -11,7 +11,9 @@ export default function ({ getService }: FtrProviderContext) { const svlCommonApi = getService('svlCommonApi'); const supertest = getService('supertest'); - describe('security/users', function () { + // Test should be unskipped when the API is disabled + // https://github.com/elastic/kibana/issues/161337 + describe.skip('security/users', function () { it('rejects request to create user', async () => { const { body, status } = await supertest .post(`/internal/security/users/some_testuser`) diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/index.ts b/x-pack/test_serverless/api_integration/test_suites/observability/index.ts index 1b571e6e0f7a5..1020ebc74d551 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/index.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/index.ts @@ -9,7 +9,6 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('serverless observability API', function () { - loadTestFile(require.resolve('./security_users')); loadTestFile(require.resolve('./snapshot_telemetry')); }); } diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/security_users.ts b/x-pack/test_serverless/api_integration/test_suites/observability/security_users.ts deleted file mode 100644 index b3ccb00830b26..0000000000000 --- a/x-pack/test_serverless/api_integration/test_suites/observability/security_users.ts +++ /dev/null @@ -1,31 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { FtrProviderContext } from '../../ftr_provider_context'; - -export default function ({ getService }: FtrProviderContext) { - const svlCommonApi = getService('svlCommonApi'); - const supertest = getService('supertest'); - - /* - * This is a placeholder test to demonstrate usage. - * This test case is actually already covered in the `serverless` plugin tests - * and should be replaced with something specific to the observability project - * once it modifies / adds / disables Kibana APIs. - */ - describe('security/users', function () { - it('rejects request to create user', async () => { - const { body, status } = await supertest - .post(`/internal/security/users/some_testuser`) - .set(svlCommonApi.getCommonRequestHeader()) - .send({ username: 'some_testuser', password: 'testpassword', roles: [] }); - - // in a non-serverless environment this would succeed with a 200 - svlCommonApi.assertResponseStatusCode(400, status, body); - }); - }); -} diff --git a/x-pack/test_serverless/api_integration/test_suites/search/index.ts b/x-pack/test_serverless/api_integration/test_suites/search/index.ts index 21fea435a53a2..20c04f741b1ac 100644 --- a/x-pack/test_serverless/api_integration/test_suites/search/index.ts +++ b/x-pack/test_serverless/api_integration/test_suites/search/index.ts @@ -9,7 +9,6 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('serverless search API', function () { - loadTestFile(require.resolve('./security_users')); loadTestFile(require.resolve('./snapshot_telemetry')); }); } diff --git a/x-pack/test_serverless/api_integration/test_suites/search/security_users.ts b/x-pack/test_serverless/api_integration/test_suites/search/security_users.ts deleted file mode 100644 index bb6391f167cc2..0000000000000 --- a/x-pack/test_serverless/api_integration/test_suites/search/security_users.ts +++ /dev/null @@ -1,31 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { FtrProviderContext } from '../../ftr_provider_context'; - -export default function ({ getService }: FtrProviderContext) { - const svlCommonApi = getService('svlCommonApi'); - const supertest = getService('supertest'); - - /* - * This is a placeholder test to demonstrate usage. - * This test case is actually already covered in the `serverless` plugin tests - * and should be replaced with something specific to the search project - * once it modifies / adds / disables Kibana APIs. - */ - describe('security/users', function () { - it('rejects request to create user', async () => { - const { body, status } = await supertest - .post(`/internal/security/users/some_testuser`) - .set(svlCommonApi.getCommonRequestHeader()) - .send({ username: 'some_testuser', password: 'testpassword', roles: [] }); - - // in a non-serverless environment this would succeed with a 200 - svlCommonApi.assertResponseStatusCode(400, status, body); - }); - }); -} diff --git a/x-pack/test_serverless/api_integration/test_suites/security/index.ts b/x-pack/test_serverless/api_integration/test_suites/security/index.ts index 22b9e23010b6a..9dc97ea8a9b57 100644 --- a/x-pack/test_serverless/api_integration/test_suites/security/index.ts +++ b/x-pack/test_serverless/api_integration/test_suites/security/index.ts @@ -9,7 +9,6 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ loadTestFile }: FtrProviderContext) { describe('serverless security API', function () { - loadTestFile(require.resolve('./security_users')); loadTestFile(require.resolve('./snapshot_telemetry')); }); } diff --git a/x-pack/test_serverless/api_integration/test_suites/security/security_users.ts b/x-pack/test_serverless/api_integration/test_suites/security/security_users.ts deleted file mode 100644 index 3b389f1aff527..0000000000000 --- a/x-pack/test_serverless/api_integration/test_suites/security/security_users.ts +++ /dev/null @@ -1,31 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { FtrProviderContext } from '../../ftr_provider_context'; - -export default function ({ getService }: FtrProviderContext) { - const svlCommonApi = getService('svlCommonApi'); - const supertest = getService('supertest'); - - /* - * This is a placeholder test to demonstrate usage. - * This test case is actually already covered in the `serverless` plugin tests - * and should be replaced with something specific to the security project - * once it modifies / adds / disables Kibana APIs. - */ - describe('security/users', function () { - it('rejects request to create user', async () => { - const { body, status } = await supertest - .post(`/internal/security/users/some_testuser`) - .set(svlCommonApi.getCommonRequestHeader()) - .send({ username: 'some_testuser', password: 'testpassword', roles: [] }); - - // in a non-serverless environment this would succeed with a 200 - svlCommonApi.assertResponseStatusCode(400, status, body); - }); - }); -} diff --git a/x-pack/test_serverless/shared/config.base.ts b/x-pack/test_serverless/shared/config.base.ts index 49158e78dcda2..4c7f1e89aa2e8 100644 --- a/x-pack/test_serverless/shared/config.base.ts +++ b/x-pack/test_serverless/shared/config.base.ts @@ -23,7 +23,6 @@ export default async () => { esTestCluster: { license: 'trial', from: 'snapshot', - serverArgs: ['xpack.security.enabled=false'], }, kbnTestServer: { @@ -62,6 +61,11 @@ export default async () => { ], }, + security: { disableTestUser: true }, + + // Used by FTR to recognize serverless project and change its behavior accordingly + serverless: true, + // overriding default timeouts from packages/kbn-test/src/functional_test_runner/lib/config/schema.ts // so we can easily adjust them for serverless where needed timeouts: {