No response compression when there is a referer (#47751)

* Hacking it in there, this is obviously not where this belongs

* Moving implementation to a private method

* Adding unit tests, I don't like the way I had to write these

* Adding integration tests

* Test not relying on implementation details...

* No longer using .inject, thanks Mikhail!!!

* Adding comment explaining the long body

* Fixing nesting of describes for api integration tests
This commit is contained in:
Brandon Kobel 2019-10-21 06:35:11 -07:00 committed by GitHub
parent 28c374ace5
commit 85e5885ccf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 93 additions and 11 deletions

View file

@ -16,21 +16,45 @@
* 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(`doesn't use compression when there is a referer`, async () => {
await supertest
.get('/app/kibana')
.set('accept-encoding', 'gzip')
.set('referer', 'https://www.google.com')
.then(response => {
expect(response.headers).not.to.have.property('content-encoding');
});
});
});
});
}