Skip to content

Commit

Permalink
Fix and mark HMAC tests with empty secret as pending for openssl 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
anakinj committed Jul 23, 2022
1 parent 3299349 commit d4db08f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions spec/integration/readme_examples_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
end

it 'decodes with HMAC algorithm without secret key' do
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if ::JWT.openssl_3?
token = JWT.encode payload, nil, 'HS256'
decoded_token = JWT.decode token, nil, false

Expand Down
6 changes: 4 additions & 2 deletions spec/jwt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@

context 'when hmac algorithm is used without secret key' do
it 'encodes payload' do
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if ::JWT.openssl_3?
payload = { a: 1, b: 'b' }

token = JWT.encode(payload, '', 'HS256')
Expand All @@ -644,8 +645,8 @@
let(:payload) { { 'a' => 1, 'b' => 'b' } }

it 'ignores algorithm casing during encode/decode' do
enc = JWT.encode(payload, '', 'hs256')
expect(JWT.decode(enc, '')).to eq([payload, { 'alg' => 'HS256' }])
enc = JWT.encode(payload, 'secret', 'hs256')
expect(JWT.decode(enc, 'secret')).to eq([payload, { 'alg' => 'HS256' }])

enc = JWT.encode(payload, data[:rsa_private], 'rs512')
expect(JWT.decode(enc, data[:rsa_public], true, algorithm: 'RS512')).to eq([payload, { 'alg' => 'RS512' }])
Expand Down Expand Up @@ -759,6 +760,7 @@
describe 'when token signed with nil and decoded with nil' do
let(:no_key_token) { ::JWT.encode(payload, nil, 'HS512') }
it 'raises JWT::DecodeError' do
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if ::JWT.openssl_3?
expect { ::JWT.decode(no_key_token, nil, true, algorithms: 'HS512') }.to raise_error(JWT::DecodeError, 'No verification key available')
end
end
Expand Down

0 comments on commit d4db08f

Please sign in to comment.