-
Notifications
You must be signed in to change notification settings - Fork 62
want better interface for making test HTTP requests #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or 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
Contributor
|
Not done looking through it, but I'd like to leave this in Nexus for a week or two even after this PR for more iteration. |
3 tasks
david-crespo
approved these changes
Nov 19, 2021
Contributor
david-crespo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I'm going to use it RIGHT NOW
Collaborator
Author
|
Thanks for taking a close look and playing with it! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change prototypes a few interfaces for more ergonomically making HTTP requests in the Nexus test suite. The meat is in nexus/tests/common/http_testing.rs. It includes:
RequestBuilder, which essentially prototypes Proposal: make_request helpers shouldn't assert status code dropshot#165. This struct is Nexus-agnostic and could go into Dropshot instead of keeping it in Nexus. My hope is that we could eventually move this into Dropshot, deprecate all thedropshot::ClientTestContext::make_request*()functions and replace them with this. Those functions should be implementable (for compatibility) in terms of this newRequestBuilder. Theobjects_{post,get,delete}family of functions indropshot::test_utilcould also be implemented in terms of this -- in fact, I included adropshot_compatmodule here with drop-in replacements for these functions.NexusRequestis a light wrapper aroundRequestBuilderthat gives us a place to put Nexus-specific customization. The one (really important) example of this right now isNexusRequest::authn_as, which lets the test say how it wants to authenticate without having to know about spoof authentication, the specific header names and values, etc.Reviewers: I would actually start with the places in the Nexus test suite that I've updated to use the new functions:
NexusRequest. Previously, this function had a bit of authn boilerplate that would have to be replicated to every place where we need to authenticate. That is, as we protect more external API endpoints with authorization, we'd need to copy around this boilerplate. That's basically what pushed me to make this PR.RequestBuilder. (It can't useNexusBuilderbecause it's not actually talking to Nexus -- it needs to provide different kinds of values for the "spoof" header than a valid Nexus client does)This change currently depends on this tiny Dropshot change:
Here's what I'd like to do:
RequestBuilderandNexusRequestinterfaces (and get them to where I've got some +1's)[ ] get feedback on whether we want to putI want to move this into Dropshot in a follow-on PR, not now, so that it's easier to iterate on as I convert more endpoints to useRequestBuilderstraight into Dropshot or keep it in Omicron for now. (The main reason to keep it out is to get more experience with it before we commit to it in Dropshot.)NexusRequest.In follow-up PRs, I'll:
NexusRequest-- it will be needed as we convert API endpoints to use authz.RequestBuilderinto Dropshot to replace what's there today