Skip to content

Commit

Permalink
Switching approach to dynamically enabling security
Browse files Browse the repository at this point in the history
  • Loading branch information
kobelb committed Sep 5, 2018
1 parent 1607f80 commit 189fbe6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
14 changes: 6 additions & 8 deletions packages/kbn-test/src/functional_tests/lib/run_elasticsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,25 @@ import { setupUsers, DEFAULT_SUPERUSER_PASS } from './auth';

export async function runElasticsearch({ config, options }) {
const { log, esFrom } = options;
const securityEnabled = config.get('esTestCluster.securityEnabled');
const license = config.get('esTestCluster.license');
const isTrialLicense = config.get('esTestCluster.license') === 'trial';

const cluster = createEsTestCluster({
port: config.get('servers.elasticsearch.port'),
password: securityEnabled
password: isTrialLicense
? DEFAULT_SUPERUSER_PASS
: config.get('servers.elasticsearch.password'),
license: config.get('esTestCluster.license'),
license,
log,
basePath: resolve(KIBANA_ROOT, '.es'),
esFrom: esFrom || config.get('esTestCluster.from'),
});

const esArgs = [
...config.get('esTestCluster.serverArgs'),
...(securityEnabled ? ['xpack.security.enabled=true'] : []),
];
const esArgs = config.get('esTestCluster.serverArgs');

await cluster.start(esArgs);

if (securityEnabled) {
if (isTrialLicense) {
await setupUsers(log, config);
}

Expand Down
1 change: 0 additions & 1 deletion src/functional_test_runner/lib/config/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export const schema = Joi.object().keys({
license: Joi.string().default('oss'),
from: Joi.string().default('snapshot'),
serverArgs: Joi.array(),
securityEnabled: Joi.boolean().default(false),
}).default(),

kbnTestServer: Joi.object().keys({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ export default async function ({ readConfigFile }) {
esTestCluster: {
license: 'trial',
from: 'snapshot',
securityEnabled: true,
serverArgs: [
'xpack.license.self_generated.type=trial',
'xpack.security.enabled=true',
],
},

Expand Down
15 changes: 5 additions & 10 deletions x-pack/test/saved_object_api_integration/common/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { resolveKibanaPath } from '@kbn/plugin-helpers';
import { EsProvider } from './services/es';


export function createTestConfig(name, { license = 'trial', disabledPlugins = [], securityEnabled = true } = {}) {
export function createTestConfig(name, { license = 'trial', disabledPlugins = [] } = {}) {

return async function ({ readConfigFile }) {

Expand All @@ -28,11 +28,6 @@ export function createTestConfig(name, { license = 'trial', disabledPlugins = []
servers: config.xpack.api.get('servers'),
services: {
es: EsProvider,
// Provide license and list of disabled plugins to tests so they can alter their configuration
testEnv: () => ({
license,
disabledPlugins,
}),
esSupertestWithoutAuth: config.xpack.api.get('services.esSupertestWithoutAuth'),
supertest: config.kibana.api.get('services.supertest'),
supertestWithoutAuth: config.xpack.api.get('services.supertestWithoutAuth'),
Expand All @@ -48,11 +43,11 @@ export function createTestConfig(name, { license = 'trial', disabledPlugins = []
},

esTestCluster: {
...config.xpack.api.get('esTestCluster'),
license,
from: 'snapshot',
securityEnabled,
serverArgs: [
...license === 'trial' ? ['xpack.license.self_generated.type=trial'] : [],
`xpack.license.self_generated.type=${license}`,
`xpack.security.enabled=${!disabledPlugins.includes('security') && license === 'trial'}`,
],
},

Expand All @@ -62,8 +57,8 @@ export function createTestConfig(name, { license = 'trial', disabledPlugins = []
...config.xpack.api.get('kbnTestServer.serverArgs'),
'--optimize.enabled=false',
'--server.xsrf.disableProtection=true',
`--plugin-path=${path.join(__dirname, 'fixtures', 'namespace_agnostic_type_plugin')}`,
...disabledPlugins.map(key => `--xpack.${key}.enabled=false`),
`--plugin-path=${path.join(__dirname, 'fixtures', 'namespace_agnostic_type_plugin')}`
],
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

import { createTestConfig } from '../common/config';

export default createTestConfig('security_and_spaces', { license: 'trial', securityEnabled: true });
export default createTestConfig('security_and_spaces', { license: 'trial' });

0 comments on commit 189fbe6

Please sign in to comment.