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

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

This commit is contained in:
Bill Cromie 2013-08-16 16:47:35 -04:00
commit bb59e70168
9 changed files with 32 additions and 25 deletions

View file

@ -19,7 +19,7 @@ end
group :test do
gem 'coveralls', :require => false
gem 'rack-test'
gem 'rspec', '>= 2.11'
gem 'rspec', '>= 2.14'
gem 'simplecov', :require => false
end

View file

@ -6,7 +6,6 @@
[![Code Climate](https://codeclimate.com/github/intridea/omniauth.png)][codeclimate]
[![Coverage Status](https://coveralls.io/repos/intridea/omniauth/badge.png?branch=master)][coveralls]
[gem]: https://rubygems.org/gems/omniauth
[travis]: http://travis-ci.org/intridea/omniauth
[gemnasium]: https://gemnasium.com/intridea/omniauth
@ -93,7 +92,7 @@ steps are necessary for your application. For example, in a Rails app I
would add a line in my `routes.rb` file like this:
```ruby
match '/auth/:provider/callback', to: 'sessions#create'
get '/auth/:provider/callback', to: 'sessions#create'
```
And I might then have a `SessionsController` with code that looks
@ -143,7 +142,7 @@ your first stop if you are wondering about a more in-depth look at
OmniAuth, how it works, and how to use it.
## Supported Ruby Versions
OmniAuth is tested under 1.8.7, 1.9.2, 1.9.3, JRuby (1.8 mode), and Rubinius
OmniAuth is tested under 1.8.7, 1.9.2, 1.9.3, 2.0.0, JRuby (1.8 mode), and Rubinius
(1.8 and 1.9 modes).
## Versioning

View file

@ -244,11 +244,7 @@ module OmniAuth
end
def on_callback_path?
if options.callback_path.respond_to?(:call)
options.callback_path.call(env)
else
on_path?(callback_path)
end
on_path?(callback_path)
end
def on_path?(path)
@ -386,7 +382,10 @@ module OmniAuth
end
def callback_path
options[:callback_path].is_a?(String) ? options[:callback_path] : (custom_path(:request_path) || "#{path_prefix}/#{name}/callback")
path = options[:callback_path] if options[:callback_path].is_a?(String)
path ||= current_path if options[:callback_path].respond_to?(:call) && options[:callback_path].call(env)
path ||= custom_path(:request_path)
path ||= "#{path_prefix}/#{name}/callback"
end
def setup_path

View file

@ -1,3 +1,3 @@
module OmniAuth
VERSION = "1.1.3" unless defined?(OmniAuth::VERSION)
VERSION = "1.1.4" unless defined?(OmniAuth::VERSION)
end

View file

@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.licenses = ['MIT']
spec.name = 'omniauth'
spec.require_paths = ['lib']
spec.required_rubygems_version = '>= 1.3.6'
spec.required_rubygems_version = '>= 1.3.5'
spec.signing_key = File.expand_path("~/.gem/private_key.pem") if $0 =~ /gem\z/
spec.summary = spec.description
spec.test_files = Dir.glob("spec/**/*")

View file

@ -39,7 +39,7 @@ describe OmniAuth::FailureEndpoint do
end
it "respects the configured path prefix" do
OmniAuth.config.stub(:path_prefix => '/boo')
allow(OmniAuth.config).to receive(:path_prefix).and_return('/boo')
_, head, _ = *subject.call(env)
expect(head["Location"]).to eq('/boo/failure?message=invalid_request&strategy=test')
end

View file

@ -2,7 +2,7 @@ require 'helper'
describe OmniAuth::Strategies::Developer do
let(:app){ Rack::Builder.new do |b|
b.use Rack::Session::Cookie
b.use Rack::Session::Cookie, {:secret => "abc123"}
b.use OmniAuth::Strategies::Developer
b.run lambda{|env| [200, {}, ['Not Found']]}
end.to_app }
@ -47,7 +47,7 @@ describe OmniAuth::Strategies::Developer do
context "with custom options" do
let(:app){ Rack::Builder.new do |b|
b.use Rack::Session::Cookie
b.use Rack::Session::Cookie, {:secret => "abc123"}
b.use OmniAuth::Strategies::Developer, :fields => [:first_name, :last_name], :uid_field => :last_name
b.run lambda{|env| [200, {}, ['Not Found']]}
end.to_app }

View file

@ -152,8 +152,8 @@ describe OmniAuth::Strategy do
end
it "returns an AuthHash" do
instance.stub!(:uid).and_return('123')
instance.stub!(:info).and_return(:name => 'Hal Awesome')
allow(instance).to receive(:uid).and_return('123')
allow(instance).to receive(:info).and_return(:name => 'Hal Awesome')
hash = instance.auth_hash
expect(hash).to be_kind_of(OmniAuth::AuthHash)
expect(hash.uid).to eq('123')
@ -168,7 +168,7 @@ describe OmniAuth::Strategy do
end
it "is the default options if any are provided" do
ExampleStrategy.stub!(:default_options).and_return(OmniAuth::Strategy::Options.new(:abc => 123))
allow(ExampleStrategy).to receive(:default_options).and_return(OmniAuth::Strategy::Options.new(:abc => 123))
expect(ExampleStrategy.new(app).options.abc).to eq(123)
end
end
@ -212,8 +212,8 @@ describe OmniAuth::Strategy do
it "sets the auth hash" do
env = make_env
subject.stub!(:env).and_return(env)
subject.stub!(:auth_hash).and_return("AUTH HASH")
allow(subject).to receive(:env).and_return(env)
allow(subject).to receive(:auth_hash).and_return("AUTH HASH")
subject.callback_phase
expect(env['omniauth.auth']).to eq("AUTH HASH")
end
@ -340,7 +340,7 @@ describe OmniAuth::Strategy do
end
it "preserves the query parameters" do
strategy.stub(:full_host).and_return('http://example.com')
allow(strategy).to receive(:full_host).and_return('http://example.com')
begin
strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5'))
rescue RuntimeError; end
@ -348,7 +348,7 @@ describe OmniAuth::Strategy do
end
it "consider script name" do
strategy.stub(:full_host).and_return('http://example.com')
allow(strategy).to receive(:full_host).and_return('http://example.com')
begin
strategy.call(make_env('/auth/test', 'SCRIPT_NAME' => '/sub_uri'))
rescue RuntimeError; end
@ -384,6 +384,15 @@ describe OmniAuth::Strategy do
strategy_instance = fresh_strategy.new(nil, :request_path => lambda{|env| "/auth/boo/callback/22" })
expect(strategy_instance.callback_path).to eq('/auth/boo/callback/22')
end
it "correctly reports the callback path when the custom callback path evaluator is truthy" do
strategy_instance = ExampleStrategy.new(app,
:callback_path => lambda{|env| env['PATH_INFO'] == "/auth/bish/bosh/callback"}
)
expect{strategy_instance.call(make_env('/auth/bish/bosh/callback')) }.to raise_error("Callback Phase")
expect(strategy_instance.callback_path).to eq('/auth/bish/bosh/callback')
end
end
context "custom paths" do
@ -409,7 +418,7 @@ describe OmniAuth::Strategy do
it "preserves the query parameters" do
@options = {:callback_path => '/radical'}
strategy.stub(:full_host).and_return('http://example.com')
allow(strategy).to receive(:full_host).and_return('http://example.com')
begin
strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5'))
rescue RuntimeError; end
@ -441,7 +450,7 @@ describe OmniAuth::Strategy do
end
it "preserves the query parameters" do
strategy.stub(:full_host).and_return('http://example.com')
allow(strategy).to receive(:full_host).and_return('http://example.com')
begin
strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'id=5'))
rescue RuntimeError; end

View file

@ -108,7 +108,7 @@ describe OmniAuth do
describe ".logger" do
it "calls through to the configured logger" do
OmniAuth.stub(:config => mock(:logger => "foo"))
allow(OmniAuth).to receive(:config).and_return(double(:logger => "foo"))
expect(OmniAuth.logger).to eq("foo")
end
end