Skip to content

Commit

Permalink
Test for order of claim validation
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinj committed Aug 4, 2024
1 parent 01574df commit 4cde044
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion spec/jwt/jwt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@
let(:iss) { 'ruby-jwt-gem' }
let(:invalid_token) { JWT.encode payload, data[:secret] }

let :token do
let(:token) do
iss_payload = payload.merge(iss: iss)
JWT.encode iss_payload, data[:secret]
end
Expand All @@ -544,6 +544,16 @@
end.not_to raise_error
end
end

context 'claim verification order' do
let(:token) { JWT.encode({ nbf: Time.now.to_i + 100 }, 'secret') }

context 'when two claims are invalid' do
it 'depends on the order of the parameters what error is raised' do
expect { JWT.decode(token, 'secret', true, { verify_jti: true, verify_not_before: true }) }.to raise_error(JWT::ImmatureSignature, 'Signature nbf has not been reached')
end
end
end
end

context 'a token with no segments' do
Expand Down

0 comments on commit 4cde044

Please sign in to comment.