Skip to content

Commit

Permalink
Change log messages, now conditional on dist: false not dev: true
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner committed Nov 18, 2019
1 parent d218f9c commit c6daad1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/core/server/elasticsearch/elasticsearch_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ test('#ssl.certificateAuthorities accepts both string and array of strings', ()
expect(configValue.ssl.certificateAuthorities).toEqual(['some-path', 'another-path']);
});

test('#username throws if equal to "elastic", only while in dev mode', () => {
test('#username throws if equal to "elastic", only while running from source', () => {
const obj = {
username: 'elastic',
};
expect(() => config.schema.validate(obj, { dev: true })).toThrowErrorMatchingSnapshot();
expect(() => config.schema.validate(obj, { dev: false })).not.toThrow();
expect(() => config.schema.validate(obj, { dist: false })).toThrowErrorMatchingSnapshot();
expect(() => config.schema.validate(obj, { dist: true })).not.toThrow();
});
22 changes: 11 additions & 11 deletions src/core/server/elasticsearch/elasticsearch_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ export const config = {
defaultValue: 'http://localhost:9200',
}),
preserveHost: schema.boolean({ defaultValue: true }),
username: schema.conditional(
schema.contextRef('dev'),
true,
schema.maybe(
username: schema.maybe(
schema.conditional(
schema.contextRef('dist'),
false,
schema.string({
validate: rawConfig => {
if (rawConfig === 'elastic') {
return (
'value of "elastic" is forbidden in dev mode. This is a superuser account that can obfuscate privilege-related ' +
'issues. You should use the "kibana" user instead.'
'value of "elastic" is forbidden. This is a superuser account that can obfuscate ' +
'privilege-related issues. You should use the "kibana" user instead.'
);
}
},
})
),
schema.maybe(schema.string())
}),
schema.string()
)
),
password: schema.maybe(schema.string()),
requestHeadersWhitelist: schema.oneOf([schema.string(), schema.arrayOf(schema.string())], {
Expand Down Expand Up @@ -215,9 +215,9 @@ export class ElasticsearchConfig {

if (this.username === 'elastic' && log !== undefined) {
// logger is optional / not used during tests
// TODO: logger can be removed when ISSUE#40255 is resolved to support deprecations in NP config service
// TODO: logger can be removed when issue #40255 is resolved to support deprecations in NP config service
log.warn(
`Setting the elasticsearch username to "elastic" in production mode is deprecated. You should use the "kibana" user instead.`,
`Setting the elasticsearch username to "elastic" is deprecated. You should use the "kibana" user instead.`,
{ tags: ['deprecation'] }
);
}
Expand Down

0 comments on commit c6daad1

Please sign in to comment.