Skip to content

Loading…

Problem with mock_request_call and mock_callback_call methods not preserving the omniauth.params hash #610

Merged
merged 1 commit into from

2 participants

@alexis

The fix is pretty simple.

@sferik sferik merged commit 30936da into intridea:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 1 deletion.
  1. +3 −1 lib/omniauth/strategy.rb
  2. +14 −0 spec/omniauth/strategy_spec.rb
View
4 lib/omniauth/strategy.rb
@@ -261,6 +261,8 @@ def mock_call!(env)
def mock_request_call
setup_phase
+ session['omniauth.params'] = request.params
+
if request.params['origin']
@env['rack.session']['omniauth.origin'] = request.params['origin']
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
@@ -276,7 +278,7 @@ def mock_callback_call
fail!(mocked_auth)
else
@env['omniauth.auth'] = mocked_auth
- @env['omniauth.params'] = session.delete('query_params') || {}
+ @env['omniauth.params'] = session.delete('omniauth.params') || {}
@env['omniauth.origin'] = session.delete('omniauth.origin')
@env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
call_app!
View
14 spec/omniauth/strategy_spec.rb
@@ -564,6 +564,20 @@ def make_env(path = '/auth/test', props = {})
strategy.env['omniauth.origin'].should == 'http://example.com/origin'
end
+ it 'should set omniauth.params on the request phase' do
+ OmniAuth.config.mock_auth[:test] = {}
+
+ strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'foo=bar'))
+ strategy.env['rack.session']['omniauth.params'].should == {'foo' => 'bar'}
+ end
+
+ it 'should turn omniauth.params into an env variable on the callback phase' do
+ OmniAuth.config.mock_auth[:test] = {}
+
+ strategy.call(make_env('/auth/test/callback', 'rack.session' => {'omniauth.params' => {'foo' => 'bar'}}))
+ strategy.env['omniauth.params'].should == {'foo' => 'bar'}
+ end
+
after do
OmniAuth.config.test_mode = false
end
Something went wrong with that request. Please try again.