Merge branch 'jsj-configurable-raise-out' of github.com:joshjordan/omniauth into joshjordan-jsj-configurable-raise-out
This commit is contained in:
commit
596d29fba0
|
@ -33,6 +33,7 @@ module OmniAuth
|
||||||
:camelizations => {},
|
:camelizations => {},
|
||||||
:path_prefix => '/auth',
|
:path_prefix => '/auth',
|
||||||
:on_failure => OmniAuth::FailureEndpoint,
|
:on_failure => OmniAuth::FailureEndpoint,
|
||||||
|
:failure_raise_out_environments => ['development'],
|
||||||
:form_css => Form::DEFAULT_CSS,
|
:form_css => Form::DEFAULT_CSS,
|
||||||
:test_mode => false,
|
:test_mode => false,
|
||||||
:logger => default_logger,
|
:logger => default_logger,
|
||||||
|
@ -96,7 +97,7 @@ module OmniAuth
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_writer :on_failure
|
attr_writer :on_failure
|
||||||
attr_accessor :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host, :camelizations, :logger
|
attr_accessor :failure_raise_out_environments, :path_prefix, :allowed_request_methods, :form_css, :test_mode, :mock_auth, :full_host, :camelizations, :logger
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.config
|
def self.config
|
||||||
|
|
|
@ -17,7 +17,7 @@ module OmniAuth
|
||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
raise_out! if ENV['RACK_ENV'].to_s == 'development'
|
raise_out! if OmniAuth.config.failure_raise_out_environments.include?(ENV['RACK_ENV'])
|
||||||
redirect_to_failure
|
redirect_to_failure
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ require 'omniauth'
|
||||||
require 'omniauth/test'
|
require 'omniauth/test'
|
||||||
|
|
||||||
OmniAuth.config.logger = Logger.new("/dev/null")
|
OmniAuth.config.logger = Logger.new("/dev/null")
|
||||||
|
ENV['RACK_ENV'] ||= 'test'
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.include Rack::Test::Methods
|
config.include Rack::Test::Methods
|
||||||
|
|
|
@ -3,10 +3,9 @@ require 'helper'
|
||||||
describe OmniAuth::FailureEndpoint do
|
describe OmniAuth::FailureEndpoint do
|
||||||
subject{ OmniAuth::FailureEndpoint }
|
subject{ OmniAuth::FailureEndpoint }
|
||||||
|
|
||||||
context "development" do
|
context "raise-out environment" do
|
||||||
before do
|
before do
|
||||||
@rack_env = ENV['RACK_ENV']
|
@default, OmniAuth.config.failure_raise_out_environments = OmniAuth.config.failure_raise_out_environments, ['test']
|
||||||
ENV['RACK_ENV'] = 'development'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises out the error" do
|
it "raises out the error" do
|
||||||
|
@ -20,11 +19,11 @@ describe OmniAuth::FailureEndpoint do
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
ENV['RACK_ENV'] = @rack_env
|
OmniAuth.config.failure_raise_out_environments = @default
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "non-development" do
|
context "non-raise-out environment" do
|
||||||
let(:env){ {'omniauth.error.type' => 'invalid_request',
|
let(:env){ {'omniauth.error.type' => 'invalid_request',
|
||||||
'omniauth.error.strategy' => ExampleStrategy.new({}) } }
|
'omniauth.error.strategy' => ExampleStrategy.new({}) } }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue