1
0
Fork 0
mirror of https://github.com/omniauth/omniauth.git synced 2022-11-09 12:31:49 -05:00

test mode request redirect to callback_url

This commit is contained in:
Josh Lane 2013-09-24 14:42:39 -07:00
parent abf32a4d94
commit e2f2dce974
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
@ -411,11 +412,15 @@ module OmniAuth
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