Skip to content

Commit

Permalink
cache only when kid is found, even unless auto_detect mode. and pass …
Browse files Browse the repository at this point in the history
…options to delete
  • Loading branch information
nov committed Jan 24, 2023
1 parent 3acd910 commit e5eff66
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions lib/json/jwk/set/fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,10 @@ def self.fetch(jwks_uri, kid:, auto_detect: true, **options)
end
)
)
cache.delete(cache_key, options) if jwks[kid].blank?

if auto_detect
if jwks[kid]
jwks[kid]
else
cache.delete(cache_key)
raise KidNotFound
end
jwks[kid] or raise KidNotFound
else
jwks
end
Expand Down
2 changes: 1 addition & 1 deletion spec/json/jwk/set/fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def delete(cache_key)
end

it do
expect(JSON::JWK::Set::Fetcher.cache).to receive(:delete).with(cache_key)
expect(JSON::JWK::Set::Fetcher.cache).to receive(:delete).with(cache_key, {})
expect do
mock_json :get, jwks_uri, 'jwks' do
subject
Expand Down

0 comments on commit e5eff66

Please sign in to comment.