diff --git a/lib/Transport.js b/lib/Transport.js index 3e6d9fd3d..4d609387d 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -559,7 +559,10 @@ class Transport { debug('Product check failed', err) if (err.statusCode === 401 || err.statusCode === 403) { this[kProductCheck] = 2 - process.emitWarning('The client is unable to verify that the server is Elasticsearch due to security privileges on the server side. Some functionality may not be compatible if the server is running an unsupported product.') + process.emitWarning( + 'The client is unable to verify that the server is Elasticsearch due to security privileges on the server side. Some functionality may not be compatible if the server is running an unsupported product.', + 'ProductNotSupportedSecurityError' + ) productCheckEmitter.emit('product-check', null, true) } else { this[kProductCheck] = 0 diff --git a/test/acceptance/product-check.test.js b/test/acceptance/product-check.test.js index 30c50eaa2..4f357efd7 100644 --- a/test/acceptance/product-check.test.js +++ b/test/acceptance/product-check.test.js @@ -470,7 +470,7 @@ test('Errors v6', t => { }) test('Auth error - 401', t => { - t.plan(8) + t.plan(9) const MockConnection = buildMockConnection({ onRequest (params) { return { @@ -487,6 +487,7 @@ test('Auth error - 401', t => { process.on('warning', onWarning) function onWarning (warning) { + t.equal(warning.name, 'ProductNotSupportedSecurityError') t.equal(warning.message, 'The client is unable to verify that the server is Elasticsearch due to security privileges on the server side. Some functionality may not be compatible if the server is running an unsupported product.') } @@ -524,7 +525,7 @@ test('Auth error - 401', t => { }) test('Auth error - 403', t => { - t.plan(8) + t.plan(9) const MockConnection = buildMockConnection({ onRequest (params) { return { @@ -541,6 +542,7 @@ test('Auth error - 403', t => { process.on('warning', onWarning) function onWarning (warning) { + t.equal(warning.name, 'ProductNotSupportedSecurityError') t.equal(warning.message, 'The client is unable to verify that the server is Elasticsearch due to security privileges on the server side. Some functionality may not be compatible if the server is running an unsupported product.') }