Skip to content

Commit 1f29105

Browse files
committed
fail! should return an array of rack response
1 parent 6e215cf commit 1f29105

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

lib/omniauth/strategies/apple.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,7 @@ def fetch_jwks
106106
end
107107
res = conn.get 'https://appleid.apple.com/auth/keys'
108108
if res.success?
109-
jwks = res.body
110-
if jwks.is_a?(Hash)
111-
jwks
112-
else
113-
fail!(:jwks_fetching_failed, JWTFetchingFailed.new("Invalid format of JWKS returned: #{jwks}"))
114-
end
109+
res.body
115110
else
116111
fail!(:jwks_fetching_failed, JWTFetchingFailed.new('HTTP Error when fetching JWKs'))
117112
end

spec/omniauth/strategies/apple_spec.rb

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@
265265

266266
context 'fails nonce' do
267267
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, {}, ''])
269272
end
270273
it 'when differs from session' do
271274
subject.session['omniauth.nonce'] = 'abc'
@@ -357,7 +360,7 @@
357360
expect(subject).to receive(:fail!).with(
358361
:jwks_fetching_failed,
359362
instance_of(OmniAuth::Strategies::Apple::JWTFetchingFailed)
360-
)
363+
).and_return([302, {}, ''])
361364
subject.info
362365
end
363366
end
@@ -376,26 +379,7 @@
376379
expect(subject).to receive(:fail!).with(
377380
:jwks_fetching_failed,
378381
instance_of(Faraday::ParsingError)
379-
)
380-
subject.info
381-
end
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::Apple::JWTFetchingFailed)
398-
)
382+
).and_return([302, {}, ''])
399383
subject.info
400384
end
401385
end

0 commit comments

Comments
 (0)