File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 6
6
module OmniAuth
7
7
module Strategies
8
8
class Apple < OmniAuth ::Strategies ::OAuth2
9
+ class JWTFetchingFailed < CallbackError
10
+ def initialize ( error_reason = nil , error_uri = nil )
11
+ super :jwks_fetching_failed , error_reason , error_uri
12
+ end
13
+ end
14
+
9
15
option :name , 'apple'
10
16
11
17
option :client_options ,
@@ -102,10 +108,10 @@ def fetch_jwks
102
108
if res . success?
103
109
res . body
104
110
else
105
- fail! ( :jwks_fetching_failed , CallbackError . new ( :jwks_fetching_failed , 'HTTP Error when fetching JWKs' ) )
111
+ raise JWTFetchingFailed . new ( 'HTTP Error when fetching JWKs' )
106
112
end
107
- rescue Faraday ::Error => e
108
- fail! ( :jwks_fetching_failed , e )
113
+ rescue JWTFetchingFailed , Faraday ::Error => e
114
+ fail! ( :jwks_fetching_failed , e ) and nil
109
115
end
110
116
111
117
def verify_nonce! ( payload )
Original file line number Diff line number Diff line change 265
265
266
266
context 'fails nonce' do
267
267
before ( :each ) do
268
- expect ( subject ) . to receive ( :fail! ) . with ( :nonce_mismatch , instance_of ( OmniAuth ::Strategies ::OAuth2 ::CallbackError ) )
268
+ expect ( subject ) . to receive ( :fail! ) . with (
269
+ :nonce_mismatch ,
270
+ instance_of ( OmniAuth ::Strategies ::OAuth2 ::CallbackError )
271
+ ) . and_return ( [ 302 , { } , '' ] )
269
272
end
270
273
it 'when differs from session' do
271
274
subject . session [ 'omniauth.nonce' ] = 'abc'
356
359
it do
357
360
expect ( subject ) . to receive ( :fail! ) . with (
358
361
:jwks_fetching_failed ,
359
- instance_of ( OmniAuth ::Strategies ::OAuth2 :: CallbackError )
360
- )
362
+ instance_of ( OmniAuth ::Strategies ::Apple :: JWTFetchingFailed )
363
+ ) . and_return ( [ 302 , { } , '' ] )
361
364
subject . info
362
365
end
363
366
end
376
379
expect ( subject ) . to receive ( :fail! ) . with (
377
380
:jwks_fetching_failed ,
378
381
instance_of ( Faraday ::ParsingError )
379
- )
382
+ ) . and_return ( [ 302 , { } , '' ] )
380
383
subject . info
381
384
end
382
385
end
You can’t perform that action at this time.
0 commit comments