Skip to content

Commit

Permalink
Change level for elasticsearch.username deprecation (#122717)
Browse files Browse the repository at this point in the history
  • Loading branch information
jportner authored Jan 12, 2022
1 parent 1f04996 commit 9ffffbc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/core/server/elasticsearch/elasticsearch_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,22 +289,24 @@ describe('throws when config is invalid', () => {
});

describe('deprecations', () => {
it('logs a warning if elasticsearch.username is set to "elastic"', () => {
const { messages } = applyElasticsearchDeprecations({ username: 'elastic' });
it('logs a critical deprecation if elasticsearch.username is set to "elastic"', () => {
const { messages, levels } = applyElasticsearchDeprecations({ username: 'elastic' });
expect(messages).toMatchInlineSnapshot(`
Array [
"Kibana is configured to authenticate to Elasticsearch with the \\"elastic\\" user. Use a service account token instead.",
]
`);
expect(levels).toEqual(['critical']);
});

it('logs a warning if elasticsearch.username is set to "kibana"', () => {
const { messages } = applyElasticsearchDeprecations({ username: 'kibana' });
const { messages, levels } = applyElasticsearchDeprecations({ username: 'kibana' });
expect(messages).toMatchInlineSnapshot(`
Array [
"Kibana is configured to authenticate to Elasticsearch with the \\"kibana\\" user. Use a service account token instead.",
]
`);
expect(levels).toEqual(['warning']);
});

it('does not log a warning if elasticsearch.username is set to something besides "elastic" or "kibana"', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/core/server/elasticsearch/elasticsearch_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ const deprecations: ConfigDeprecationProvider = () => [

if (es.username === 'elastic' || es.username === 'kibana') {
const username = es.username;
const level = es.username === 'elastic' ? 'critical' : 'warning';
addDeprecation({
configPath: `${fromPath}.username`,
title: i18n.translate('core.deprecations.elasticsearchUsername.title', {
Expand All @@ -158,7 +159,7 @@ const deprecations: ConfigDeprecationProvider = () => [
'Kibana is configured to authenticate to Elasticsearch with the "{username}" user. Use a service account token instead.',
values: { username },
}),
level: 'warning',
level,
documentationUrl: `https://www.elastic.co/guide/en/elasticsearch/reference/${branch}/service-accounts.html`,
correctiveActions: {
manualSteps: [
Expand Down

0 comments on commit 9ffffbc

Please sign in to comment.