Skip to content

Commit

Permalink
Functional tests - Add esSupertest support for SSL (#90425) (#90755)
Browse files Browse the repository at this point in the history
This PR allows the functional test service esSupertest to work correctly in environments that have ES SSL enabled in the Kibana server configuration.
  • Loading branch information
pheyos authored Feb 9, 2021
1 parent 04025f5 commit 1dccab3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/api_integration/services/supertest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions x-pack/test/functional_with_es_ssl/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -33,6 +34,7 @@ export default async function ({ readConfigFile }: FtrConfigProviderContext) {
elasticsearch: {
...xpackFunctionalConfig.get('servers.elasticsearch'),
protocol: 'https',
certificateAuthorities: [Fs.readFileSync(CA_CERT_PATH)],
},
};

Expand Down

0 comments on commit 1dccab3

Please sign in to comment.