Skip to content

[7.x] [Enterprise Search] Request handler refactors/enhancements + update existing routes to use shared handler (#76106)#76232

Merged
cee-chen merged 1 commit intoelastic:7.xfrom
cee-chen:backport/7.x/pr-76106
Aug 28, 2020
Merged

[7.x] [Enterprise Search] Request handler refactors/enhancements + update existing routes to use shared handler (#76106)#76232
cee-chen merged 1 commit intoelastic:7.xfrom
cee-chen:backport/7.x/pr-76106

Conversation

@cee-chen
Copy link
Copy Markdown
Contributor

Backports the following commits to 7.x:

…xisting routes to use shared handler (elastic#76106)

* Refactor enterprise_search_request_handler to a class that stores config/log

- So that routes don't have to continuously pass it in - just params that actually change (paths, queries)

+ misc refactors/lint fixes from code review

* Update mocks/dependencies so other tests pass type checks

* Update /api/workplace_search/overview endpoint to use new request handler

* Update /api/app_search/engines route to use new handler

- This required updating the shared handler to accept custom params set by the route, since the engines route transmutes some param names
- createRequest mock also had to be updated to correctly reflect a curried function in order to get tests passing

* DRY out hasValidData to a reusable/cleaner call

* Update shared handler to output specific message for auth errors

- Check for /login URL (indicates auth issue)
- Refactor final catch return to allow being passed messages from previous throw
- Change hasValidData fallback to only log (potentially sensitive?) JSON data to server, not to client
- Minor test cleanup - move error tests to single describe block, minor URL/newline cleanup

* Update handler to pass method & body requests + pass back response code

- This will support future POST requests as well as support (e.g.) 404 responses

Minor test refactors:
- Set up new request defaults (method, empty body) + expected output & convert KibanaAuthHeader to string since they're set so close to one another
- group request pass tests into a describe block, remove response body portion of their tests (since we don't really care about that for those tests)
- group response tests into describe block
- clarify how passed handler params arg overrides request.params

* PR feedback: Update custom params arg to take an object instead of a query string
@cee-chen cee-chen added the backport This PR is a backport of another PR label Aug 28, 2020
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@cee-chen cee-chen merged commit fd1b85c into elastic:7.x Aug 28, 2020
@cee-chen cee-chen deleted the backport/7.x/pr-76106 branch August 31, 2020 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants