Permalink
Browse files

Merge branch 'master' of github.com:intridea/omniauth

  • Loading branch information...
Michael Bleigh
Michael Bleigh committed Apr 12, 2012
2 parents 8e48c7b + 0a7b5b2 commit d0d751a41b8b4425a16ef44c944436109fb97712
Showing with 41 additions and 36 deletions.
  1. +1 −2 .travis.yml
  2. +2 −2 README.md
  3. +9 −4 lib/omniauth/failure_endpoint.rb
  4. +9 −7 spec/omniauth/failure_endpoint_spec.rb
  5. +2 −21 spec/omniauth/strategy_spec.rb
  6. +18 −0 spec/spec_helper.rb
View
@@ -1,4 +1,4 @@
-gemfiles:
+gemfile:
- Gemfile
- Gemfile.rack-1.3.x
language: ruby
@@ -7,6 +7,5 @@ rvm:
- 1.9.2
- 1.9.3
- jruby-18mode
- - jruby-19mode
- rbx-18mode
- rbx-19mode
View
@@ -129,8 +129,8 @@ OmniAuth, how it works, and how to use it.
## <a name="versions"></a>Supported Ruby Versions
-OmniAuth is tested under 1.8.7, 1.9.2, 1.9.3, JRuby, Rubinius (1.8
-mode), and Ruby Enterprise Edition.
+OmniAuth is tested under 1.8.7, 1.9.2, 1.9.3, JRuby (1.8 mode), and Rubinius
+(1.8 and 1.9 modes).
## <a name="license"></a>License
@@ -22,18 +22,23 @@ def call
end
def raise_out!
- raise env['omniauth.error'] || OmniAuth::Error.new(env['omniauth.error.type'])
+ raise env['omniauth.error'] || OmniAuth::Error.new(env['omniauth.error.type'])
end
def redirect_to_failure
message_key = env['omniauth.error.type']
- new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}#{origin_query_param}"
+ new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}#{origin_query_param}#{strategy_name_query_param}"
Rack::Response.new(["302 Moved"], 302, 'Location' => new_path).finish
end
+ def strategy_name_query_param
+ return "" unless env['omniauth.error.strategy']
+ "&strategy=#{env['omniauth.error.strategy'].name}"
+ end
+
def origin_query_param
return "" unless env['omniauth.origin']
- "&origin=#{CGI.escape(env['omniauth.origin'])}"
+ "&origin=#{Rack::Utils.escape(env['omniauth.origin'])}"
end
end
-end
+end
@@ -4,14 +4,15 @@
subject{ OmniAuth::FailureEndpoint }
context 'development' do
- before do
+ before do
@rack_env = ENV['RACK_ENV']
ENV['RACK_ENV'] = 'development'
end
it 'should raise out the error' do
- err = StandardError.new("Blah")
- expect{ subject.call('omniauth.error' => err) }.to raise_error(err)
+ expect do
+ subject.call('omniauth.error' => StandardError.new("Blah"))
+ end.to raise_error(StandardError, "Blah")
end
it 'should raise out an OmniAuth::Error if no omniauth.error is set' do
@@ -24,22 +25,23 @@
end
context 'non-development' do
- let(:env){ {'omniauth.error.type' => 'invalid_request'} }
-
+ let(:env){ {'omniauth.error.type' => 'invalid_request',
+ 'omniauth.error.strategy' => ExampleStrategy.new({}) } }
+
it 'should be a redirect' do
status, head, body = *subject.call(env)
status.should == 302
end
it 'should include the SCRIPT_NAME' do
status, head, body = *subject.call(env.merge('SCRIPT_NAME' => '/random'))
- head['Location'].should == '/random/auth/failure?message=invalid_request'
+ head['Location'].should == '/random/auth/failure?message=invalid_request&strategy=test'
end
it 'should respect configured path prefix' do
OmniAuth.config.stub(:path_prefix => '/boo')
status, head, body = *subject.call(env)
- head["Location"].should == '/boo/failure?message=invalid_request'
+ head["Location"].should == '/boo/failure?message=invalid_request&strategy=test'
end
it 'should include the origin (escaped) if one is provided' do
@@ -1,23 +1,4 @@
-require File.expand_path('../../spec_helper', __FILE__)
-
-class ExampleStrategy
- include OmniAuth::Strategy
- option :name, 'test'
- def call(env); self.call!(env) end
- attr_reader :last_env
- def request_phase
- @fail = fail!(options[:failure]) if options[:failure]
- @last_env = env
- return @fail if @fail
- raise "Request Phase"
- end
- def callback_phase
- @fail = fail!(options[:failure]) if options[:failure]
- @last_env = env
- return @fail if @fail
- raise "Callback Phase"
- end
-end
+require 'spec_helper'
def make_env(path = '/auth/test', props = {})
{
@@ -637,4 +618,4 @@ def make_env(path = '/auth/test', props = {})
OmniAuth.config.test_mode = false
end
end
-end
+end
View
@@ -13,3 +13,21 @@
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
end
+class ExampleStrategy
+ include OmniAuth::Strategy
+ option :name, 'test'
+ def call(env); self.call!(env) end
+ attr_reader :last_env
+ def request_phase
+ @fail = fail!(options[:failure]) if options[:failure]
+ @last_env = env
+ return @fail if @fail
+ raise "Request Phase"
+ end
+ def callback_phase
+ @fail = fail!(options[:failure]) if options[:failure]
+ @last_env = env
+ return @fail if @fail
+ raise "Callback Phase"
+ end
+end

0 comments on commit d0d751a

Please sign in to comment.