mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Migrate /translations
route to core (#83280)
* move i18n route to core * add FTR test for endpoint
This commit is contained in:
parent
66def097ad
commit
d1abc866d4
11 changed files with 255 additions and 96 deletions
55
test/api_integration/apis/core/compression.ts
Normal file
55
test/api_integration/apis/core/compression.ts
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import expect from '@kbn/expect';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
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.header).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.header).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.header).not.to.have.property('content-encoding');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import expect from '@kbn/expect';
|
||||
|
||||
export default function ({ getService }) {
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('core', () => {
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
27
test/api_integration/apis/core/index.ts
Normal file
27
test/api_integration/apis/core/index.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('core', () => {
|
||||
loadTestFile(require.resolve('./compression'));
|
||||
loadTestFile(require.resolve('./translations'));
|
||||
});
|
||||
}
|
42
test/api_integration/apis/core/translations.ts
Normal file
42
test/api_integration/apis/core/translations.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue