-
Notifications
You must be signed in to change notification settings - Fork 270
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
Fixes #14852 - do not pass in "data" param unless needed #436
Conversation
note: this PR should fix the katello dev setup 401 issue during proxy registration |
The expectations will need to be adjusted in here too: https://github.com/theforeman/puppet-foreman/blob/master/spec/unit/foreman_resource_rest_v3_spec.rb |
this PR has a bug related to POSTing. I am looking into it now and will update. |
if [:post, :put, :patch].include?(method) | ||
response = oauth_consumer.request(method, uri.to_s, generate_token, {}, data, headers) | ||
else | ||
response = oauth_consumer.request(method, uri.to_s, generate_token, {}, headers) |
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.
Is GET the only one this applies to? I might flip the conditions around in that case. Could :delete
for example be a possible method?
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.
It could be flipped, I did it like that so it's the inverse of what the oauth gem does.
in 0.4.7 it's:
if [:post, :put].include?(http_method)
data = arguments.shift
end
Later versions added :patch
so I added it here as well.
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.
Ok makes sense then
Tested, clean installer run, and the proxy gets registered. |
travis fails on 1.8.7:
This appears to not be related to this PR. |
#437 should fix the webmock error. Tested this and it works fine, I'm guessing you've enabled oauth_map_users, which is why the contents of the headers are important. Seems to fix it for me. |
@beav please rebase. |
Previously, the "data" param was passed to all oauth requests. This caused issues with `GET` requests, since `data` and `headers` gets mashed into `*arguments`, and then the oauth gem will `shift` off the first argument if there's a `POST` or `PUT` method. The end result was that headers weren't being sent on `GET` requests. Instead, only supply the "data" param if we are doing a `POST` or `PUT`.
@mmoll rebased |
merged, thanks @beav! |
) Previously, the "data" param was passed to all oauth requests. This caused issues with `GET` requests, since `data` and `headers` gets mashed into `*arguments`, and then the oauth gem will `shift` off the first argument if there's a `POST` or `PUT` method. The end result was that headers weren't being sent on `GET` requests. Instead, only supply the "data" param if we are doing a `POST` or `PUT`.
Previously, the "data" param was passed to all oauth requests. This caused
issues with
GET
requests, sincedata
andheaders
gets mashed into*arguments
, and then the oauth gem willshift
off the first argument ifthere's a
POST
orPUT
method. The end result was that headers weren't beingsent on
GET
requests.Instead, only supply the "data" param if we are doing a
POST
orPUT
.