2020-12-10 15:14:09 +01:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
2021-02-04 03:12:39 +01:00
|
|
|
* 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.
|
2020-12-10 15:14:09 +01:00
|
|
|
*/
|
2021-02-04 03:12:39 +01:00
|
|
|
|
2020-12-10 15:14:09 +01:00
|
|
|
import expect from '@kbn/expect';
|
|
|
|
|
|
|
|
import { FtrProviderContext } from '../ftr_provider_context';
|
|
|
|
|
|
|
|
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|
|
|
const browser = getService('browser');
|
|
|
|
const config = getService('config');
|
|
|
|
const find = getService('find');
|
|
|
|
|
|
|
|
describe('CORS', () => {
|
|
|
|
it('Communicates to Kibana with configured CORS', async () => {
|
|
|
|
const args: string[] = config.get('kbnTestServer.serverArgs');
|
2020-12-14 13:57:28 +01:00
|
|
|
const originSetting = args.find((str) => str.includes('server.cors.allowOrigin'));
|
2020-12-10 15:14:09 +01:00
|
|
|
if (!originSetting) {
|
2020-12-14 13:57:28 +01:00
|
|
|
throw new Error('Cannot find "server.cors.allowOrigin" argument');
|
2020-12-10 15:14:09 +01:00
|
|
|
}
|
|
|
|
const [, value] = originSetting.split('=');
|
|
|
|
const url = JSON.parse(value);
|
|
|
|
|
|
|
|
await browser.navigateTo(url[0]);
|
|
|
|
const element = await find.byCssSelector('p');
|
|
|
|
expect(await element.getVisibleText()).to.be('content from kibana');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|