Skip to content

Commit

Permalink
[kbn/test/es] remove unnecessary es user management logic
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Jun 17, 2021
1 parent b5f0bc9 commit 217d4c9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 235 deletions.
188 changes: 0 additions & 188 deletions packages/kbn-test/src/functional_tests/lib/auth.ts

This file was deleted.

23 changes: 1 addition & 22 deletions packages/kbn-test/src/functional_tests/lib/run_elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { KIBANA_ROOT } from './paths';
import type { Config } from '../../functional_test_runner/';
import { createTestEsCluster } from '../../es';

import { setupUsers, DEFAULT_SUPERUSER_PASS } from './auth';

interface RunElasticsearchOptions {
log: ToolingLog;
esFrom: string;
Expand All @@ -34,9 +32,7 @@ export async function runElasticsearch({

const cluster = createTestEsCluster({
port: config.get('servers.elasticsearch.port'),
password: isSecurityEnabled
? DEFAULT_SUPERUSER_PASS
: config.get('servers.elasticsearch.password'),
password: isSecurityEnabled ? 'changeme' : config.get('servers.elasticsearch.password'),
license,
log,
basePath: resolve(KIBANA_ROOT, '.es'),
Expand All @@ -49,22 +45,5 @@ export async function runElasticsearch({

await cluster.start();

if (isSecurityEnabled) {
await setupUsers({
log,
esPort: config.get('servers.elasticsearch.port'),
updates: [config.get('servers.elasticsearch'), config.get('servers.kibana')],
protocol: config.get('servers.elasticsearch').protocol,
caPath: getRelativeCertificateAuthorityPath(config.get('kbnTestServer.serverArgs')),
});
}

return cluster;
}

function getRelativeCertificateAuthorityPath(esConfig: string[] = []) {
const caConfig = esConfig.find(
(config) => config.indexOf('--elasticsearch.ssl.certificateAuthorities') === 0
);
return caConfig ? caConfig.split('=')[1] : undefined;
}
2 changes: 0 additions & 2 deletions packages/kbn-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export { esTestConfig, createTestEsCluster } from './es';

export { kbnTestConfig, kibanaServerTestUser, kibanaTestUser, adminTestUser } from './kbn';

export { setupUsers, DEFAULT_SUPERUSER_PASS } from './functional_tests/lib/auth';

export { readConfigFile } from './functional_test_runner/lib/config/read_config_file';

export { runFtrCli } from './functional_test_runner/cli';
Expand Down
26 changes: 3 additions & 23 deletions src/core/test_helpers/kbn_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@
*/

import { ToolingLog, REPO_ROOT } from '@kbn/dev-utils';
import {
createTestEsCluster,
DEFAULT_SUPERUSER_PASS,
esTestConfig,
kbnTestConfig,
kibanaServerTestUser,
kibanaTestUser,
setupUsers,
} from '@kbn/test';
import { createTestEsCluster, esTestConfig, kibanaServerTestUser, kibanaTestUser } from '@kbn/test';
import { defaultsDeep } from 'lodash';
import { resolve } from 'path';
import { BehaviorSubject } from 'rxjs';
Expand Down Expand Up @@ -208,7 +200,7 @@ export function createTestServers({
defaultsDeep({}, settings.es ?? {}, {
log,
license,
password: license === 'trial' ? DEFAULT_SUPERUSER_PASS : undefined,
password: license === 'trial' ? 'changeme' : undefined,
})
);

Expand All @@ -224,19 +216,7 @@ export function createTestServers({
await es.start();

if (['gold', 'trial'].includes(license)) {
await setupUsers({
log,
esPort: esTestConfig.getUrlParts().port,
updates: [
...usersToBeAdded,
// user elastic
esTestConfig.getUrlParts() as { username: string; password: string },
// user kibana
kbnTestConfig.getUrlParts() as { username: string; password: string },
],
});

// Override provided configs, we know what the elastic user is now
// Override provided configs
kbnSettings.elasticsearch = {
hosts: [esTestConfig.getUrl()],
username: kibanaServerTestUser.username,
Expand Down

0 comments on commit 217d4c9

Please sign in to comment.