mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Http compression config (#50738)
HTTP compression for responses may be disabled entirely, or it may be conditionally enabled based on a whitelist of trusted referrers.
This commit is contained in:
parent
4e820b5be1
commit
5906801b4f
17 changed files with 284 additions and 23 deletions
|
@ -16,21 +16,55 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import expect from '@kbn/expect';
|
||||
|
||||
export default function ({ getService }) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('core request context', () => {
|
||||
it('provides access to elasticsearch', async () => (
|
||||
await supertest
|
||||
.get('/requestcontext/elasticsearch')
|
||||
.expect(200, 'Elasticsearch: true')
|
||||
));
|
||||
describe('core', () => {
|
||||
describe('request context', () => {
|
||||
it('provides access to elasticsearch', async () => (
|
||||
await supertest
|
||||
.get('/requestcontext/elasticsearch')
|
||||
.expect(200, 'Elasticsearch: true')
|
||||
));
|
||||
|
||||
it('provides access to SavedObjects client', async () => (
|
||||
await supertest
|
||||
.get('/requestcontext/savedobjectsclient')
|
||||
.expect(200, 'SavedObjects client: {"page":1,"per_page":20,"total":0,"saved_objects":[]}')
|
||||
));
|
||||
it('provides access to SavedObjects client', async () => (
|
||||
await supertest
|
||||
.get('/requestcontext/savedobjectsclient')
|
||||
.expect(200, 'SavedObjects client: {"page":1,"per_page":20,"total":0,"saved_objects":[]}')
|
||||
));
|
||||
});
|
||||
|
||||
describe('compression', () => {
|
||||
it(`uses compression when there isn't a referer`, async () => {
|
||||
await supertest
|
||||
.get('/app/kibana')
|
||||
.set('accept-encoding', 'gzip')
|
||||
.then(response => {
|
||||
expect(response.headers).to.have.property('content-encoding', 'gzip');
|
||||
});
|
||||
});
|
||||
|
||||
it(`uses compression when there is a whitelisted referer`, async () => {
|
||||
await supertest
|
||||
.get('/app/kibana')
|
||||
.set('accept-encoding', 'gzip')
|
||||
.set('referer', 'https://some-host.com')
|
||||
.then(response => {
|
||||
expect(response.headers).to.have.property('content-encoding', 'gzip');
|
||||
});
|
||||
});
|
||||
|
||||
it(`doesn't use compression when there is a non-whitelisted referer`, async () => {
|
||||
await supertest
|
||||
.get('/app/kibana')
|
||||
.set('accept-encoding', 'gzip')
|
||||
.set('referer', 'https://other.some-host.com')
|
||||
.then(response => {
|
||||
expect(response.headers).not.to.have.property('content-encoding');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue