-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix/UiSettings] ignore certain errors (#13079)
* [SavedObjectClient] emit detectable errors * [uiSettingsService] consume new SavedObjectsClient errors * [SavedObjectsClient] expose errorTypeHelpers as such * [elasticsearch/tests] recreate error for each test * [http] wait for elasticsearch plugin to be ready * [shortUrl/tests] ensure that create request responds with 200 * [shortUrl] use errorTypeHelpers to filter errors * [uiSettings/savedObjectsClientStub] stub errorTypeHelpers * [SavedObjectsClient/errors] expose error module so tests can make errors * [shortUrl/tests] use actual SavedObjectsClient errors * [uiSettings/savedObjectsClientStub] use actual errors lib * [SavedObjectsClient] use decorate instead of "wrap" * [server/routes/uiSettings] refactor routes to forward Boom errors from uiSettings * [uiSettings] colocate routes and service * [testUtils/esTestCluster] use more standard api style * [testUtils/es] add createCallCluster util * [testUtils/esTestCluster] add getters for client/callCluster * [es/healthcheck] ensure that healtcheck stops when server is stopped * [uiSettings/routes] add param/payload validation * [uiSettings/routes] add tests that verify error behaviors (cherry picked from commit 8a64872)
- Loading branch information
Showing
42 changed files
with
1,187 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/core_plugins/kibana/server/routes/api/settings/register_delete.js
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/core_plugins/kibana/server/routes/api/settings/register_get.js
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
src/core_plugins/kibana/server/routes/api/settings/register_set.js
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/core_plugins/kibana/server/routes/api/settings/register_set_many.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/server/saved_objects/client/lib/__tests__/decorate_es_error.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import expect from 'expect.js'; | ||
import { errors as esErrors } from 'elasticsearch'; | ||
|
||
import { decorateEsError } from '../decorate_es_error'; | ||
import { | ||
isEsUnavailableError, | ||
isConflictError, | ||
isNotAuthorizedError, | ||
isForbiddenError, | ||
isNotFoundError, | ||
isBadRequestError, | ||
} from '../errors'; | ||
|
||
describe('savedObjectsClient/decorateEsError', () => { | ||
it('always returns the same error it receives', () => { | ||
const error = new Error(); | ||
expect(decorateEsError(error)).to.be(error); | ||
}); | ||
|
||
it('makes es.ConnectionFault a SavedObjectsClient/EsUnavailable error', () => { | ||
const error = new esErrors.ConnectionFault(); | ||
expect(isEsUnavailableError(error)).to.be(false); | ||
expect(decorateEsError(error)).to.be(error); | ||
expect(isEsUnavailableError(error)).to.be(true); | ||
}); | ||
|
||
it('makes es.ServiceUnavailable a SavedObjectsClient/EsUnavailable error', () => { | ||
const error = new esErrors.ServiceUnavailable(); | ||
expect(isEsUnavailableError(error)).to.be(false); | ||
expect(decorateEsError(error)).to.be(error); | ||
expect(isEsUnavailableError(error)).to.be(true); | ||
}); | ||
|
||
it('makes es.NoConnections a SavedObjectsClient/EsUnavailable error', () => { | ||
const error = new esErrors.NoConnections(); | ||
expect(isEsUnavailableError(error)).to.be(false); | ||
expect(decorateEsError(error)).to.be(error); | ||
expect(isEsUnavailableError(error)).to.be(true); | ||
}); | ||
|
||
it('makes es.RequestTimeout a SavedObjectsClient/EsUnavailable error', () => { | ||
const error = new esErrors.RequestTimeout(); | ||
expect(isEsUnavailableError(error)).to.be(false); | ||
expect(decorateEsError(error)).to.be(error); | ||
expect(isEsUnavailableError(error)).to.be(true); | ||
}); | ||
|
||
it('makes es.Conflict a SavedObjectsClient/Conflict error', () => { | ||
const error = new esErrors.Conflict(); | ||
expect(isConflictError(error)).to.be(false); | ||
expect(decorateEsError(error)).to.be(error); | ||
expect(isConflictError(error)).to.be(true); | ||
}); | ||
|
||
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); | ||
}); | ||
|
||
it('makes es.Forbidden a SavedObjectsClient/Forbidden error', () => { | ||
const error = new esErrors.Forbidden(); | ||
expect(isForbiddenError(error)).to.be(false); | ||
expect(decorateEsError(error)).to.be(error); | ||
expect(isForbiddenError(error)).to.be(true); | ||
}); | ||
|
||
it('makes es.NotFound a SavedObjectsClient/NotFound error', () => { | ||
const error = new esErrors.NotFound(); | ||
expect(isNotFoundError(error)).to.be(false); | ||
expect(decorateEsError(error)).to.be(error); | ||
expect(isNotFoundError(error)).to.be(true); | ||
}); | ||
|
||
it('makes es.BadRequest a SavedObjectsClient/BadRequest error', () => { | ||
const error = new esErrors.BadRequest(); | ||
expect(isBadRequestError(error)).to.be(false); | ||
expect(decorateEsError(error)).to.be(error); | ||
expect(isBadRequestError(error)).to.be(true); | ||
}); | ||
|
||
it('returns other errors as Boom errors', () => { | ||
const error = new Error(); | ||
expect(error).to.not.have.property('isBoom'); | ||
expect(decorateEsError(error)).to.be(error); | ||
expect(error).to.have.property('isBoom'); | ||
}); | ||
}); |
Oops, something went wrong.