diff --git a/test/api_integration/services/supertest.ts b/test/api_integration/services/supertest.ts index 6680c7b203bd5..baf42703c64a0 100644 --- a/test/api_integration/services/supertest.ts +++ b/test/api_integration/services/supertest.ts @@ -22,10 +22,14 @@ export function KibanaSupertestProvider({ getService }: FtrProviderContext) { export function ElasticsearchSupertestProvider({ getService }: FtrProviderContext) { const config = getService('config'); const esServerConfig = config.get('servers.elasticsearch'); + + // For stateful tests, use system indices user so tests can write to system indices + // For serverless tests, we don't have a system indices user, so we're using the default superuser const elasticSearchServerUrl = formatUrl({ ...esServerConfig, - // Use system indices user so tests can write to system indices - auth: `${systemIndicesSuperuser.username}:${systemIndicesSuperuser.password}`, + ...(config.get('serverless') + ? [] + : { auth: `${systemIndicesSuperuser.username}:${systemIndicesSuperuser.password}` }), }); let agentOptions = {}; diff --git a/x-pack/test_serverless/api_integration/test_suites/common/elasticsearch_api.ts b/x-pack/test_serverless/api_integration/test_suites/common/elasticsearch_api.ts new file mode 100644 index 0000000000000..b55f36cab29aa --- /dev/null +++ b/x-pack/test_serverless/api_integration/test_suites/common/elasticsearch_api.ts @@ -0,0 +1,20 @@ +/* + * 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 esSupertest = getService('esSupertest'); + const svlCommonApi = getService('svlCommonApi'); + + describe('Elasticsearch API', function () { + it('can request /', async () => { + const { body, status } = await esSupertest.get('/'); + svlCommonApi.assertResponseStatusCode(200, status, body); + }); + }); +} diff --git a/x-pack/test_serverless/api_integration/test_suites/common/index.ts b/x-pack/test_serverless/api_integration/test_suites/common/index.ts index ae68f7ec7670c..fffe386b7c2ba 100644 --- a/x-pack/test_serverless/api_integration/test_suites/common/index.ts +++ b/x-pack/test_serverless/api_integration/test_suites/common/index.ts @@ -34,5 +34,6 @@ export default function ({ loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./scripts_tests')); loadTestFile(require.resolve('./search_oss')); loadTestFile(require.resolve('./search_xpack')); + loadTestFile(require.resolve('./elasticsearch_api')); }); } diff --git a/x-pack/test_serverless/shared/config.base.ts b/x-pack/test_serverless/shared/config.base.ts index a15405cd0f231..5ea4a5eddf14f 100644 --- a/x-pack/test_serverless/shared/config.base.ts +++ b/x-pack/test_serverless/shared/config.base.ts @@ -27,7 +27,11 @@ export default async () => { protocol: 'https', certificateAuthorities: process.env.TEST_CLOUD ? undefined : [Fs.readFileSync(CA_CERT_PATH)], }, - elasticsearch: { ...esTestConfig.getUrlParts(), protocol: 'https' }, + elasticsearch: { + ...esTestConfig.getUrlParts(), + protocol: 'https', + certificateAuthorities: process.env.TEST_CLOUD ? undefined : [Fs.readFileSync(CA_CERT_PATH)], + }, }; // "Fake" SAML provider