Skip to content

Commit

Permalink
Merge pull request #5967 from epixa/5562-tests-with-shield
Browse files Browse the repository at this point in the history
Configurable shield credentials for tests
  • Loading branch information
epixa committed Jan 21, 2016
2 parents 4e71bee + d50c48b commit 7db9c91
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
6 changes: 4 additions & 2 deletions test/serverConfig.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var shield = require('./shield');

var kibanaURL = '/app/kibana';

module.exports = {
Expand All @@ -11,13 +13,13 @@ module.exports = {
protocol: process.env.TEST_UI_KIBANA_PROTOCOL || 'http',
hostname: process.env.TEST_UI_KIBANA_HOSTNAME || 'localhost',
port: parseInt(process.env.TEST_UI_KIBANA_PORT, 10) || 5620,
auth: 'user:notsecure'
auth: shield.kibanaUser.username + ':' + shield.kibanaUser.password
},
elasticsearch: {
protocol: process.env.TEST_UI_ES_PROTOCOL || 'http',
hostname: process.env.TEST_UI_ES_HOSTNAME || 'localhost',
port: parseInt(process.env.TEST_UI_ES_PORT, 10) || 9220,
auth: 'admin:notsecure'
auth: shield.admin.username + ':' + shield.admin.password
}
},
apps: {
Expand Down
16 changes: 16 additions & 0 deletions test/shield.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const env = process.env;

exports.kibanaUser = {
username: env.SHIELD_KIBANA_USER || 'user',
password: env.SHIELD_KIBANA_USER_PASS || 'notsecure'
};

exports.kibanaServer = {
username: env.SHIELD_KIBANA_SERVER || 'kibana',
password: env.SHIELD_KIBANA_SERVER_PASS || 'notsecure'
};

exports.admin = {
username: env.SHIELD_ADMIN || 'admin',
password: env.SHIELD_ADMIN_PASS || 'notsecure'
};
8 changes: 5 additions & 3 deletions test/utils/kbn_server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defaultsDeep, set } from 'lodash';
import requirefrom from 'requirefrom';
import { header as basicAuthHeader } from './base_auth';
import { kibanaUser, kibanaServer } from '../shield';

const src = requirefrom('src');
const KbnServer = src('server/KbnServer');
Expand All @@ -26,8 +27,8 @@ const SERVER_DEFAULTS = {
},
elasticsearch: {
url: 'http://localhost:9210',
username: 'kibana',
password: 'notsecure'
username: kibanaServer.username,
password: kibanaServer.password
}
};

Expand All @@ -46,7 +47,8 @@ export function createServer(params = {}) {
* Creates request configuration with a basic auth header
*/
export function authOptions() {
const authHeader = basicAuthHeader('user', 'notsecure');
const { username, password } = kibanaUser;
const authHeader = basicAuthHeader(username, password);
return set({}, 'headers.Authorization', authHeader);
};

Expand Down

0 comments on commit 7db9c91

Please sign in to comment.