Merge pull request #699 from lanej/mock-request-callback-url

test mode request redirect to callback_url
This commit is contained in:
Tom Milewski 2013-09-26 08:36:35 -07:00
commit 83284ce6c2
2 changed files with 17 additions and 6 deletions

View File

@ -274,7 +274,8 @@ module OmniAuth
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
@env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
end
redirect(script_name + callback_path + query_string)
redirect(callback_url)
end
def mock_callback_call
@ -406,16 +407,20 @@ module OmniAuth
def full_host
case OmniAuth.config.full_host
when String
OmniAuth.config.full_host
when Proc
OmniAuth.config.full_host.call(env)
else
when String
OmniAuth.config.full_host
when Proc
OmniAuth.config.full_host.call(env)
else
# in Rack 1.3.x, request.url explodes if scheme is nil
if request.scheme && request.url.match(URI::ABS_URI)
uri = URI.parse(request.url.gsub(/\?.*$/,''))
uri.path = ''
#sometimes the url is actually showing http inside rails because the other layers (like nginx) have handled the ssl termination.
uri.scheme = 'https' if ssl?
uri.to_s
else ""
end
end
end

View File

@ -547,6 +547,11 @@ describe OmniAuth::Strategy do
expect(strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).first).to eq(strategy.call(make_env('/auth/test/callback')).first)
end
it "maintains host and port" do
response = strategy.call(make_env('/auth/test', 'rack.url_scheme' => "http", 'HTTP_HOST' => 'example.org', 'SERVER_PORT' => 3000))
expect(response[1]['Location']).to eq('http://example.org:3000/auth/test/callback')
end
it "maintains query string parameters" do
response = strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'cheese=stilton'))
expect(response[1]['Location']).to eq('/auth/test/callback?cheese=stilton')
@ -662,6 +667,7 @@ describe OmniAuth::Strategy do
end
after do
OmniAuth.config.full_host = nil
OmniAuth.config.test_mode = false
end
end