import path from 'path' ; import { CA_CERT_PATH } from '@kbn/dev-utils' ; import { FtrConfigProviderContext } from '@kbn/test' ; import { services } from './services' ; interface CreateTestConfigOptions { license : string ; disabledPlugins ? : string [ ] ; ssl ? : boolean ; } export function createTestConfig ( name , options ) { const { license = 'trial' , disabledPlugins = [ ] , ssl = false } = options ; return async ( { readConfigFile } ) => { const xPackApiIntegrationTestsConfig = await readConfigFile ( require . resolve ( '../../api_integration/config.ts' ) ) ; const servers = { ... xPackApiIntegrationTestsConfig . get ( 'servers' ) , elasticsearch : { ... xPackApiIntegrationTestsConfig . get ( 'servers.elasticsearch' ) , protocol : ssl ? 'https' : 'http' , } , } ; return { testFiles : [ require . resolve ( `../${ name }/tests/` ) ] , servers , services , junit : { reportName : 'X-Pack Lists Integration Tests' , } , esTestCluster : { ... xPackApiIntegrationTestsConfig . get ( 'esTestCluster' ) , license , ssl , serverArgs : [ `xpack.license.self_generated.type=${ license }` , `xpack.security.enabled=${ ! disabledPlugins . includes ( 'security' ) }` , ] , } , kbnTestServer : { ... xPackApiIntegrationTestsConfig . get ( 'kbnTestServer' ) , serverArgs : [ ... xPackApiIntegrationTestsConfig . get ( 'kbnTestServer.serverArgs' ) , ... disabledPlugins . filter ( ( k ) => k !== 'security' ) . map ( ( key ) => `--xpack.${ key }.enabled=false` ) , `--plugin-path=${ path . join ( __dirname , 'fixtures' , 'plugins' , 'alerts' ) }` , `--plugin-path=${ path . join ( __dirname , 'fixtures' , 'plugins' , 'actions' ) }` , `--plugin-path=${ path . join ( __dirname , 'fixtures' , 'plugins' , 'task_manager' ) }` , `--plugin-path=${ path . join ( __dirname , 'fixtures' , 'plugins' , 'aad' ) }` , ... ( ssl ? [ `--elasticsearch.hosts=${ servers . elasticsearch . protocol }://${ servers . elasticsearch . hostname }:${ servers . elasticsearch . port }` , `--elasticsearch.ssl.certificateAuthorities=${ CA_CERT_PATH }` , ] : [ ] ) , ] , } , } ; } ; }