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:
parent
abf32a4d94
commit
e2f2dce974
2 changed files with 17 additions and 6 deletions
|
@ -274,7 +274,8 @@ module OmniAuth
|
||||||
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
|
elsif env['HTTP_REFERER'] && !env['HTTP_REFERER'].match(/#{request_path}$/)
|
||||||
@env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
|
@env['rack.session']['omniauth.origin'] = env['HTTP_REFERER']
|
||||||
end
|
end
|
||||||
redirect(script_name + callback_path + query_string)
|
|
||||||
|
redirect(callback_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def mock_callback_call
|
def mock_callback_call
|
||||||
|
@ -406,16 +407,20 @@ module OmniAuth
|
||||||
|
|
||||||
def full_host
|
def full_host
|
||||||
case OmniAuth.config.full_host
|
case OmniAuth.config.full_host
|
||||||
when String
|
when String
|
||||||
OmniAuth.config.full_host
|
OmniAuth.config.full_host
|
||||||
when Proc
|
when Proc
|
||||||
OmniAuth.config.full_host.call(env)
|
OmniAuth.config.full_host.call(env)
|
||||||
else
|
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 = URI.parse(request.url.gsub(/\?.*$/,''))
|
||||||
uri.path = ''
|
uri.path = ''
|
||||||
#sometimes the url is actually showing http inside rails because the other layers (like nginx) have handled the ssl termination.
|
#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.scheme = 'https' if ssl?
|
||||||
uri.to_s
|
uri.to_s
|
||||||
|
else ""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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)
|
expect(strategy.call(make_env('/AUTH/TeSt/CaLlBAck')).first).to eq(strategy.call(make_env('/auth/test/callback')).first)
|
||||||
end
|
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
|
it "maintains query string parameters" do
|
||||||
response = strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'cheese=stilton'))
|
response = strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'cheese=stilton'))
|
||||||
expect(response[1]['Location']).to eq('/auth/test/callback?cheese=stilton')
|
expect(response[1]['Location']).to eq('/auth/test/callback?cheese=stilton')
|
||||||
|
@ -662,6 +667,7 @@ describe OmniAuth::Strategy do
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
OmniAuth.config.full_host = nil
|
||||||
OmniAuth.config.test_mode = false
|
OmniAuth.config.test_mode = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue