Skip to content

Commit

Permalink
integration test for required_claims
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjdavis committed Jul 15, 2021
1 parent 6c47e9a commit 4cb4751
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/integration/readme_examples_spec.rb
Expand Up @@ -226,6 +226,20 @@
end.not_to raise_error
end

it 'required_claims' do
payload = { data: 'test' }

token = JWT.encode payload, hmac_secret, 'HS256'

expect do
JWT.decode token, hmac_secret, true, :required_claims => ['exp'], :algorithm => 'HS256'
end.to raise_error(JWT::MissingRequiredClaim)

expect do
JWT.decode token, hmac_secret, true, :required_claims => ['data'], :algorithm => 'HS256'
end.not_to raise_error
end

it 'find_key' do
issuers = %w[My_Awesome_Company1 My_Awesome_Company2]
iss_payload = { data: 'data', iss: issuers.first }
Expand Down

0 comments on commit 4cb4751

Please sign in to comment.