-
Notifications
You must be signed in to change notification settings - Fork 121
allow the json path walk method to parse array indexes #22
allow the json path walk method to parse array indexes #22
Conversation
In the plugin_spec.rb class there is the comment
How would I go about doing these things, it's not entirely clear to me. |
Hi @ursinewalrus, thanks for the PR. The comments in We will need to get some new rspec tests added for this new feature, so that we can be sure it won't regress in future. |
Hi David! Perhaps there is a difference here, I am running it following https://meta.discourse.org/t/beginners-guide-to-install-discourse-on-macos-for-development/15772 , which I think might have some differences from the install that assumes you have a domain? Running "rake plugin:spec[discourse-oauth2-basic]" Running |
I'm not sure exactly why this was happening in development, but working fine in CI. Regardless, I just pushed 47a8211 to master which should resolve the issue, and remove some of the hacks we had in |
a253c6d
to
1ed49bf
Compare
spec/plugin_spec.rb
Outdated
SiteSetting.oauth2_json_email_path = 'emails[1].value' | ||
result = authenticator.json_walk({}, JSON.parse(json_string), :user_id) | ||
|
||
expect(result).to eq nil |
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.
shouldn't we be expecting test2@example.com
here?
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! Had a copy issue and because of how I was sort of pre-testing the tests locally the issue with it incorrectly passing for me didn't show up. The passed in token also should have been :email, or the oauth2_json path should have been the oauth2_json_user_id_path
4cce401
to
0695af7
Compare
@riking - it looks to me like @ursinewalrus addressed your concerns above. anything else blocking this PR now? |
This is looking good to me, thanks @ursinewalrus and @mcwumbly |
Hi!
The way the old json walk worked prevented us from pulling the email address out of the json response our oauth provider sent back. The format looked something like
The old way would return { "value" : "theemail@address.com"}, where of course we only wanted the value of "value".
It is changed so now you can write your path like
emails[index].value
to get it, or if you do
emails.value
it will still default to an index of 0 so as not to break old paths.