-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds api integration tests for core to serverless common (#167570)
- Loading branch information
1 parent
0ae3b23
commit 642ad7f
Showing
7 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
x-pack/test_serverless/api_integration/test_suites/common/core/capabilities.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}); | ||
}); | ||
}); | ||
} |
43 changes: 43 additions & 0 deletions
43
x-pack/test_serverless/api_integration/test_suites/common/core/compression.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
}); | ||
}); | ||
} |
16 changes: 16 additions & 0 deletions
16
x-pack/test_serverless/api_integration/test_suites/common/core/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); | ||
}); | ||
} |
31 changes: 31 additions & 0 deletions
31
x-pack/test_serverless/api_integration/test_suites/common/core/translations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters