Skip to content

Commit

Permalink
Merge pull request #58 from envato/jaf/rack-3-support
Browse files Browse the repository at this point in the history
Fix compatibility with Rack 3 + general tidy up
  • Loading branch information
4-Eyes authored Jul 10, 2024
2 parents a06e196 + 9a86076 commit 2db4736
Show file tree
Hide file tree
Showing 19 changed files with 124 additions and 32 deletions.
36 changes: 22 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
---
name: tests
on: [ push, pull_request ]
on: [push, pull_request]
jobs:
test:
name: Test (Ruby ${{ matrix.ruby }} on ${{ matrix.gemfile }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: [ '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3' ]
gemfile: [ 'faraday_1.10.0', 'faraday_2.1.0', 'faraday_2.2.0', 'faraday_2.3.0', 'jwt_1.5.6', 'jwt_2.2.3', 'jwt_2.3.0', 'jwt_2.4.1' ]
ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
gemfile:
[
"faraday_1.10.0",
"faraday_2.8.0",
"faraday_2.9.0",
"faraday_2.10.0",
"jwt_1.5.0",
"jwt_2.6.0",
"jwt_2.7.0",
"jwt_2.8.0",
"rack_2.1.0",
"rack_2.2.0",
"rack_3.0.0",
"rack_3.1.0",
]
exclude:
- { ruby: '2.4', gemfile: 'faraday_2.1.0' }
- { ruby: '2.4', gemfile: 'faraday_2.2.0' }
- { ruby: '2.4', gemfile: 'faraday_2.3.0' }
- { ruby: '2.4', gemfile: 'jwt_2.4.1' }
- { ruby: '2.5', gemfile: 'faraday_2.1.0' }
- { ruby: '2.5', gemfile: 'faraday_2.2.0' }
- { ruby: '2.5', gemfile: 'faraday_2.3.0' }
- { ruby: '3.0', gemfile: 'faraday_1.10.0' }
- { ruby: '3.1', gemfile: 'faraday_1.10.0' }
- { ruby: '3.2', gemfile: 'faraday_1.10.0' }
- { ruby: '3.3', gemfile: 'faraday_1.10.0' }
- { ruby: "2.6", gemfile: "faraday_2.9.0" }
- { ruby: "2.7", gemfile: "faraday_2.9.0" }
- { ruby: "2.6", gemfile: "faraday_2.10.0" }
- { ruby: "2.7", gemfile: "faraday_2.10.0" }
- { ruby: "3.3", gemfile: "rack_2.1.0" }

env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
Expand Down
31 changes: 22 additions & 9 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,38 @@
# Latest JWT minor versions
# Source: https://rubygems.org/gems/jwt/versions
%w[
1.5.6
2.2.3
2.3.0
2.4.1
1.5.0
2.6.0
2.7.0
2.8.0
].each do |jwt_version|
appraise "jwt-#{jwt_version}" do
gem "jwt", jwt_version
gem 'jwt', "~> #{jwt_version}"
end
end

# Latest Faraday minor versions
# Source: https://rubygems.org/gems/faraday/versions
%w[
1.10.0
2.1.0
2.2.0
2.3.0
2.8.0
2.9.0
2.10.0
].each do |faraday_version|
appraise "faraday-#{faraday_version}" do
gem "faraday", faraday_version, require: false
gem 'faraday', "~> #{faraday_version}", require: false
end
end

# Latest Rack minor versions
# Source: https://rubygems.org/gems/rack/versions
%w[
2.1.0
2.2.0
3.0.0
3.1.0
].each do |rack_version|
appraise "rack-#{rack_version}" do
gem 'rack', "~> #{rack_version}"
end
end
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,26 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## [v4.0.0]

### Changed

- Moved CI build to GitHub Actions ([#52]).
- Updated test matrix to test against the following gem versions, any gem versions outside of this matrix are no longer fully supported ([#58]):
- `faraday`: `~> 1.10.0`, `~> 2.8.0`, `~> 2.9.0` & `~> 2.10.0`
- `jwt`: `~> 1.5.0`, `~> 2.6.0`, `~> 2.7.0` & `~> 2.8.0`
- `rack`: `~> 2.1.0`
- Removed support for Ruby 2.4 & 2.5 ([#58])
- Add Ruby 3.3 ([#56]), 3.2 ([#55]) to our test matrix

### Fixed

- Compatibility with Rack 3+ ([#58])

[#52]: https://github.com/envato/jwt_signed_request/pull/52
[#55]: https://github.com/envato/jwt_signed_request/pull/55
[#56]: https://github.com/envato/jwt_signed_request/pull/56
[#58]: https://github.com/envato/jwt_signed_request/pull/58

## [v3.0.0] - 2021-01-12

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ Configured versions are defined in [Appraisals](./Appraisals), which at time of
].each do |jwt_version|
```

Ensure you set up your local environment by running:

```sh
bundle exec appraisal install
```

Run the test suite like this:

```sh
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/faraday_1.10.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "faraday", "1.10.0", require: false
gem "faraday", "~> 1.10.0", require: false

gemspec path: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "faraday", "2.3.0", require: false
gem "faraday", "~> 2.10.0", require: false

gemspec path: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "faraday", "2.1.0", require: false
gem "faraday", "~> 2.8.0", require: false

gemspec path: "../"
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "https://rubygems.org"

gem "faraday", "2.2.0", require: false
gem "faraday", "~> 2.9.0", require: false

gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/jwt_2.2.3.gemfile → gemfiles/jwt_1.5.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
source "https://rubygems.org"

gem "faraday", require: false
gem "jwt", "2.2.3"
gem "jwt", "~> 1.5.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/jwt_2.3.0.gemfile → gemfiles/jwt_2.6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
source "https://rubygems.org"

gem "faraday", require: false
gem "jwt", "2.3.0"
gem "jwt", "~> 2.6.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/jwt_2.4.1.gemfile → gemfiles/jwt_2.7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
source "https://rubygems.org"

gem "faraday", require: false
gem "jwt", "2.4.1"
gem "jwt", "~> 2.7.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/jwt_1.5.6.gemfile → gemfiles/jwt_2.8.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
source "https://rubygems.org"

gem "faraday", require: false
gem "jwt", "1.5.6"
gem "jwt", "~> 2.8.0"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rack_2.1.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "faraday", require: false
gem "rack", "~> 2.1.0"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rack_2.2.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "faraday", require: false
gem "rack", "~> 2.2.0"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rack_3.0.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "faraday", require: false
gem "rack", "~> 3.0.0"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rack_3.1.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "faraday", require: false
gem "rack", "~> 3.1.0"

gemspec path: "../"
3 changes: 3 additions & 0 deletions lib/jwt_signed_request/verify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ def verify_request!
end

def request_body
return '' if request.body.nil?

request.body.rewind
string = request.body.read
request.body.rewind
string
Expand Down
2 changes: 1 addition & 1 deletion lib/jwt_signed_request/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module JWTSignedRequest
VERSION = '3.0.0'
VERSION = '4.0.0'
end
15 changes: 15 additions & 0 deletions spec/jwt_signed_request/verify_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,21 @@
expect(request.body.read).to eq 'data=body'
end

context 'and the body has already been read' do
before do
body.read
end

it 'does not raise any errors' do
expect { verify_request }.not_to raise_error
end

it 'allows the body to be read' do
verify_request
expect(request.body.read).to eq 'data=body'
end
end

context 'when secret key and algorithm are unspecified' do
subject(:verify_request) { described_class.call(request: request) }

Expand Down

0 comments on commit 2db4736

Please sign in to comment.