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
|
|
|
*/
|
|
|
|
|
|
|
|
import Url from 'url';
|
|
|
|
import Path from 'path';
|
2021-05-17 18:51:53 +02:00
|
|
|
import type { FtrConfigProviderContext } from '@kbn/test';
|
2020-12-10 15:14:09 +01:00
|
|
|
import { kbnTestConfig } from '@kbn/test';
|
|
|
|
import { pageObjects } from '../functional/page_objects';
|
|
|
|
|
2021-01-21 16:34:03 +01:00
|
|
|
const pluginPort = process.env.TEST_CORS_SERVER_PORT
|
|
|
|
? parseInt(process.env.TEST_CORS_SERVER_PORT, 10)
|
|
|
|
: 5699;
|
|
|
|
|
2020-12-10 15:14:09 +01:00
|
|
|
export default async function ({ readConfigFile }: FtrConfigProviderContext) {
|
|
|
|
const kibanaFunctionalConfig = await readConfigFile(require.resolve('../functional/config.js'));
|
|
|
|
|
|
|
|
const corsTestPlugin = Path.resolve(__dirname, './plugins/kibana_cors_test');
|
|
|
|
|
|
|
|
const servers = {
|
|
|
|
...kibanaFunctionalConfig.get('servers'),
|
|
|
|
elasticsearch: {
|
|
|
|
...kibanaFunctionalConfig.get('servers.elasticsearch'),
|
|
|
|
},
|
|
|
|
kibana: {
|
|
|
|
...kibanaFunctionalConfig.get('servers.kibana'),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const { protocol, hostname } = kbnTestConfig.getUrlParts();
|
|
|
|
const originUrl = Url.format({
|
|
|
|
protocol,
|
|
|
|
hostname,
|
|
|
|
port: pluginPort,
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
testFiles: [require.resolve('./tests')],
|
|
|
|
servers,
|
|
|
|
services: kibanaFunctionalConfig.get('services'),
|
|
|
|
pageObjects,
|
|
|
|
junit: {
|
|
|
|
reportName: 'Kibana CORS with X-Pack Security',
|
|
|
|
},
|
|
|
|
|
|
|
|
esTestCluster: kibanaFunctionalConfig.get('esTestCluster'),
|
|
|
|
apps: {
|
|
|
|
...kibanaFunctionalConfig.get('apps'),
|
|
|
|
},
|
|
|
|
|
|
|
|
kbnTestServer: {
|
|
|
|
...kibanaFunctionalConfig.get('kbnTestServer'),
|
|
|
|
serverArgs: [
|
|
|
|
...kibanaFunctionalConfig.get('kbnTestServer.serverArgs'),
|
|
|
|
`--plugin-path=${corsTestPlugin}`,
|
|
|
|
`--test.cors.port=${pluginPort}`,
|
|
|
|
'--server.cors.enabled=true',
|
2020-12-14 13:57:28 +01:00
|
|
|
'--server.cors.allowCredentials=true',
|
|
|
|
`--server.cors.allowOrigin=["${originUrl}"]`,
|
2020-12-10 15:14:09 +01:00
|
|
|
],
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|