mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
This commit is contained in:
parent
6748c6abbd
commit
acd99a13c5
2 changed files with 15 additions and 0 deletions
|
@ -47,6 +47,10 @@ export function convertEsError(indices, error) {
|
|||
return createNoMatchingIndicesError(indices);
|
||||
}
|
||||
|
||||
if (error.isBoom) {
|
||||
return error;
|
||||
}
|
||||
|
||||
const statusCode = error.statusCode;
|
||||
const message = error.body ? error.body.error : undefined;
|
||||
return Boom.boomify(error, { statusCode, message });
|
||||
|
|
|
@ -117,6 +117,17 @@ export default function ({ getService }) {
|
|||
|
||||
expect(converted.output.statusCode).to.be(401);
|
||||
});
|
||||
|
||||
it('preserves headers from Boom errors', () => {
|
||||
const error = new Error();
|
||||
error.statusCode = 401;
|
||||
const boomError = Boom.boomify(error, { statusCode: error.statusCode });
|
||||
const wwwAuthenticate = 'Basic realm="Authorization Required"';
|
||||
boomError.output.headers['WWW-Authenticate'] = wwwAuthenticate;
|
||||
const converted = convertEsError(indices, boomError);
|
||||
|
||||
expect(converted.output.headers['WWW-Authenticate']).to.be(wwwAuthenticate);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue