From c42e8b8b9afcd948e1a721ce7f2684b7ea5d6f9d Mon Sep 17 00:00:00 2001 From: LeeDr Date: Thu, 5 Jan 2017 19:10:53 -0600 Subject: [PATCH 1/9] Support 1 Kibana and 1 Elasticsearch URL as input params --- test/server_config.js | 45 +++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/test/server_config.js b/test/server_config.js index 869f281e376f6..09346a93340c5 100644 --- a/test/server_config.js +++ b/test/server_config.js @@ -1,6 +1,13 @@ -const shield = require('./shield'); +import url from 'url'; +import shield from './shield'; -const kibanaURL = '/app/kibana'; +const KIBANA_BASE_PATH = '/app/kibana'; +const TEST_KIBANA_URL = url.parse(process.env.TEST_KIBANA ? process.env.TEST_KIBANA : 'http://localhost:5620'); +const TEST_ES_URL = url.parse(process.env.TEST_ES ? process.env.TEST_ES : 'http://localhost:9220'); +const TEST_KIBANA_USERNAME = TEST_KIBANA_URL.username || shield.kibanaUser.username; +const TEST_KIBANA_PASSWORD = TEST_KIBANA_URL.password || shield.kibanaUser.password; +const TEST_ES_USERNAME = TEST_ES_URL.username || shield.admin.username; +const TEST_ES_PASSWORD = TEST_ES_URL.password || shield.admin.password; module.exports = { servers: { @@ -10,20 +17,20 @@ module.exports = { port: parseInt(process.env.TEST_WEBDRIVER_PORT, 10) || 4444 }, kibana: { - protocol: process.env.TEST_KIBANA_PROTOCOL || 'http', - hostname: process.env.TEST_KIBANA_HOSTNAME || 'localhost', - port: parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620, - auth: shield.kibanaUser.username + ':' + shield.kibanaUser.password, - username: shield.kibanaUser.username, - password: shield.kibanaUser.password + protocol: process.env.TEST_KIBANA_PROTOCOL || TEST_KIBANA_URL.protocol, + hostname: process.env.TEST_KIBANA_HOSTNAME || TEST_KIBANA_URL.hostname, + port: parseInt(process.env.TEST_KIBANA_PORT, 10) || parseInt(TEST_KIBANA_URL.port, 10), + username: TEST_KIBANA_USERNAME, + password: TEST_KIBANA_PASSWORD, + auth: `${TEST_KIBANA_USERNAME}:${TEST_KIBANA_PASSWORD}` }, elasticsearch: { - protocol: process.env.TEST_ES_PROTOCOL || 'http', - hostname: process.env.TEST_ES_HOSTNAME || 'localhost', - port: parseInt(process.env.TEST_ES_PORT, 10) || 9220, - auth: shield.admin.username + ':' + shield.admin.password, - username: shield.admin.username, - password: shield.admin.password + protocol: process.env.TEST_ES_PROTOCOL || TEST_ES_URL.protocol, + hostname: process.env.TEST_ES_HOSTNAME || TEST_ES_URL.hostname, + port: parseInt(process.env.TEST_ES_PORT, 10) || parseInt(TEST_ES_URL.port, 10), + username: TEST_ES_USERNAME, + password: TEST_ES_PASSWORD, + auth: `${TEST_ES_USERNAME}:${TEST_ES_PASSWORD}` } }, apps: { @@ -31,23 +38,23 @@ module.exports = { pathname: 'status' }, discover: { - pathname: kibanaURL, + pathname: KIBANA_BASE_PATH, hash: '/discover', }, visualize: { - pathname: kibanaURL, + pathname: KIBANA_BASE_PATH, hash: '/visualize', }, dashboard: { - pathname: kibanaURL, + pathname: KIBANA_BASE_PATH, hash: '/dashboard', }, settings: { - pathname: kibanaURL, + pathname: KIBANA_BASE_PATH, hash: '/management' }, console: { - pathname: kibanaURL, + pathname: KIBANA_BASE_PATH, hash: '/dev_tools/console', } } From 96f33d08aeb13b371f3117aa1b8d7d6c65b2f4d2 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Mon, 2 Apr 2018 11:07:02 -0500 Subject: [PATCH 2/9] Revert a previous change to test char substitution --- src/test_utils/es/es_test_config.js | 42 ++++++++++++++++++++---- test/functional/apps/console/_console.js | 2 +- test/kibana_test_server_url_parts.js | 39 ++++++++++++++++++---- 3 files changed, 69 insertions(+), 14 deletions(-) diff --git a/src/test_utils/es/es_test_config.js b/src/test_utils/es/es_test_config.js index ca8f043057ee8..c85b0bb1eda94 100644 --- a/src/test_utils/es/es_test_config.js +++ b/src/test_utils/es/es_test_config.js @@ -1,4 +1,4 @@ -import { format as formatUrl } from 'url'; +import { format as formatUrl, url } from 'url'; import pkg from '../../../package.json'; import { admin } from '../../../test/shield'; @@ -20,13 +20,41 @@ export const esTestConfig = new class EsTestConfig { } getUrlParts() { + + let testEsUrl; + let testEsProtocol; + let testEsHostname; + let testEsPort; + let testEsUsername; + let testEsPassword; + + // Allow setting one complete TEST_ES_URL for Es like https://elastic:changeme@myCloudInstance:9200 + if (process.env.TEST_ES_URL) { + testEsUrl = url.parse(process.env.TEST_ES_URL); + testEsProtocol = testEsUrl.protocol; + testEsHostname = testEsUrl.hostname; + testEsPort = parseInt(testEsUrl.port, 10); + testEsUsername = testEsUrl.username; + testEsPassword = testEsUrl.password; + } else { + // Allow setting any individual component(s) of the URL, + // or use default values (username and password from shield.js) + testEsProtocol = process.env.TEST_ES_PROTOCOL || 'http'; + testEsHostname = process.env.TEST_ES_HOSTNAME || 'localhost'; + testEsPort = parseInt(process.env.TEST_ES_PORT, 10) || 9220; + testEsUsername = process.env.TEST_ES_USERNAME || admin.username; + testEsPassword = process.env.TEST_ES_PASSWORD || admin.password; + } + + + return { - protocol: process.env.TEST_ES_PROTOCOL || 'http', - hostname: process.env.TEST_ES_HOSTNAME || 'localhost', - port: parseInt(process.env.TEST_ES_PORT, 10) || 9220, - auth: admin.username + ':' + admin.password, - username: admin.username, - password: admin.password, + protocol: testEsProtocol, + hostname: testEsHostname, + port: testEsPort, + auth: testEsUsername + ':' + testEsPassword, + username: testEsUsername, + password: testEsPassword, }; } }; diff --git a/test/functional/apps/console/_console.js b/test/functional/apps/console/_console.js index dfd739567300b..ee46905a08199 100644 --- a/test/functional/apps/console/_console.js +++ b/test/functional/apps/console/_console.js @@ -22,7 +22,7 @@ export default function ({ getService, getPageObjects }) { return PageObjects.common.navigateToApp('console'); }); - it('should show the default *%^$# @ ! ~ request', function () { + it('should show the default request', function () { // collapse the help pane because we only get the VISIBLE TEXT, not the part that is scrolled return PageObjects.console.collapseHelp() .then(function () { diff --git a/test/kibana_test_server_url_parts.js b/test/kibana_test_server_url_parts.js index ca25f2fa9a7d6..5e4987535aca7 100644 --- a/test/kibana_test_server_url_parts.js +++ b/test/kibana_test_server_url_parts.js @@ -1,10 +1,37 @@ import { kibanaUser } from './shield'; +import url from 'url'; + +let testKibanaUrl; +let testKibanaProtocol; +let testKibanaHostname; +let testKibanaPort; +let testKibanaUsername; +let testKibanaPassword; + +// Allow setting one complete TEST_KIBANA_URL for Kibana like https://elastic:changeme@myCloudInstance:5601 +if (process.env.TEST_KIBANA_URL) { + testKibanaUrl = url.parse(process.env.TEST_KIBANA_URL); + testKibanaProtocol = testKibanaUrl.protocol; + testKibanaHostname = testKibanaUrl.hostname; + testKibanaPort = parseInt(testKibanaUrl.port, 10); + testKibanaUsername = testKibanaUrl.username; + testKibanaPassword = testKibanaUrl.password; +} else { + // Allow setting any individual component(s) of the URL, + // or use default values (username and password from shield.js) + testKibanaProtocol = process.env.TEST_KIBANA_PROTOCOL || 'http'; + testKibanaHostname = process.env.TEST_KIBANA_HOSTNAME || 'localhost'; + testKibanaPort = parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620; + testKibanaUsername = process.env.TEST_KIBANA_USERNAME || kibanaUser.username; + testKibanaPassword = process.env.TEST_KIBANA_PASSWORD || kibanaUser.password; +} export const kibanaTestServerUrlParts = { - protocol: process.env.TEST_KIBANA_PROTOCOL || 'http', - hostname: process.env.TEST_KIBANA_HOSTNAME || 'localhost', - port: parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620, - auth: kibanaUser.username + ':' + kibanaUser.password, - username: kibanaUser.username, - password: kibanaUser.password, + + protocol: testKibanaProtocol, + hostname: testKibanaHostname, + port: testKibanaPort, + username: testKibanaUsername, + password: testKibanaPassword, + auth: `${testKibanaUsername}:${testKibanaPassword}` }; From 693f64bae6b745cbffdece91dcb993d1dbd05223 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Mon, 2 Apr 2018 11:46:53 -0500 Subject: [PATCH 3/9] Allow setting TEST_KIBANA_URL and TEST_ES_URL for Cloud testing --- src/test_utils/es/es_test_config.js | 8 +++++--- test/kibana_test_server_url_parts.js | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/test_utils/es/es_test_config.js b/src/test_utils/es/es_test_config.js index c85b0bb1eda94..1ec672500d680 100644 --- a/src/test_utils/es/es_test_config.js +++ b/src/test_utils/es/es_test_config.js @@ -1,4 +1,5 @@ -import { format as formatUrl, url } from 'url'; +import url, { format as formatUrl } from 'url'; +// import url from 'url'; import pkg from '../../../package.json'; import { admin } from '../../../test/shield'; @@ -31,7 +32,8 @@ export const esTestConfig = new class EsTestConfig { // Allow setting one complete TEST_ES_URL for Es like https://elastic:changeme@myCloudInstance:9200 if (process.env.TEST_ES_URL) { testEsUrl = url.parse(process.env.TEST_ES_URL); - testEsProtocol = testEsUrl.protocol; + // have to remove the ":" off protocol + testEsProtocol = testEsUrl.protocol.slice(0, -1); testEsHostname = testEsUrl.hostname; testEsPort = parseInt(testEsUrl.port, 10); testEsUsername = testEsUrl.username; @@ -45,7 +47,7 @@ export const esTestConfig = new class EsTestConfig { testEsUsername = process.env.TEST_ES_USERNAME || admin.username; testEsPassword = process.env.TEST_ES_PASSWORD || admin.password; } - + console.log(testEsProtocol); return { diff --git a/test/kibana_test_server_url_parts.js b/test/kibana_test_server_url_parts.js index 5e4987535aca7..08bbdee91ebac 100644 --- a/test/kibana_test_server_url_parts.js +++ b/test/kibana_test_server_url_parts.js @@ -11,7 +11,8 @@ let testKibanaPassword; // Allow setting one complete TEST_KIBANA_URL for Kibana like https://elastic:changeme@myCloudInstance:5601 if (process.env.TEST_KIBANA_URL) { testKibanaUrl = url.parse(process.env.TEST_KIBANA_URL); - testKibanaProtocol = testKibanaUrl.protocol; + // have to remove the ":" off protocol + testKibanaProtocol = testKibanaUrl.protocol.slice(0, -1); testKibanaHostname = testKibanaUrl.hostname; testKibanaPort = parseInt(testKibanaUrl.port, 10); testKibanaUsername = testKibanaUrl.username; From 9629bccea89b9489e252cf4475c5325eeec7584b Mon Sep 17 00:00:00 2001 From: LeeDr Date: Mon, 2 Apr 2018 12:07:28 -0500 Subject: [PATCH 4/9] cleanup comment --- src/test_utils/es/es_test_config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test_utils/es/es_test_config.js b/src/test_utils/es/es_test_config.js index 1ec672500d680..6639312b649c2 100644 --- a/src/test_utils/es/es_test_config.js +++ b/src/test_utils/es/es_test_config.js @@ -1,5 +1,4 @@ import url, { format as formatUrl } from 'url'; -// import url from 'url'; import pkg from '../../../package.json'; import { admin } from '../../../test/shield'; From 891774244f167da0ce0caad1d2a0b50e0ca546f2 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Wed, 4 Apr 2018 11:20:11 -0500 Subject: [PATCH 5/9] Update docs --- .../core/development-functional-tests.asciidoc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/development/core/development-functional-tests.asciidoc b/docs/development/core/development-functional-tests.asciidoc index 936593ae5873f..32f27df4e0401 100644 --- a/docs/development/core/development-functional-tests.asciidoc +++ b/docs/development/core/development-functional-tests.asciidoc @@ -36,6 +36,17 @@ There are three ways to run the tests depending on your goals: + ["source","shell"] ---------- +export TEST_KIBANA_URL=https://kibana:password@my-kibana-instance.internal.net:443 + +export TEST_ES_URL=https://elastic:password@my-es-cluster.internal.net:9200 +node scripts/functional_test_runner +---------- + + +** Or you can override any or all of these individual parts of the URL and leave the others to the default values. ++ +["source","shell"] +---------- export TEST_KIBANA_PROTOCOL=https export TEST_KIBANA_HOSTNAME=my-kibana-instance.internal.net export TEST_KIBANA_PORT=443 @@ -405,4 +416,4 @@ const log = getService(‘log’); // log.debug only writes when using the `--debug` or `--verbose` flag. log.debug(‘done clicking menu’); ------------ \ No newline at end of file +----------- From 7cdc0f737d99b879b6c19cc72ed6afab7ad75299 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Wed, 4 Apr 2018 13:28:57 -0500 Subject: [PATCH 6/9] Refactor after PR review --- src/test_utils/es/es_test_config.js | 44 +++++++++++++--------------- test/kibana_test_server_url_parts.js | 44 ++++++++++++++-------------- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/test_utils/es/es_test_config.js b/src/test_utils/es/es_test_config.js index 6639312b649c2..1895051b39b04 100644 --- a/src/test_utils/es/es_test_config.js +++ b/src/test_utils/es/es_test_config.js @@ -22,40 +22,38 @@ export const esTestConfig = new class EsTestConfig { getUrlParts() { let testEsUrl; - let testEsProtocol; - let testEsHostname; - let testEsPort; - let testEsUsername; - let testEsPassword; + let protocol; + let hostname; + let port; + let username; + let password; // Allow setting one complete TEST_ES_URL for Es like https://elastic:changeme@myCloudInstance:9200 if (process.env.TEST_ES_URL) { testEsUrl = url.parse(process.env.TEST_ES_URL); // have to remove the ":" off protocol - testEsProtocol = testEsUrl.protocol.slice(0, -1); - testEsHostname = testEsUrl.hostname; - testEsPort = parseInt(testEsUrl.port, 10); - testEsUsername = testEsUrl.username; - testEsPassword = testEsUrl.password; + protocol = testEsUrl.protocol.slice(0, -1); + hostname = testEsUrl.hostname; + port = parseInt(testEsUrl.port, 10); + username = testEsUrl.username; + password = testEsUrl.password; } else { // Allow setting any individual component(s) of the URL, // or use default values (username and password from shield.js) - testEsProtocol = process.env.TEST_ES_PROTOCOL || 'http'; - testEsHostname = process.env.TEST_ES_HOSTNAME || 'localhost'; - testEsPort = parseInt(process.env.TEST_ES_PORT, 10) || 9220; - testEsUsername = process.env.TEST_ES_USERNAME || admin.username; - testEsPassword = process.env.TEST_ES_PASSWORD || admin.password; + protocol = process.env.TEST_ES_PROTOCOL || 'http'; + hostname = process.env.TEST_ES_HOSTNAME || 'localhost'; + port = parseInt(process.env.TEST_ES_PORT, 10) || 9220; + username = process.env.TEST_ES_USERNAME || admin.username; + password = process.env.TEST_ES_PASSWORD || admin.password; } - console.log(testEsProtocol); - return { - protocol: testEsProtocol, - hostname: testEsHostname, - port: testEsPort, - auth: testEsUsername + ':' + testEsPassword, - username: testEsUsername, - password: testEsPassword, + protocol, + hostname, + port, + auth: username + ':' + password, + username, + password, }; } }; diff --git a/test/kibana_test_server_url_parts.js b/test/kibana_test_server_url_parts.js index 08bbdee91ebac..b3fe2753072e8 100644 --- a/test/kibana_test_server_url_parts.js +++ b/test/kibana_test_server_url_parts.js @@ -2,37 +2,37 @@ import { kibanaUser } from './shield'; import url from 'url'; let testKibanaUrl; -let testKibanaProtocol; -let testKibanaHostname; -let testKibanaPort; -let testKibanaUsername; -let testKibanaPassword; +let protocol; +let hostname; +let port; +let username; +let password; + // Allow setting one complete TEST_KIBANA_URL for Kibana like https://elastic:changeme@myCloudInstance:5601 if (process.env.TEST_KIBANA_URL) { testKibanaUrl = url.parse(process.env.TEST_KIBANA_URL); // have to remove the ":" off protocol - testKibanaProtocol = testKibanaUrl.protocol.slice(0, -1); - testKibanaHostname = testKibanaUrl.hostname; - testKibanaPort = parseInt(testKibanaUrl.port, 10); - testKibanaUsername = testKibanaUrl.username; - testKibanaPassword = testKibanaUrl.password; + protocol = testKibanaUrl.protocol.slice(0, -1); + hostname = testKibanaUrl.hostname; + port = parseInt(testKibanaUrl.port, 10); + username = testKibanaUrl.username; + password = testKibanaUrl.password; } else { // Allow setting any individual component(s) of the URL, // or use default values (username and password from shield.js) - testKibanaProtocol = process.env.TEST_KIBANA_PROTOCOL || 'http'; - testKibanaHostname = process.env.TEST_KIBANA_HOSTNAME || 'localhost'; - testKibanaPort = parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620; - testKibanaUsername = process.env.TEST_KIBANA_USERNAME || kibanaUser.username; - testKibanaPassword = process.env.TEST_KIBANA_PASSWORD || kibanaUser.password; + protocol = process.env.TEST_KIBANA_PROTOCOL || 'http'; + hostname = process.env.TEST_KIBANA_HOSTNAME || 'localhost'; + port = parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620; + username = process.env.TEST_KIBANA_USERNAME || kibanaUser.username; + password = process.env.TEST_KIBANA_PASSWORD || kibanaUser.password; } export const kibanaTestServerUrlParts = { - - protocol: testKibanaProtocol, - hostname: testKibanaHostname, - port: testKibanaPort, - username: testKibanaUsername, - password: testKibanaPassword, - auth: `${testKibanaUsername}:${testKibanaPassword}` + protocol, + hostname, + port, + auth: username + ':' + password, + username, + password, }; From 333d909d27bb1a88e0eba56cb7a16868b730bd79 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Wed, 11 Apr 2018 17:29:32 -0500 Subject: [PATCH 7/9] Changes from review --- src/test_utils/es/es_test_config.js | 4 +- test/kibana_test_server_url_parts.js | 56 ++++++++++++---------------- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/test_utils/es/es_test_config.js b/src/test_utils/es/es_test_config.js index 1895051b39b04..1c8372c6c91b1 100644 --- a/src/test_utils/es/es_test_config.js +++ b/src/test_utils/es/es_test_config.js @@ -35,8 +35,8 @@ export const esTestConfig = new class EsTestConfig { protocol = testEsUrl.protocol.slice(0, -1); hostname = testEsUrl.hostname; port = parseInt(testEsUrl.port, 10); - username = testEsUrl.username; - password = testEsUrl.password; + username = testEsUrl.auth.split(':')[0]; + password = testEsUrl.auth.split(':')[1]; } else { // Allow setting any individual component(s) of the URL, // or use default values (username and password from shield.js) diff --git a/test/kibana_test_server_url_parts.js b/test/kibana_test_server_url_parts.js index b3fe2753072e8..b70478d52eb33 100644 --- a/test/kibana_test_server_url_parts.js +++ b/test/kibana_test_server_url_parts.js @@ -1,38 +1,30 @@ import { kibanaUser } from './shield'; import url from 'url'; -let testKibanaUrl; -let protocol; -let hostname; -let port; -let username; -let password; +function getUrlParts() { + // allow setting one complete TEST_KIBANA_URL for ES like https://elastic:changeme@example.com:9200 + if (process.env.TEST_KIBANA_URL) { + const testKibanaUrl = url.parse(process.env.TEST_KIBANA_URL); + return { + protocol: testKibanaUrl.protocol.slice(0, -1), + hostname: testKibanaUrl.hostname, + port: parseInt(testKibanaUrl.port, 10), + auth: testKibanaUrl.auth, + username: testKibanaUrl.auth.split(':')[0], + password: testKibanaUrl.auth.split(':')[1] + }; + } - -// Allow setting one complete TEST_KIBANA_URL for Kibana like https://elastic:changeme@myCloudInstance:5601 -if (process.env.TEST_KIBANA_URL) { - testKibanaUrl = url.parse(process.env.TEST_KIBANA_URL); - // have to remove the ":" off protocol - protocol = testKibanaUrl.protocol.slice(0, -1); - hostname = testKibanaUrl.hostname; - port = parseInt(testKibanaUrl.port, 10); - username = testKibanaUrl.username; - password = testKibanaUrl.password; -} else { - // Allow setting any individual component(s) of the URL, - // or use default values (username and password from shield.js) - protocol = process.env.TEST_KIBANA_PROTOCOL || 'http'; - hostname = process.env.TEST_KIBANA_HOSTNAME || 'localhost'; - port = parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620; - username = process.env.TEST_KIBANA_USERNAME || kibanaUser.username; - password = process.env.TEST_KIBANA_PASSWORD || kibanaUser.password; + const username = process.env.TEST_KIBANA_USERNAME || kibanaUser.username; + const password = process.env.TEST_KIBANA_PASSWORD || kibanaUser.password; + return { + protocol: process.env.TEST_KIBANA_PROTOCOL || 'http', + hostname: process.env.TEST_KIBANA_HOSTNAME || 'localhost', + port: parseInt(process.env.TEST_KIBANA_PORT, 10) || 9220, + auth: `${username}:${password}`, + username, + password, + }; } -export const kibanaTestServerUrlParts = { - protocol, - hostname, - port, - auth: username + ':' + password, - username, - password, -}; +export const kibanaTestServerUrlParts = getUrlParts(); From 5da16358cb04d0e85f7c67f6cff3d9127a89f412 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Thu, 12 Apr 2018 14:33:14 -0500 Subject: [PATCH 8/9] fix default Kibana port to 5620 --- test/kibana_test_server_url_parts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/kibana_test_server_url_parts.js b/test/kibana_test_server_url_parts.js index b70478d52eb33..e8d8a48d1a778 100644 --- a/test/kibana_test_server_url_parts.js +++ b/test/kibana_test_server_url_parts.js @@ -20,7 +20,7 @@ function getUrlParts() { return { protocol: process.env.TEST_KIBANA_PROTOCOL || 'http', hostname: process.env.TEST_KIBANA_HOSTNAME || 'localhost', - port: parseInt(process.env.TEST_KIBANA_PORT, 10) || 9220, + port: parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620, auth: `${username}:${password}`, username, password, From a1fa8f8eb32aa42180bd29c2032fe0e4db6d352a Mon Sep 17 00:00:00 2001 From: LeeDr Date: Fri, 13 Apr 2018 09:21:36 -0500 Subject: [PATCH 9/9] Change es_test_config.js similar to kibana_test_server_url_parts.js --- src/test_utils/es/es_test_config.js | 50 ++++++++++++----------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/src/test_utils/es/es_test_config.js b/src/test_utils/es/es_test_config.js index 1c8372c6c91b1..46a3cd63be20f 100644 --- a/src/test_utils/es/es_test_config.js +++ b/src/test_utils/es/es_test_config.js @@ -20,40 +20,32 @@ export const esTestConfig = new class EsTestConfig { } getUrlParts() { - - let testEsUrl; - let protocol; - let hostname; - let port; - let username; - let password; - // Allow setting one complete TEST_ES_URL for Es like https://elastic:changeme@myCloudInstance:9200 if (process.env.TEST_ES_URL) { - testEsUrl = url.parse(process.env.TEST_ES_URL); - // have to remove the ":" off protocol - protocol = testEsUrl.protocol.slice(0, -1); - hostname = testEsUrl.hostname; - port = parseInt(testEsUrl.port, 10); - username = testEsUrl.auth.split(':')[0]; - password = testEsUrl.auth.split(':')[1]; - } else { - // Allow setting any individual component(s) of the URL, - // or use default values (username and password from shield.js) - protocol = process.env.TEST_ES_PROTOCOL || 'http'; - hostname = process.env.TEST_ES_HOSTNAME || 'localhost'; - port = parseInt(process.env.TEST_ES_PORT, 10) || 9220; - username = process.env.TEST_ES_USERNAME || admin.username; - password = process.env.TEST_ES_PASSWORD || admin.password; + const testEsUrl = url.parse(process.env.TEST_ES_URL); + return { + // have to remove the ":" off protocol + protocol: testEsUrl.protocol.slice(0, -1), + hostname: testEsUrl.hostname, + port: parseInt(testEsUrl.port, 10), + username: testEsUrl.auth.split(':')[0], + password: testEsUrl.auth.split(':')[1], + auth: testEsUrl.auth + }; } + const username = process.env.TEST_KIBANA_USERNAME || admin.username; + const password = process.env.TEST_KIBANA_PASSWORD || admin.password; return { - protocol, - hostname, - port, - auth: username + ':' + password, - username, - password, + // Allow setting any individual component(s) of the URL, + // or use default values (username and password from shield.js) + protocol: process.env.TEST_ES_PROTOCOL || 'http', + hostname: process.env.TEST_ES_HOSTNAME || 'localhost', + port: parseInt(process.env.TEST_ES_PORT, 10) || 9220, + auth: `${username}:${password}`, + username: username, + password: password, }; + } };