Skip to content

Commit adcd31e

Browse files
author
Mario de la Ossa
authored
Update JWT to 2.3, fix specs (#18)
1 parent 88051ce commit adcd31e

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

fridge.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
2121
spec.require_paths = ['lib']
2222

2323
spec.add_dependency 'gem_config'
24-
spec.add_dependency 'jwt', '~> 1.5.6'
24+
spec.add_dependency 'jwt', '~> 2.3.0'
2525

2626
spec.add_development_dependency 'aptible-tasks'
2727
spec.add_development_dependency 'pry'

lib/fridge/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Fridge
2-
VERSION = '0.4.5'.freeze
2+
VERSION = '1.0.0'.freeze
33
end

spec/fridge/access_token_spec.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,22 @@
7979
end
8080

8181
it 'should be verifiable with the application public key' do
82-
expect { JWT.decode(subject.serialize, public_key) }.not_to raise_error
82+
expect { JWT.decode(subject.serialize, public_key, true, algorithm: 'RS512') }
83+
.not_to raise_error
8384
end
8485

8586
it 'should be tamper-resistant' do
8687
header, _, signature = subject.serialize.split('.')
87-
tampered_claim = JWT.base64url_encode({ foo: 'bar' }.to_json)
88+
tampered_claim = JWT::Base64.url_encode({ foo: 'bar' }.to_json)
8889
tampered_token = [header, tampered_claim, signature].join('.')
8990

9091
expect do
91-
JWT.decode(tampered_token, public_key)
92+
JWT.decode(tampered_token, public_key, true, algorithm: 'RS512')
9293
end.to raise_error JWT::DecodeError
9394
end
9495

9596
it 'should represent :exp in seconds since the epoch' do
96-
hash, = JWT.decode(subject.serialize, public_key)
97+
hash, = JWT.decode(subject.serialize, public_key, true, algorithm: 'RS512')
9798
expect(hash['exp']).to be_a Integer
9899
end
99100

@@ -133,7 +134,7 @@
133134
# test that, although eventually we'll want to see symbols back.
134135
actor_s = { 'sub' => 'foo', 'username' => 'test',
135136
'act' => { 'sub' => 'bar' } }
136-
hash, = JWT.decode(subject.serialize, public_key)
137+
hash, = JWT.decode(subject.serialize, public_key, true, algorithm: 'RS512')
137138
expect(hash['act']).to eq(actor_s)
138139

139140
# Now, check that we properly get symbols back

0 commit comments

Comments
 (0)