Skip to content

Commit

Permalink
Return truthy value on success
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinj committed Oct 3, 2024
1 parent b9ee8b6 commit 6335f5e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Notable changes in the upcoming **version 3.0**:

**Fixes and enhancements:**

- Return truthy value for `::JWT::ClaimsValidator#validate!` and `::JWT::Verify.verify_claims` [#628](https://github.com/jwt/ruby-jwt/pull/628) ([@anakinj](https://github.com/anakinj))
- Your contribution here

## [v2.9.2](https://github.com/jwt/ruby-jwt/tree/v2.9.2) (2024-10-03)
Expand Down
1 change: 1 addition & 0 deletions lib/jwt/claims_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def initialize(payload)

def validate!
Claims.verify_payload!(@payload, :numeric)
true
end
end
end
1 change: 1 addition & 0 deletions lib/jwt/verify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class << self

def verify_claims(payload, options)
::JWT::Claims.verify!(payload, options)
true
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/jwt/claims_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
context "when #{claim} payload is an integer" do
let(:claims) { { claim => 12_345 } }

it { is_expected.to be_truthy }
it 'does not raise error' do
expect { subject }.not_to raise_error
end
Expand Down
2 changes: 1 addition & 1 deletion spec/jwt/verify_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def issuer_start_with_ruby?(issuer)
%w[verify_aud verify_expiration verify_iat verify_iss verify_jti verify_not_before verify_sub].each do |method|
let(:payload) { base_payload.merge(fail_verifications_payload) }
it "must skip verification when #{method} option is set to false" do
described_class.verify_claims(payload, options.merge(method => false))
expect(described_class.verify_claims(payload, options.merge(method => false))).to be_truthy
end

it "must raise error when #{method} option is set to true" do
Expand Down

0 comments on commit 6335f5e

Please sign in to comment.