File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,12 @@ def initialize(claims = {})
2626 @content_type = 'application/jwt'
2727 self . typ = :JWT
2828 self . alg = :none
29+ update claims
2930 unless claims . nil?
3031 [ :exp , :nbf , :iat ] . each do |key |
31- claims [ key ] = claims [ key ] . to_i if claims [ key ]
32+ self [ key ] = self [ key ] . to_i if self [ key ]
3233 end
3334 end
34- update claims
3535 end
3636
3737 def sign ( private_key_or_secret , algorithm = :autodetect )
@@ -142,4 +142,4 @@ def pretty_generate(jwt_string)
142142require 'json/jwk'
143143require 'json/jwk/jwkizable'
144144require 'json/jwk/set'
145- require 'json/jwk/set/fetcher'
145+ require 'json/jwk/set/fetcher'
Original file line number Diff line number Diff line change 2323 JSON ::JWT ::VERSION . should_not be_blank
2424 end
2525
26+ describe '#initialize' do
27+ it "doesn't try to modify a frozen hash" do
28+ claims = { iss : 'joe' , exp : '1300819380' } . freeze
29+ jwt = JSON ::JWT . new ( claims )
30+ expect ( jwt [ :exp ] ) . to eql 1300819380
31+ expect ( claims [ :exp ] ) . to eql '1300819380'
32+ end
33+ end
34+
2635 context 'when not signed nor encrypted' do
2736 it do
2837 jwt . to_s . should == no_signed
You can’t perform that action at this time.
0 commit comments