File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,12 @@ def fetch_jwks
100
100
end
101
101
res = conn . get 'https://appleid.apple.com/auth/keys'
102
102
if res . success?
103
- res . body
103
+ jwks = res . body
104
+ if jwks . is_a? ( Hash )
105
+ jwks
106
+ else
107
+ fail! ( :jwks_fetching_failed , CallbackError . new ( :jwks_fetching_failed , "Invalid format of JWKS returned: #{ jwks } " ) )
108
+ end
104
109
else
105
110
fail! ( :jwks_fetching_failed , CallbackError . new ( :jwks_fetching_failed , 'HTTP Error when fetching JWKs' ) )
106
111
end
Original file line number Diff line number Diff line change 380
380
subject . info
381
381
end
382
382
end
383
+
384
+ context 'when JWKS format is missing :keys' do
385
+ before do
386
+ stub_request ( :get , 'https://appleid.apple.com/auth/keys' ) . to_return (
387
+ body : 'true' ,
388
+ headers : {
389
+ 'Content-Type' : 'application/json'
390
+ }
391
+ )
392
+ end
393
+
394
+ it do
395
+ expect ( subject ) . to receive ( :fail! ) . with (
396
+ :jwks_fetching_failed ,
397
+ instance_of ( OmniAuth ::Strategies ::OAuth2 ::CallbackError )
398
+ )
399
+ subject . info
400
+ end
401
+ end
383
402
end
384
403
end
You can’t perform that action at this time.
0 commit comments