Skip to content
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

Support for ruby 3.0 #883

Merged
merged 9 commits into from
Oct 6, 2021
Merged

Support for ruby 3.0 #883

merged 9 commits into from
Oct 6, 2021

Conversation

flavorjones
Copy link
Contributor

@flavorjones flavorjones commented Oct 6, 2021

This changeset allows shopify_api to run with Ruby 3.0. The notable changes introduced are:

  • replace URI.escape usage in HMAC-signature parameter handling with WEBrick::HTTPUtils method calls
  • replace URI.escape usage in OAuth URL construction with URI.encode_www_form
  • handle Ruby 3.0's narrower support for keyword argument syntax
  • update minitest (developer dependency)
  • introduce webrick as a runtime dependency

Note that tests have been added around the parameter-handling as it relates to HMAC signature validation, because the keys and values are encoded differently and in very specific ways. I've tried to reproduce the existing behavior insofar as I understand it.

Note that URI equivalence in the tests is now asserted by using Addressable::URI#equals instead of directly comparing strings. There are small differences in how URI.encode_www_form encodes CGI parameters (compared to URI.escape), but they're not semantic differences.

@flavorjones flavorjones requested a review from a team as a code owner October 6, 2021 16:02
@andyw8
Copy link
Contributor

andyw8 commented Oct 6, 2021

Perhaps we can test core against this branch to verify?

@andyw8
Copy link
Contributor

andyw8 commented Oct 6, 2021

Let's also update dev.yml to specify Ruby 3?

@flavorjones
Copy link
Contributor Author

Perhaps we can test core against this branch to verify?

Will do.

Let's also update dev.yml to specify Ruby 3?

WIll do.

Copy link
Contributor

@paulomarg paulomarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One non-blocking comment but otherwise LGTM!

lib/shopify_api/session.rb Outdated Show resolved Hide resolved
@flavorjones
Copy link
Contributor Author

Please note at https://github.com/Shopify/shopify/pull/316649 represents a green test suite against this branch (modulo some attribute changes related to upgrading shopify_api from 9.2 to 9.4).

I think this is ready for review.

Add tests describing the encoding behaviors for keys and values during
signature validation. These tests are _descriptive_ of the current
behavior, and not _prescriptive_.
Replace it with similar methods from WEBrick::HTTPUtils.

Note that this introduces webrick as an explicit dependency because
webrick is available as a separate gem, and because Ruby 3.0 ships
without it in the standard library.
instead of URI.escape which is deprecated.
@flavorjones flavorjones merged commit 239b250 into master Oct 6, 2021
@flavorjones flavorjones deleted the flavorjones-ruby-3-0-support branch October 6, 2021 19:29
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems October 7, 2021 19:11 Inactive
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems April 4, 2022 13:35 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants