-
Notifications
You must be signed in to change notification settings - Fork 228
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
Add required version parameter when requesting user information from … #109
Conversation
…vk provider [fix #108] Seems like now vk provider requires v (version) parameter to be present when calling their API: ``` curl -XGET https://api.vk.com/method/getProfiles\?user_id\=1 => {"error":{"error_code":8,"error_msg":"Invalid request: v (version) is required","request_params":[{"key":"oauth","value":"1"},{"key":"method","value":"getProfiles"},{"key":"user_id","value":"1"}]}} curl -XGET https://api.vk.com/method/getProfiles\?user_id\=1\&v\=5.71 {"response":[{"id":1,"first_name":"Павел","last_name":"Дуров"}]} ```
Thank you very much for he PR! It looks good to me. |
It matters to the issue that cuts out to external gems. Even though it’s better if the PR has tests of the change, considering the code base and circumstances, I think I can’t require tests to the PR. |
Facebook similarly requires an API version, and that's currently set in the initializer. @Hirurg103 can you try setting We should never hardcode api versions as it would require updating the entire Sorcery gem if VK bumps their version requirement. Instead, lets turn this PR into adding the version to the initializer template, and fix any issues that might arise from setting it that way. |
I'm sorry I miss that. Thanks for the response. |
Hi @athix , sounds good to me. I'll do that, thank you |
Hi @ebihara99999 @athix, I've added possibility to configure vk api version with tests |
@Hirurg103 Firstly, follow this and add vk configuration block to configure an api version. Facebook api version example is L119. Now It seems you can't receive the api version because of lacking of this configuration. Then can you confirm working it properly? If you confirm it's working, please add tests if necessary. |
Hi @ebihara99999, done. Thank you for explanation! Could you review this PR if it can be merged? |
I will check the PR in a few days:) |
Hi @ebihara99999 , thank you! |
@Hirurg103 Anyway I think |
The change relates to the providers/vk model so I added providers/vk_spec to make tests more modular instead of putting test cases for different providers into spec/controllers/controller_oauth2_spec.rb As I see there is an example which checks that facebook Graph API version is being passed correctly when calling facebook API - see controller_oauth2_spec.rb#L94-L99. In the future we could refactor that controller spec to test each provider individually - I've found another bug with Facebook provider which relates to loading user avatar - will report it later Either way I can remove that vk provider spec if you insist |
Hi @ebihara99999, do I need to remove the tests to get this work merged? |
Would you wait for the answer in a few days? I’m somehow busy now... |
Hello @ebihara99999 yes, of course |
Hi @ebihara99999 maybe athix can look at this PR if you are busy? |
@Hirurg103 |
I do not understand your point. My test case sets the version parameter in the config and checks that vk API gets called with that version when Vk#process_callback is invoked |
Then it should be like these examples ( just an example, should not be all the same ). Yours are wider. Focus on what you need to test :) |
I do not see much value in those examples. These tests are like setting a variable and then checking that is set correctly, like:
In my tests I set vk version in the config and then check that VK API is being actually called with that version when we request user info |
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.
I tested this locally and the spec doesn't fail even without online access, which satisfies my only worry with this spec (if it used real API calls, it could be flaky and fail if offline/rate limited).
I'd have to dig a little deeper to fully understand what it's doing, but I don't see any issues merging it in for now. Any additional testing is a welcome addition.
Spec fails if the param is removed, as expected. Still a little rough on what's going on under the hood with the stubbing, but I'm comfortable merging this. @ebihara99999 if you want to open another PR with how you'd like the specs to look and discuss it with @Hirurg103 and myself, I would appreciate it. There's a lot of ways to do testing, so I'd like to make sure we have the optimal solution here. |
Thanks for dealing with that! |
@athix and @ebihara99999 Thanks for handling this! |
…vk provider
[fix #108]
Seems like now vk provider requires v (version) parameter to be present when calling their API: