Skip to content

Commit 2a550f9

Browse files
authored
Update CI to add compatibility with rails 8 (#283)
* Update CI to use recent Rails versions * Override registrations controller to disable session storing
1 parent 3a0ade4 commit 2a550f9

File tree

23 files changed

+269
-204
lines changed

23 files changed

+269
-204
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: CI
22

33
on: [push, pull_request]
44

@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
ruby-version: ['3.0', '3.1', '3.2', '3.3', ruby-head]
10+
ruby-version: ['3.2', '3.3', '3.4', ruby-head]
1111

1212
steps:
1313
- uses: actions/checkout@v4
@@ -16,6 +16,7 @@ jobs:
1616
with:
1717
ruby-version: ${{ matrix.ruby-version }}
1818
bundler-cache: true # 'bundle install' and cache
19-
- name: Run specs
19+
- name: Run specs
2020
run: |
21+
cd spec/fixtures/rails_app && bundle && bundle exec rails db:setup && cd -
2122
bundle exec rspec

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
- name: Set up Ruby ${{ matrix.ruby-version }}
1111
uses: ruby/setup-ruby@v1
1212
with:
13-
ruby-version: 2.7
13+
ruby-version: 3.4
1414
bundler-cache: true # 'bundle install' and cache
15-
- name: Run specs
15+
- name: Run specs
1616
run: |
1717
bundle exec rubocop

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
/doc/
77
/pkg/
88
/spec/reports/
9+
/spec/fixtures/rails_app/db/test.sqlite3*
10+
/spec/fixtures/rails_app/db/development.sqlite3*
11+
/spec/fixtures/rails_app/tmp
912
/tmp/
1013
.overcommit_gems.rb.lock
1114
*.log
1215
*sqlite3-journal
16+
/tags

devise-jwt.gemspec

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ Gem::Specification.new do |spec|
2828
spec.add_development_dependency "rake", "~> 13.0"
2929
spec.add_development_dependency "rspec"
3030
# Needed to test the rails fixture application
31-
spec.add_development_dependency 'rails', '~> 6.0'
32-
spec.add_development_dependency 'sqlite3', '~> 1.3'
33-
spec.add_development_dependency 'rspec-rails', '~> 4.0'
31+
spec.add_development_dependency 'rails'
32+
spec.add_development_dependency 'sqlite3'
33+
spec.add_development_dependency 'rspec-rails'
3434
# Cops
35-
spec.add_development_dependency 'rubocop', '~> 0.87'
36-
spec.add_development_dependency 'rubocop-rspec', '~> 1.42'
35+
spec.add_development_dependency 'rubocop'
36+
spec.add_development_dependency 'rubocop-rspec'
3737
# Test reporting
38-
spec.add_development_dependency 'simplecov', '0.17'
39-
spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
38+
spec.add_development_dependency 'simplecov'
39+
spec.add_development_dependency 'codeclimate-test-reporter'
4040
end

spec/devise/jwt/defaults_generator_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
it 'adds strategies configured for each devise model with jwt' do
126126
expect(defaults[:revocation_strategies]).to eq(
127127
jwt_with_jti_matcher_user: 'JwtWithJtiMatcherUser',
128-
jwt_with_denylist_user: 'JWTDenylist',
128+
jwt_with_denylist_user: 'JwtDenylist',
129129
jwt_with_allowlist_user: 'JwtWithAllowlistUser',
130130
jwt_with_null_user: 'Devise::JWT::RevocationStrategies::Null'
131131
)

spec/devise/jwt/mapping_inspector_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,45 +24,45 @@
2424
describe '#jwt?' do
2525
context 'when jwt_authenticatable module is included' do
2626
it 'returns true' do
27-
expect(jwt_with_jti_matcher_inspector.jwt?).to eq(true)
27+
expect(jwt_with_jti_matcher_inspector.jwt?).to be(true)
2828
end
2929
end
3030

3131
context 'when jwt_authenticatable module is not included' do
3232
it 'returns false' do
33-
expect(no_jwt_inspector.jwt?).to eq(false)
33+
expect(no_jwt_inspector.jwt?).to be(false)
3434
end
3535
end
3636
end
3737

3838
describe '#session?' do
3939
context 'when session routes are included' do
4040
it 'returns true' do
41-
expect(jwt_with_jti_matcher_inspector.session?).to eq(true)
41+
expect(jwt_with_jti_matcher_inspector.session?).to be(true)
4242
end
4343
end
4444

4545
context 'when session routes are not included' do
4646
it 'returns true' do
4747
jwt_with_jti_matcher_inspector.mapping.routes.delete(:session)
4848

49-
expect(jwt_with_jti_matcher_inspector.session?).to eq(false)
49+
expect(jwt_with_jti_matcher_inspector.session?).to be(false)
5050
end
5151
end
5252
end
5353

5454
describe '#registration?' do
5555
context 'when registration routes are included' do
5656
it 'returns true' do
57-
expect(jwt_with_jti_matcher_inspector.registration?).to eq(true)
57+
expect(jwt_with_jti_matcher_inspector.registration?).to be(true)
5858
end
5959
end
6060

6161
context 'when registration routes are not included' do
6262
it 'returns true' do
6363
jwt_with_jti_matcher_inspector.mapping.routes.delete(:registration)
6464

65-
expect(jwt_with_jti_matcher_inspector.registration?).to eq(false)
65+
expect(jwt_with_jti_matcher_inspector.registration?).to be(false)
6666
end
6767
end
6868
end

spec/devise/jwt/revocation_strategies/allowlist_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
before { user.allowlisted_jwts.create(payload) }
2121

2222
it 'returns false' do
23-
expect(strategy.jwt_revoked?(payload, user)).to eq(false)
23+
expect(strategy.jwt_revoked?(payload, user)).to be(false)
2424
end
2525
end
2626

2727
context 'when jti and aud payload does not exist on jwt_allowlist' do
2828
it 'returns true' do
29-
expect(strategy.jwt_revoked?(payload, user)).to eq(true)
29+
expect(strategy.jwt_revoked?(payload, user)).to be(true)
3030
end
3131
end
3232
end
@@ -40,9 +40,11 @@
4040
end
4141

4242
it 'does not crash when token has already been revoked' do
43-
strategy.revoke_jwt(payload, user)
43+
expect do
44+
strategy.revoke_jwt(payload, user)
4445

45-
strategy.revoke_jwt(payload, user)
46+
strategy.revoke_jwt(payload, user)
47+
end.not_to raise_error
4648
end
4749
end
4850

@@ -52,7 +54,7 @@
5254

5355
expect(
5456
jwt_with_allowlist_user.allowlisted_jwts.exists?(payload)
55-
).to eq(true)
57+
).to be(true)
5658
end
5759
end
5860
end

