mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Basic support for running server tests with shield
These changes will make sure the kibana server in tests is using shield credentials, as are any requests made through the kbn_server test helper. The current credentials are hardcoded based on our internal best practices, but they should be made configurable in the future. This will pass credentials to ES regardless of whether shield is actually enabled, but that will have no negative effect if shield happens to be disabled.
This commit is contained in:
parent
41de597e42
commit
eccb3d6f97
2 changed files with 15 additions and 2 deletions
4
test/utils/base_auth.js
Normal file
4
test/utils/base_auth.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
export function header(user, pass) {
|
||||
const encoded = new Buffer(`${user}:${pass}`).toString('base64');
|
||||
return `Basic ${encoded}`;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import { defaultsDeep } from 'lodash';
|
||||
import { defaultsDeep, set } from 'lodash';
|
||||
import requirefrom from 'requirefrom';
|
||||
import { header as basicAuthHeader } from './base_auth';
|
||||
|
||||
const src = requirefrom('src');
|
||||
const KbnServer = src('server/KbnServer');
|
||||
|
@ -24,7 +25,9 @@ const SERVER_DEFAULTS = {
|
|||
enabled: false
|
||||
},
|
||||
elasticsearch: {
|
||||
url: 'http://localhost:9210'
|
||||
url: 'http://localhost:9210',
|
||||
username: 'kibana',
|
||||
password: 'notsecure'
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -33,6 +36,12 @@ export function createServer(params = {}) {
|
|||
return new KbnServer(params);
|
||||
};
|
||||
|
||||
export function authOptions() {
|
||||
const authHeader = basicAuthHeader('user', 'notsecure');
|
||||
return set({}, 'headers.Authorization', authHeader);
|
||||
};
|
||||
|
||||
export function makeRequest(kbnServer, options, fn) {
|
||||
options = defaultsDeep({}, authOptions(), options);
|
||||
return kbnServer.server.inject(options, fn);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue