Functional tests - Add esSupertest support for SSL (#90425)

This PR allows the functional test service esSupertest to work correctly in environments that have ES SSL enabled in the Kibana server configuration.
This commit is contained in:
Robert Oskamp 2021-02-09 12:45:19 +01:00 committed by GitHub
parent af75079a31
commit 523110d4bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -19,6 +19,14 @@ export function KibanaSupertestProvider({ getService }: FtrProviderContext) {
export function ElasticsearchSupertestProvider({ getService }: FtrProviderContext) {
const config = getService('config');
const elasticSearchServerUrl = formatUrl(config.get('servers.elasticsearch'));
return supertestAsPromised(elasticSearchServerUrl);
const esServerConfig = config.get('servers.elasticsearch');
const elasticSearchServerUrl = formatUrl(esServerConfig);
let agentOptions = {};
if ('certificateAuthorities' in esServerConfig) {
agentOptions = { ca: esServerConfig!.certificateAuthorities };
}
// @ts-ignore - supertestAsPromised doesn't like the agentOptions, but still passes it correctly to supertest
return supertestAsPromised.agent(elasticSearchServerUrl, agentOptions);
}

View file

@ -5,6 +5,7 @@
* 2.0.
*/
import Fs from 'fs';
import { resolve, join } from 'path';
import { CA_CERT_PATH } from '@kbn/dev-utils';
import { FtrConfigProviderContext } from '@kbn/test/types/ftr';
@ -33,6 +34,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
elasticsearch: {
...xpackFunctionalConfig.get('servers.elasticsearch'),
protocol: 'https',
certificateAuthorities: [Fs.readFileSync(CA_CERT_PATH)],
},
};