spec/devise/jwt/revocation_strategies/denylist_spec.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'spec_helper'
44

55
describe Devise::JWT::RevocationStrategies::Denylist do
6-
subject(:strategy) { JWTDenylist }
6+
subject(:strategy) { JwtDenylist }
77

88
let(:payload) { { 'jti' => '123', 'exp' => '1501717440' } }
99

@@ -12,13 +12,13 @@
1212
it 'returns true' do
1313
strategy.create(jti: '123')
1414

15-
expect(strategy.jwt_revoked?(payload, :whatever)).to eq(true)
15+
expect(strategy.jwt_revoked?(payload, :whatever)).to be(true)
1616
end
1717
end
1818

1919
context 'when payload jti is not in the denylist' do
2020
it 'returns true' do
21-
expect(strategy.jwt_revoked?(payload, :whatever)).to eq(false)
21+
expect(strategy.jwt_revoked?(payload, :whatever)).to be(false)
2222
end
2323
end
2424
end
@@ -34,13 +34,15 @@
3434
strategy.revoke_jwt(payload, :whatever)
3535

3636
exp = strategy.find_by(jti: '123').exp
37-
expect(exp).equal? Time.at(payload['exp'].to_i)
37+
expect(exp).to eq(Time.at(payload['exp'].to_i))
3838
end
3939

4040
it 'does not crash when token has already been revoked' do
41-
strategy.revoke_jwt(payload, :whatever)
41+
expect do
42+
strategy.revoke_jwt(payload, :whatever)
4243

43-
strategy.revoke_jwt(payload, :whatever)
44+
strategy.revoke_jwt(payload, :whatever)
45+
end.not_to raise_error
4446
end
4547
end
4648
end

spec/devise/jwt/revocation_strategies/jti_matcher_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
let(:jti) { user.jti }
2727

2828
it 'returns false' do
29-
expect(strategy.jwt_revoked?(payload, user)).to eq(false)
29+
expect(strategy.jwt_revoked?(payload, user)).to be(false)
3030
end
3131
end
3232

3333
context 'when jti in payload does not match user jti column' do
3434
let(:jti) { '123' }
3535

3636
it 'returns true' do
37-
expect(strategy.jwt_revoked?(payload, user)).to eq(true)
37+
expect(strategy.jwt_revoked?(payload, user)).to be(true)
3838
end
3939
end
4040
end

spec/devise/jwt/revocation_strategies/null_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
describe '#jwt_revoked?(payload, user)' do
99
it 'returns false' do
10-
expect(strategy.jwt_revoked?(:whatever, :whatever)).to eq(false)
10+
expect(strategy.jwt_revoked?(:whatever, :whatever)).to be(false)
1111
end
1212
end
1313
end

0 commit comments

Comments
 (0)