Skip to content

Commit

Permalink
one of many
Browse files Browse the repository at this point in the history
Signed-off-by: Hermann Mayer <hermann.mayer92@gmail.com>
  • Loading branch information
Jack12816 committed Jul 8, 2024
1 parent a16fb14 commit 541fb7c
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
ruby: ['2.7']
rails: ['5.2']
rails: ['5.2', '6.1', '7.1']
env:
BUNDLE_GEMFILE: 'gemfiles/rails_${{ matrix.rails }}.gemfile'
steps:
Expand Down
12 changes: 12 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ appraise 'rails-5.2' do
gem 'activerecord', '~> 5.2.0'
gem 'activesupport', '~> 5.2.0'
end

appraise 'rails-6.1' do
gem 'activejob', '~> 6.1.0'
gem 'activerecord', '~> 6.1.0'
gem 'activesupport', '~> 6.1.0'
end

appraise 'rails-7.1' do
gem 'activejob', '~> 7.1.0'
gem 'activerecord', '~> 7.1.0'
gem 'activesupport', '~> 7.1.0'
end
27 changes: 27 additions & 0 deletions gemfiles/rails_6.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal", "~> 2.4"
gem "bundler", "~> 2.3"
gem "countless", "~> 1.1"
gem "guard-rspec", "~> 4.7"
gem "rack", "~> 2.2"
gem "rack-test", "~> 2.0"
gem "railties", ">= 5.2"
gem "rake", "~> 13.0"
gem "rspec", "~> 3.12"
gem "rubocop", "~> 1.28"
gem "rubocop-rails", "~> 2.14"
gem "rubocop-rspec", "~> 2.10"
gem "simplecov", ">= 0.22"
gem "timecop", ">= 0.9.6"
gem "vcr", "~> 6.0"
gem "webmock", "~> 3.18"
gem "yard", ">= 0.9.28"
gem "yard-activesupport-concern", ">= 0.0.1"
gem "activejob", "~> 6.1.0"
gem "activerecord", "~> 6.1.0"
gem "activesupport", "~> 6.1.0"

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

source "https://rubygems.org"

gem "appraisal", "~> 2.4"
gem "bundler", "~> 2.3"
gem "countless", "~> 1.1"
gem "guard-rspec", "~> 4.7"
gem "rack", "~> 2.2"
gem "rack-test", "~> 2.0"
gem "railties", ">= 5.2"
gem "rake", "~> 13.0"
gem "rspec", "~> 3.12"
gem "rubocop", "~> 1.28"
gem "rubocop-rails", "~> 2.14"
gem "rubocop-rspec", "~> 2.10"
gem "simplecov", ">= 0.22"
gem "timecop", ">= 0.9.6"
gem "vcr", "~> 6.0"
gem "webmock", "~> 3.18"
gem "yard", ">= 0.9.28"
gem "yard-activesupport-concern", ">= 0.0.1"
gem "activejob", "~> 7.1.0"
gem "activerecord", "~> 7.1.0"
gem "activesupport", "~> 7.1.0"

gemspec path: "../"
2 changes: 1 addition & 1 deletion spec/grape/jwt/authentication/dependencies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
jwt_verification_key
].each do |option|
it "sets the '#{option}' option" do
expect(Keyless.configuration).to receive("#{option}=".to_sym)
expect(Keyless.configuration).to receive(:"#{option}=")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/grape/jwt/authentication/jwt_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
it 'inject the parsed token which makes the payload accessible' do
handler.call(env)
expect(env['grape_jwt_auth.parsed_token'].payload).to \
be_eql(RecursiveOpenStruct.new(test: true))
eql(RecursiveOpenStruct.new(test: true))
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/grape/jwt/grape_usage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,49 +87,49 @@ class API < Grape::API
it 'fails on missing authorization header' do
get '/v1/test'
expect(last_response.body).to \
be_eql('Malformed!')
eql('Malformed!')
end

it 'fails on a malformed authorization header' do
header 'Authorization', "Bearer #{malformed_token}"
get '/v1/test'
expect(last_response.body).to \
be_eql('Malformed!')
eql('Malformed!')
end

it 'fails on a wrong/bad JSON Web Token' do
header 'Authorization', "Bearer #{invalid_token}"
get '/v1/test'
expect(last_response.body).to \
be_eql('Go away!')
eql('Go away!')
end

it 'succeeds on a fine JSON Web Token' do
header 'Authorization', "Bearer #{valid_token}"
get '/v1/test'
expect(last_response.body).to be_eql('{"test":true}')
expect(last_response.body).to eql('{"test":true}')
end

it 'succeeds on a lowercase authorization header' do
header 'authorization', "Bearer #{valid_token}"
get '/v1/test'
expect(last_response.body).to be_eql('{"test":true}')
expect(last_response.body).to eql('{"test":true}')
end

describe 'helpers' do
describe '#original_request_jwt' do
it 'echos the JWT' do
header 'Authorization', "Bearer #{valid_token}"
get '/v1/token'
expect(last_response.body).to be_eql(%({"token":"#{valid_token}"}))
expect(last_response.body).to eql(%({"token":"#{valid_token}"}))
end
end

describe '#request_jwt' do
it 'echos the JWT payload' do
header 'Authorization', "Bearer #{valid_token}"
get '/v1/payload'
expect(last_response.body).to be_eql(%({"payload":{"test":true}}))
expect(last_response.body).to eql(%({"payload":{"test":true}}))
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/grape/jwt/rack_usage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@
it 'fails on missing authorization header' do
get '/'
expect(last_response.body).to \
be_eql('Authorization header is malformed.')
eql('Authorization header is malformed.')
end

it 'fails on a malformed authorization header' do
header 'Authorization', "Bearer #{malformed_token}"
get '/'
expect(last_response.body).to \
be_eql('Authorization header is malformed.')
eql('Authorization header is malformed.')
end

it 'fails on a wrong/bad JSON Web Token' do
header 'Authorization', "Bearer #{invalid_token}"
get '/'
expect(last_response.body).to \
be_eql('Access denied.')
eql('Access denied.')
end

it 'succeeds on a fine JSON Web Token' do
Expand Down

0 comments on commit 541fb7c

Please sign in to comment.