-
Notifications
You must be signed in to change notification settings - Fork 6
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
FI-2494 POST capability added to granular scopes #158
Conversation
search_method = previous_request.verb.to_sym | ||
params = search_method == :get ? previous_request.query_parameters : JSON.parse(previous_request.request_body) |
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.
The body of a POST search is application/x-www-form-urlencoded
not JSON.
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.
Thanks, changed both the rspec test to encode it as such and the parsing here to treat it as application/x-www-form-urlencoded
instead of json.
@@ -133,6 +133,7 @@ def self.metadata | |||
).to_json | |||
) | |||
end | |||
|
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.
Remove extra whitespace.
search_method = previous_request.verb.to_sym | ||
params = search_method == :get ? previous_request.query_parameters : Hash[URI.decode_www_form(previous_request.request_body)] | ||
binding.pry if search_method == :post |
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.
Remove pry.
|
||
it 'correctly pulls parameters from POST body' do | ||
response_body = | ||
FHIR::Bundle.new( |
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.
Indent this.
Summary
Added inspection of request body if it is a POST request for query parameters.
Wondering about if we will ever expect more in the body than query parameters, i.e. should there be more thorough parsing/decision making here?
Also want to check that POST searches are made to an endpoint that ends in
\_search
every time? The current spec test uses that endpoint, and I don't think it would impact the functionality, but the spec test wouldn't pass until I added that into the url (fhir_search must automatically add the route when it sees it's a POST?)Testing Guidance
Added a spec test that stubs a post request and returns correct resources, and expects test to pass.