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

Make tests pass in Rails 7.1 #165

Merged
merged 3 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/global_id/signed_global_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def verify_with_legacy_self_validated_metadata(sgid, options)

raise_if_expired(metadata['expires_at'])

metadata['gid'] if pick_purpose(options) == metadata['purpose']
metadata['gid'] if pick_purpose(options)&.to_s == metadata['purpose']&.to_s
rescue ActiveSupport::MessageVerifier::InvalidSignature, ExpiredMessage
nil
end
Expand Down
4 changes: 2 additions & 2 deletions lib/global_id/verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
class GlobalID
class Verifier < ActiveSupport::MessageVerifier
private
def encode(data)
def encode(data, **)
::Base64.urlsafe_encode64(data)
end

def decode(data)
def decode(data, **)
::Base64.urlsafe_decode64(data)
end
end
Expand Down
1 change: 1 addition & 0 deletions test/cases/railtie_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def setup
@app.config.eager_load = false
@app.config.logger = Logger.new(nil)
@app.config.secret_key_base = ('x' * 30)
@app.config.active_support.cache_format_version = Rails::VERSION::STRING.to_f
end

test 'GlobalID.app for Blog::Application defaults to blog' do
Expand Down
4 changes: 3 additions & 1 deletion test/cases/signed_global_id_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ class SignedGlobalIDPurposeTest < ActiveSupport::TestCase

test 'parse is backwards compatible with the self validated metadata' do
legacy_sgid = "eyJnaWQiOiJnaWQ6Ly9iY3gvUGVyc29uLzUiLCJwdXJwb3NlIjoibG9naW4iLCJleHBpcmVzX2F0IjpudWxsfQ==--4b9630f3a1fb3d7d6584d95d4fac96433ec2deef"
assert_equal @login_sgid, SignedGlobalID.parse(legacy_sgid, for: 'login')
parsed_sgid = SignedGlobalID.parse(legacy_sgid, for: :login)
assert_equal @login_sgid.uri, parsed_sgid.uri
assert_equal @login_sgid.purpose, parsed_sgid.purpose.to_s
end

test 'equal only with same purpose' do
Expand Down