Add warning.name to product check security exception (#1515)

This commit is contained in:
Tomas Della Vedova
2021-08-20 10:39:38 +02:00
committed by GitHub
parent 77bf94a500
commit f161946984
2 changed files with 8 additions and 3 deletions

View File

@ -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

View File

@ -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.')
}