Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('wraps other errors in Boom', async () => {
const error = new esErrors.AuthenticationException({
root_cause: [
{
type: 'security_exception',
reason: 'action [indices:data/read/field_caps] is unauthorized for user [standard]'
}
],
type: 'security_exception',
reason: 'action [indices:data/read/field_caps] is unauthorized for user [standard]'
}, {
statusCode: 403
});
expect(error).to.not.have.property('isBoom');
const converted = convertEsError(indices, error);
expect(converted).to.have.property('isBoom');
expect(converted.output.statusCode).to.be(403);
it('makes es.AuthenticationException a SavedObjectsClient/NotAuthorized error', () => {
const error = new esErrors.AuthenticationException();
expect(isNotAuthorizedError(error)).to.be(false);
expect(decorateEsError(error)).to.be(error);
expect(isNotAuthorizedError(error)).to.be(true);
});