Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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