From 9c07581ecb6ed06c426786d333cc1870fb72e88b Mon Sep 17 00:00:00 2001 From: Joakim Antman Date: Fri, 20 Sep 2024 07:43:05 +0300 Subject: [PATCH] Failing tests for verify_aud and verify_iss regressions --- spec/jwt/jwt_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/jwt/jwt_spec.rb b/spec/jwt/jwt_spec.rb index d7324495..c11d233e 100644 --- a/spec/jwt/jwt_spec.rb +++ b/spec/jwt/jwt_spec.rb @@ -538,11 +538,32 @@ iss_payload = payload.merge(iss: iss) JWT.encode iss_payload, data[:secret] end + it 'if verify_iss is set to false (default option) should not raise JWT::InvalidIssuerError' do expect do JWT.decode token, data[:secret], true, iss: iss, algorithm: 'HS256' end.not_to raise_error end + + context 'when verify_iss is set to true and no issues given' do + it 'does not raise' do + expect do + JWT.decode(token, data[:secret], true, verify_iss: true, algorithm: 'HS256') + end.not_to raise_error + end + end + end + + context 'audience claim' do + let(:token) { JWT.encode(payload, data[:secret]) } + + context 'when verify_aud is set to true and no audience given' do + it 'does not raise' do + expect do + JWT.decode(token, data[:secret], true, verify_aud: true, algorithm: 'HS256') + end.not_to raise_error + end + end end context 'claim verification order' do