import { CA_CERT_PATH } from '@kbn/dev-utils' ; import { FtrConfigProviderContext } from '@kbn/test' ; import { services } from './services' ; interface CreateTestConfigOptions { license : string ; ssl ? : boolean ; } const enabledActionTypes = [ '.email' , '.index' , '.pagerduty' , '.swimlane' , '.server-log' , '.servicenow' , '.slack' , '.webhook' , 'test.authorization' , 'test.failing' , 'test.index-record' , 'test.noop' , 'test.rate-limit' , ] ; export function createTestConfig ( name , options ) { const { license = 'trial' , 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 Detection Engine API Integration Tests' , } , esTestCluster : { ... xPackApiIntegrationTestsConfig . get ( 'esTestCluster' ) , license , ssl , serverArgs : [ `xpack.license.self_generated.type=${ license }` ] , } , kbnTestServer : { ... xPackApiIntegrationTestsConfig . get ( 'kbnTestServer' ) , serverArgs : [ ... xPackApiIntegrationTestsConfig . get ( 'kbnTestServer.serverArgs' ) , `--xpack.actions.allowedHosts=${ JSON . stringify ( [ 'localhost' , 'some.non.existent.com' ] ) }` , `--xpack.actions.enabledActionTypes=${ JSON . stringify ( enabledActionTypes ) }` , '--xpack.eventLog.logEntries=true' , `--xpack.securitySolution.alertIgnoreFields=${ JSON . stringify ( [ 'testing_ignored.constant' , '/testing_regex*/' , ] ) }` , '--xpack.ruleRegistry.write.enabled=true' , '--xpack.ruleRegistry.write.cache.enabled=false' , '--xpack.ruleRegistry.unsafe.indexUpgrade.enabled=true' , '--xpack.ruleRegistry.unsafe.legacyMultiTenancy.enabled=true' , `--xpack.securitySolution.enableExperimental=${ JSON . stringify ( [ 'ruleRegistryEnabled' ] ) }` , ... ( ssl ? [ `--elasticsearch.hosts=${ servers . elasticsearch . protocol }://${ servers . elasticsearch . hostname }:${ servers . elasticsearch . port }` , `--elasticsearch.ssl.certificateAuthorities=${ CA_CERT_PATH }` , ] : [ ] ) , ] , } , } ; } ; }