How to use the elasticsearch.errors.AuthenticationException function in elasticsearch

To help you get started, we’ve selected a few elasticsearch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elastic / kibana / test / api_integration / apis / index_patterns / es_errors / errors.js View on Github external
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);
github elastic / kibana / src / server / saved_objects / client / lib / __tests__ / decorate_es_error.js View on Github external
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);
  });