diff --git a/x-pack/test_serverless/api_integration/test_suites/common/core/capabilities.ts b/x-pack/test_serverless/api_integration/test_suites/common/core/capabilities.ts new file mode 100644 index 0000000000000..a05c0d99bd331 --- /dev/null +++ b/x-pack/test_serverless/api_integration/test_suites/common/core/capabilities.ts @@ -0,0 +1,30 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const svlCommonApi = getService('svlCommonApi'); + describe('/api/core/capabilities', () => { + it(`returns a 400 when an invalid app id is provided`, async () => { + const { body } = await supertest + .post('/api/core/capabilities') + .set(svlCommonApi.getInternalRequestHeader()) + .send({ + applications: ['dashboard', 'discover', 'bad%app'], + }) + .expect(400); + expect(body).to.eql({ + statusCode: 400, + error: 'Bad Request', + message: '[request body.applications.2]: Invalid application id', + }); + }); + }); +} diff --git a/x-pack/test_serverless/api_integration/test_suites/common/core/compression.ts b/x-pack/test_serverless/api_integration/test_suites/common/core/compression.ts new file mode 100644 index 0000000000000..3284d065c9b60 --- /dev/null +++ b/x-pack/test_serverless/api_integration/test_suites/common/core/compression.ts @@ -0,0 +1,43 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + const svlCommonApi = getService('svlCommonApi'); + + const compressionSuite = (url: string) => { + it(`uses compression when there isn't a referer`, async () => { + await supertest + .get(url) + .set('accept-encoding', 'gzip') + .set(svlCommonApi.getInternalRequestHeader()) + .then((response) => { + expect(response.header).to.have.property('content-encoding', 'gzip'); + }); + }); + + it(`uses compression when there is a whitelisted referer`, async () => { + await supertest + .get(url) + .set('accept-encoding', 'gzip') + .set(svlCommonApi.getInternalRequestHeader()) + .set('referer', 'https://some-host.com') + .then((response) => { + expect(response.header).to.have.property('content-encoding', 'gzip'); + }); + }); + }; + + describe('compression', () => { + describe('against an application page', () => { + compressionSuite('/app/kibana'); + }); + }); +} diff --git a/x-pack/test_serverless/api_integration/test_suites/common/core/index.ts b/x-pack/test_serverless/api_integration/test_suites/common/core/index.ts new file mode 100644 index 0000000000000..f55f77bd7e6ab --- /dev/null +++ b/x-pack/test_serverless/api_integration/test_suites/common/core/index.ts @@ -0,0 +1,16 @@ +/* + * 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 ({ loadTestFile }: FtrProviderContext) { + describe('core', () => { + loadTestFile(require.resolve('./compression')); + loadTestFile(require.resolve('./translations')); + loadTestFile(require.resolve('./capabilities')); + }); +} diff --git a/x-pack/test_serverless/api_integration/test_suites/common/core/translations.ts b/x-pack/test_serverless/api_integration/test_suites/common/core/translations.ts new file mode 100644 index 0000000000000..26b4302bf2c71 --- /dev/null +++ b/x-pack/test_serverless/api_integration/test_suites/common/core/translations.ts @@ -0,0 +1,31 @@ +/* + * 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 expect from '@kbn/expect'; +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function ({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + + describe('translations', () => { + it(`returns the translations with the correct headers`, async () => { + await supertest.get('/translations/en.json').then((response) => { + expect(response.body.locale).to.eql('en'); + + expect(response.header).to.have.property('content-type', 'application/json; charset=utf-8'); + expect(response.header).to.have.property('cache-control', 'must-revalidate'); + expect(response.header).to.have.property('etag'); + }); + }); + + it(`returns a 404 when not using the correct locale`, async () => { + await supertest.get('/translations/foo.json').then((response) => { + expect(response.status).to.eql(404); + }); + }); + }); +} diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/common_configs/config.group1.ts b/x-pack/test_serverless/api_integration/test_suites/observability/common_configs/config.group1.ts index a04b9074662da..d1ce536ee1f6b 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/common_configs/config.group1.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/common_configs/config.group1.ts @@ -24,6 +24,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { require.resolve('../../common/scripts_tests'), require.resolve('../../common/search_oss'), require.resolve('../../common/search_xpack'), + require.resolve('../../common/core'), ], junit: { reportName: 'Serverless Observability API Integration Tests - Common Group 1', diff --git a/x-pack/test_serverless/api_integration/test_suites/search/common_configs/config.group1.ts b/x-pack/test_serverless/api_integration/test_suites/search/common_configs/config.group1.ts index 8a983926a12e6..b24b68b8e4a48 100644 --- a/x-pack/test_serverless/api_integration/test_suites/search/common_configs/config.group1.ts +++ b/x-pack/test_serverless/api_integration/test_suites/search/common_configs/config.group1.ts @@ -24,6 +24,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { require.resolve('../../common/scripts_tests'), require.resolve('../../common/search_oss'), require.resolve('../../common/search_xpack'), + require.resolve('../../common/core'), ], junit: { reportName: 'Serverless Search API Integration Tests - Common Group 1', diff --git a/x-pack/test_serverless/api_integration/test_suites/security/common_configs/config.group1.ts b/x-pack/test_serverless/api_integration/test_suites/security/common_configs/config.group1.ts index 995c62fea1fd5..a46be9dcf4f75 100644 --- a/x-pack/test_serverless/api_integration/test_suites/security/common_configs/config.group1.ts +++ b/x-pack/test_serverless/api_integration/test_suites/security/common_configs/config.group1.ts @@ -24,6 +24,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) { require.resolve('../../common/scripts_tests'), require.resolve('../../common/search_oss'), require.resolve('../../common/search_xpack'), + require.resolve('../../common/core'), ], junit: { reportName: 'Serverless Security API Integration Tests - Common Group 1',