Skip to content

Commit

Permalink
add tests for endpoints too
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Oct 24, 2022
1 parent e1e40d0 commit a310d06
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions test/api_integration/apis/core/compression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');

describe('compression', () => {
const compressionSuite = (url: string) => {
it(`uses compression when there isn't a referer`, async () => {
await supertest
.get('/app/kibana')
.get(url)
.set('accept-encoding', 'gzip')
.then((response) => {
expect(response.header).to.have.property('content-encoding', 'gzip');
Expand All @@ -24,7 +24,7 @@ export default function ({ getService }: FtrProviderContext) {

it(`uses compression when there is a whitelisted referer`, async () => {
await supertest
.get('/app/kibana')
.get(url)
.set('accept-encoding', 'gzip')
.set('referer', 'https://some-host.com')
.then((response) => {
Expand All @@ -34,7 +34,7 @@ export default function ({ getService }: FtrProviderContext) {

it(`doesn't use compression when there is a non-whitelisted referer`, async () => {
await supertest
.get('/app/kibana')
.get(url)
.set('accept-encoding', 'gzip')
.set('referer', 'https://other.some-host.com')
.then((response) => {
Expand All @@ -44,11 +44,20 @@ export default function ({ getService }: FtrProviderContext) {

it(`supports brotli compression`, async () => {
await supertest
.get('/app/kibana')
.get(url)
.set('accept-encoding', 'br')
.then((response) => {
expect(response.header).to.have.property('content-encoding', 'br');
});
});
};

describe('compression', () => {
describe('against an application page', () => {
compressionSuite('/app/kibana');
});
describe('against an endpoint', () => {
compressionSuite('/api/status');
});
});
}

0 comments on commit a310d06

Please sign in to comment.