From b16b428bc639a61993b5cd6593d638176e9cc8ec Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Tue, 23 Mar 2021 23:48:55 +0000 Subject: [PATCH] [Tests] Update missing kibana and elastic references While generating more snapshots more Kibana and Elastic references were caught. Updated the source code and re-ran yarn test:jest -u. Signed-off-by: Kawika Avilla --- .../server/environment/resolve_uuid.test.ts | 18 ++++----- src/core/server/environment/resolve_uuid.ts | 20 +++++----- src/core/server/opensearch/default_headers.ts | 2 +- .../legacy/opensearch_client_config.test.ts | 38 +++++++++---------- .../server/plugins/plugins_service.test.ts | 1 - 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/core/server/environment/resolve_uuid.test.ts b/src/core/server/environment/resolve_uuid.test.ts index 563342ca399d..bde5cebaf761 100644 --- a/src/core/server/environment/resolve_uuid.test.ts +++ b/src/core/server/environment/resolve_uuid.test.ts @@ -102,7 +102,7 @@ describe('resolveInstanceUuid', () => { expect(logger.debug).toHaveBeenCalledTimes(1); expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(` Array [ - "Updating Kibana instance UUID to: CONFIG_UUID (was: FILE_UUID)", + "Updating OpenSearch Dashboards instance UUID to: CONFIG_UUID (was: FILE_UUID)", ] `); }); @@ -117,7 +117,7 @@ describe('resolveInstanceUuid', () => { expect(logger.debug).toHaveBeenCalledTimes(1); expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(` Array [ - "Kibana instance UUID: CONFIG_UUID", + "OpenSearch Dashboards instance UUID: CONFIG_UUID", ] `); }); @@ -137,7 +137,7 @@ describe('resolveInstanceUuid', () => { expect(logger.debug).toHaveBeenCalledTimes(1); expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(` Array [ - "Setting new Kibana instance UUID: CONFIG_UUID", + "Setting new OpenSearch Dashboards instance UUID: CONFIG_UUID", ] `); }); @@ -152,7 +152,7 @@ describe('resolveInstanceUuid', () => { expect(logger.debug).toHaveBeenCalledTimes(1); expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(` Array [ - "Resuming persistent Kibana instance UUID: FILE_UUID", + "Resuming persistent OpenSearch Dashboards instance UUID: FILE_UUID", ] `); }); @@ -178,7 +178,7 @@ describe('resolveInstanceUuid', () => { "UUID from 7.6.0 bug detected, ignoring file UUID", ], Array [ - "Setting new Kibana instance UUID: NEW_UUID", + "Setting new OpenSearch Dashboards instance UUID: NEW_UUID", ], ] `); @@ -204,7 +204,7 @@ describe('resolveInstanceUuid', () => { "UUID from 7.6.0 bug detected, ignoring file UUID", ], Array [ - "Setting new Kibana instance UUID: CONFIG_UUID", + "Setting new OpenSearch Dashboards instance UUID: CONFIG_UUID", ], ] `); @@ -226,7 +226,7 @@ describe('resolveInstanceUuid', () => { expect(logger.debug).toHaveBeenCalledTimes(1); expect(logger.debug.mock.calls[0]).toMatchInlineSnapshot(` Array [ - "Setting new Kibana instance UUID: NEW_UUID", + "Setting new OpenSearch Dashboards instance UUID: NEW_UUID", ] `); }); @@ -238,7 +238,7 @@ describe('resolveInstanceUuid', () => { await expect( resolveInstanceUuid({ pathConfig, serverConfig, logger }) ).rejects.toThrowErrorMatchingInlineSnapshot( - `"Unable to read Kibana UUID file, please check the uuid.server configuration value in opensearch_dashboards.yml and ensure Kibana has sufficient permissions to read / write to this file. Error was: EACCES"` + `"Unable to read OpenSearch Dashboards UUID file, please check the uuid.server configuration value in opensearch_dashboards.yml and ensure OpenSearch Dashboards has sufficient permissions to read / write to this file. Error was: EACCES"` ); }); it('throws an explicit error for file write errors', async () => { @@ -246,7 +246,7 @@ describe('resolveInstanceUuid', () => { await expect( resolveInstanceUuid({ pathConfig, serverConfig, logger }) ).rejects.toThrowErrorMatchingInlineSnapshot( - `"Unable to write Kibana UUID file, please check the uuid.server configuration value in opensearch_dashboards.yml and ensure Kibana has sufficient permissions to read / write to this file. Error was: EISDIR"` + `"Unable to write OpenSearch Dashboards UUID file, please check the uuid.server configuration value in opensearch_dashboards.yml and ensure OpenSearch Dashboards has sufficient permissions to read / write to this file. Error was: EISDIR"` ); }); }); diff --git a/src/core/server/environment/resolve_uuid.ts b/src/core/server/environment/resolve_uuid.ts index e60a6f0e3fed..242d05b6690d 100644 --- a/src/core/server/environment/resolve_uuid.ts +++ b/src/core/server/environment/resolve_uuid.ts @@ -48,14 +48,16 @@ export async function resolveInstanceUuid({ if (uuidFromConfig) { if (uuidFromConfig === uuidFromFile) { // uuid matches, nothing to do - logger.debug(`Kibana instance UUID: ${uuidFromConfig}`); + logger.debug(`OpenSearch Dashboards instance UUID: ${uuidFromConfig}`); return uuidFromConfig; } else { // uuid in file don't match, or file was not present, we need to write it. if (uuidFromFile === undefined) { - logger.debug(`Setting new Kibana instance UUID: ${uuidFromConfig}`); + logger.debug(`Setting new OpenSearch Dashboards instance UUID: ${uuidFromConfig}`); } else { - logger.debug(`Updating Kibana instance UUID to: ${uuidFromConfig} (was: ${uuidFromFile})`); + logger.debug( + `Updating OpenSearch Dashboards instance UUID to: ${uuidFromConfig} (was: ${uuidFromFile})` + ); } await writeUuidToFile(uuidFilePath, uuidFromConfig); return uuidFromConfig; @@ -64,12 +66,12 @@ export async function resolveInstanceUuid({ if (uuidFromFile === undefined) { const newUuid = uuid.v4(); // no uuid either in config or file, we need to generate and write it. - logger.debug(`Setting new Kibana instance UUID: ${newUuid}`); + logger.debug(`Setting new OpenSearch Dashboards instance UUID: ${newUuid}`); await writeUuidToFile(uuidFilePath, newUuid); return newUuid; } - logger.debug(`Resuming persistent Kibana instance UUID: ${uuidFromFile}`); + logger.debug(`Resuming persistent OpenSearch Dashboards instance UUID: ${uuidFromFile}`); return uuidFromFile; } @@ -90,8 +92,8 @@ async function readUuidFromFile(filepath: string, logger: Logger): Promise { "hosts": Array [ Object { "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", "xsrf": "something", }, "host": "localhost", @@ -78,7 +78,7 @@ test('parses fully specified config', () => { 'https://opensearch.local', ], requestHeadersWhitelist: [], - username: 'elastic', + username: 'opensearch', password: 'changeme', pingTimeout: 12345, requestTimeout: 54321, @@ -107,9 +107,9 @@ test('parses fully specified config', () => { "apiVersion": "v7.0.0", "hosts": Array [ Object { - "auth": "elastic:changeme", + "auth": "opensearch:changeme", "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", "xsrf": "something", }, "host": "localhost", @@ -119,9 +119,9 @@ test('parses fully specified config', () => { "query": null, }, Object { - "auth": "elastic:changeme", + "auth": "opensearch:changeme", "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", "xsrf": "something", }, "host": "domain.com", @@ -131,9 +131,9 @@ test('parses fully specified config', () => { "query": null, }, Object { - "auth": "elastic:changeme", + "auth": "opensearch:changeme", "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", "xsrf": "something", }, "host": "opensearch.local", @@ -188,7 +188,7 @@ test('parses config timeouts of moment.Duration type', () => { "hosts": Array [ Object { "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", "xsrf": "something", }, "host": "localhost", @@ -220,7 +220,7 @@ describe('#auth', () => { sniffOnStart: true, sniffOnConnectionFault: true, hosts: ['http://user:password@localhost/opensearch', 'https://opensearch.local'], - username: 'elastic', + username: 'opensearch', password: 'changeme', requestHeadersWhitelist: [], }, @@ -233,7 +233,7 @@ describe('#auth', () => { "hosts": Array [ Object { "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", "xsrf": "something", }, "host": "localhost", @@ -244,7 +244,7 @@ describe('#auth', () => { }, Object { "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", "xsrf": "something", }, "host": "opensearch.local", @@ -284,7 +284,7 @@ describe('#auth', () => { "hosts": Array [ Object { "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", "xsrf": "something", }, "host": "opensearch.local", @@ -313,7 +313,7 @@ describe('#auth', () => { sniffOnConnectionFault: true, hosts: ['https://opensearch.local'], requestHeadersWhitelist: [], - username: 'elastic', + username: 'opensearch', }, logger.get(), { auth: true } @@ -324,7 +324,7 @@ describe('#auth', () => { "hosts": Array [ Object { "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", "xsrf": "something", }, "host": "opensearch.local", @@ -509,7 +509,7 @@ describe('#ssl', () => { "hosts": Array [ Object { "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", }, "host": "opensearch.local", "path": "/", @@ -556,7 +556,7 @@ describe('#ssl', () => { "hosts": Array [ Object { "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", }, "host": "opensearch.local", "path": "/", @@ -599,7 +599,7 @@ describe('#ssl', () => { "hosts": Array [ Object { "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", }, "host": "opensearch.local", "path": "/", @@ -667,7 +667,7 @@ describe('#ssl', () => { "hosts": Array [ Object { "headers": Object { - "x-elastic-product-origin": "opensearch-dashboards", + "x-opensearch-product-origin": "opensearch-dashboards", }, "host": "opensearch.local", "path": "/", diff --git a/src/core/server/plugins/plugins_service.test.ts b/src/core/server/plugins/plugins_service.test.ts index bbf98c276161..2d3350068640 100644 --- a/src/core/server/plugins/plugins_service.test.ts +++ b/src/core/server/plugins/plugins_service.test.ts @@ -388,7 +388,6 @@ describe('PluginsService', () => { initialize: true, pluginSearchPaths: [ resolve(process.cwd(), 'src', 'plugins'), - resolve(process.cwd(), 'x-pack', 'plugins'), resolve(process.cwd(), 'plugins'), resolve(process.cwd(), '..', 'opensearch-dashboards-extra'), ],