Skip to content

Commit

Permalink
test deprecation logging when kibana user is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
legrego committed May 2, 2020
1 parent d424da4 commit 26470fb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.

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

13 changes: 11 additions & 2 deletions src/core/server/elasticsearch/elasticsearch_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,21 @@ describe('deprecations', () => {
const { messages } = applyElasticsearchDeprecations({ username: 'elastic' });
expect(messages).toMatchInlineSnapshot(`
Array [
"Setting [${CONFIG_PATH}.username] to \\"elastic\\" is deprecated. You should use the \\"kibana\\" user instead.",
"Setting [${CONFIG_PATH}.username] to \\"elastic\\" is deprecated. You should use the \\"kibana_system\\" user instead.",
]
`);
});

it('does not log a warning if elasticsearch.username is set to something besides "elastic"', () => {
it('logs a warning if elasticsearch.username is set to "kibana"', () => {
const { messages } = applyElasticsearchDeprecations({ username: 'kibana' });
expect(messages).toMatchInlineSnapshot(`
Array [
"Setting [${CONFIG_PATH}.username] to \\"kibana\\" is deprecated. You should use the \\"kibana_system\\" user instead.",
]
`);
});

it('does not log a warning if elasticsearch.username is set to something besides "elastic" or "kibana"', () => {
const { messages } = applyElasticsearchDeprecations({ username: 'otheruser' });
expect(messages).toHaveLength(0);
});
Expand Down
10 changes: 9 additions & 1 deletion x-pack/plugins/monitoring/server/__tests__/deprecations.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ describe('monitoring plugin deprecations', function() {
expect(log.called).to.be(true);
});

it('does not log a warning if elasticsearch.username is set to something besides "elastic"', () => {
it('logs a warning if elasticsearch.username is set to "kibana"', () => {
const settings = { elasticsearch: { username: 'kibana' } };

const log = sinon.spy();
transformDeprecations(settings, fromPath, log);
expect(log.called).to.be(true);
});

it('does not log a warning if elasticsearch.username is set to something besides "elastic" or "kibana"', () => {
const settings = { elasticsearch: { username: 'otheruser' } };

const log = sinon.spy();
Expand Down

0 comments on commit 26470fb

Please sign in to comment.