import Url from 'url' ; import Path from 'path' ; import type { FtrConfigProviderContext } from '@kbn/test' ; import { kbnTestConfig } from '@kbn/test' ; import { pageObjects } from '../functional/page_objects' ; const pluginPort = process . env . TEST_CORS_SERVER_PORT ? parseInt ( process . env . TEST_CORS_SERVER_PORT , 10 ) : 5699 ; export default async function ( { readConfigFile } ) { 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' , '--server.cors.allowCredentials=true' , `--server.cors.allowOrigin=["${ originUrl }"]` , ] , } , } ; }