Skip to content

Commit 3120c8f

Browse files
committed
Address PR review feedback
Check for key existence, not key truthiness.
1 parent 75d0f70 commit 3120c8f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/core/server/elasticsearch/elasticsearch_config.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ describe('deprecations', () => {
331331
});
332332

333333
it('logs a warning if ssl.key is set and ssl.certificate is not', () => {
334-
const { messages } = applyElasticsearchDeprecations({ ssl: { key: 'foo' } });
334+
const { messages } = applyElasticsearchDeprecations({ ssl: { key: '' } });
335335
expect(messages).toMatchInlineSnapshot(`
336336
Array [
337337
"Setting [${CONFIG_PATH}.ssl.key] without [${CONFIG_PATH}.ssl.certificate] is deprecated. This has no effect, you should use both settings to enable TLS client authentication to Elasticsearch.",
@@ -340,13 +340,18 @@ describe('deprecations', () => {
340340
});
341341

342342
it('logs a warning if ssl.certificate is set and ssl.key is not', () => {
343-
const { messages } = applyElasticsearchDeprecations({ ssl: { certificate: 'foo' } });
343+
const { messages } = applyElasticsearchDeprecations({ ssl: { certificate: '' } });
344344
expect(messages).toMatchInlineSnapshot(`
345345
Array [
346346
"Setting [${CONFIG_PATH}.ssl.certificate] without [${CONFIG_PATH}.ssl.key] is deprecated. This has no effect, you should use both settings to enable TLS client authentication to Elasticsearch.",
347347
]
348348
`);
349349
});
350+
351+
it('does not log a warning if both ssl.key and ssl.certificate are set', () => {
352+
const { messages } = applyElasticsearchDeprecations({ ssl: { key: '', certificate: '' } });
353+
expect(messages).toEqual([]);
354+
});
350355
});
351356

352357
test('#username throws if equal to "elastic", only while running from source', () => {

src/core/server/elasticsearch/elasticsearch_config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ const deprecations: ConfigDeprecationProvider = () => [
117117
`Setting [${fromPath}.username] to "elastic" is deprecated. You should use the "kibana" user instead.`
118118
);
119119
}
120-
if (es.ssl?.key && !es.ssl?.certificate) {
120+
if (es.ssl?.key !== undefined && es.ssl?.certificate === undefined) {
121121
log(
122122
`Setting [${fromPath}.ssl.key] without [${fromPath}.ssl.certificate] is deprecated. This has no effect, you should use both settings to enable TLS client authentication to Elasticsearch.`
123123
);
124-
} else if (es.ssl?.certificate && !es.ssl?.key) {
124+
} else if (es.ssl?.certificate !== undefined && es.ssl?.key === undefined) {
125125
log(
126126
`Setting [${fromPath}.ssl.certificate] without [${fromPath}.ssl.key] is deprecated. This has no effect, you should use both settings to enable TLS client authentication to Elasticsearch.`
127127
);

0 commit comments

Comments
 (0)