omniauth-1.1.4/ 0000755 0001750 0001750 00000000000 12132745645 012676 5 ustar ondrej ondrej omniauth-1.1.4/LICENSE.md 0000644 0001750 0001750 00000002072 12132745645 014303 0 ustar ondrej ondrej Copyright (c) 2010-2013 Michael Bleigh and Intridea, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. omniauth-1.1.4/spec/ 0000755 0001750 0001750 00000000000 12132745645 013630 5 ustar ondrej ondrej omniauth-1.1.4/spec/omniauth_spec.rb 0000644 0001750 0001750 00000006205 12132745645 017016 0 ustar ondrej ondrej require 'helper' describe OmniAuth do describe ".strategies" do it "increases when a new strategy is made" do expect{ class ExampleStrategy include OmniAuth::Strategy end }.to change(OmniAuth.strategies, :size).by(1) expect(OmniAuth.strategies.last).to eq(ExampleStrategy) end end context "configuration" do describe ".defaults" do it "is a hash of default configuration" do expect(OmniAuth::Configuration.defaults).to be_kind_of(Hash) end end it "is callable from .configure" do OmniAuth.configure do |c| expect(c).to be_kind_of(OmniAuth::Configuration) end end before do @old_path_prefix = OmniAuth.config.path_prefix @old_on_failure = OmniAuth.config.on_failure end after do OmniAuth.configure do |config| config.path_prefix = @old_path_prefix config.on_failure = @old_on_failure end end it "is able to set the path" do OmniAuth.configure do |config| config.path_prefix = '/awesome' end expect(OmniAuth.config.path_prefix).to eq('/awesome') end it "is able to set the on_failure rack app" do OmniAuth.configure do |config| config.on_failure do 'yoyo' end end expect(OmniAuth.config.on_failure.call).to eq('yoyo') end describe "mock auth" do before do OmniAuth.config.add_mock(:facebook, :uid => '12345',:info=>{:name=>'Joe', :email=>'joe@example.com'}) end it "default should be AuthHash" do OmniAuth.configure do |config| expect(config.mock_auth[:default]).to be_kind_of(OmniAuth::AuthHash) end end it "facebook should be AuthHash" do OmniAuth.configure do |config| expect(config.mock_auth[:facebook]).to be_kind_of(OmniAuth::AuthHash) end end it "sets facebook attributes" do OmniAuth.configure do |config| expect(config.mock_auth[:facebook].uid).to eq('12345') expect(config.mock_auth[:facebook].info.name).to eq('Joe') expect(config.mock_auth[:facebook].info.email).to eq('joe@example.com') end end end end describe ".logger" do it "calls through to the configured logger" do OmniAuth.stub(:config => mock(:logger => "foo")) expect(OmniAuth.logger).to eq("foo") end end describe "::Utils" do describe ".deep_merge" do it "combines hashes" do expect(OmniAuth::Utils.deep_merge({'abc' => {'def' => 123}}, {'abc' => {'foo' => 'bar'}})).to eq({'abc' => {'def' => 123, 'foo' => 'bar'}}) end end describe ".camelize" do it "works on normal cases" do { 'some_word' => 'SomeWord', 'AnotherWord' => 'AnotherWord', 'one' => 'One', 'three_words_now' => 'ThreeWordsNow' }.each_pair{ |k,v| expect(OmniAuth::Utils.camelize(k)).to eq(v) } end it "works in special cases that have been added" do OmniAuth.config.add_camelization('oauth', 'OAuth') expect(OmniAuth::Utils.camelize(:oauth)).to eq('OAuth') end end end end omniauth-1.1.4/spec/helper.rb 0000644 0001750 0001750 00000002022 12132745645 015430 0 ustar ondrej ondrej require 'simplecov' require 'coveralls' SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter ] SimpleCov.start require 'rspec' require 'rack/test' require 'omniauth' require 'omniauth/test' OmniAuth.config.logger = Logger.new("/dev/null") RSpec.configure do |config| config.include Rack::Test::Methods config.extend OmniAuth::Test::StrategyMacros, :type => :strategy config.expect_with :rspec do |c| c.syntax = :expect end end class ExampleStrategy include OmniAuth::Strategy option :name, 'test' def call(env); self.call!(env) end attr_reader :last_env def initialize(*args, &block) super @fail = nil end 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 omniauth-1.1.4/spec/omniauth/ 0000755 0001750 0001750 00000000000 12132745645 015454 5 ustar ondrej ondrej omniauth-1.1.4/spec/omniauth/failure_endpoint_spec.rb 0000644 0001750 0001750 00000003116 12132745645 022343 0 ustar ondrej ondrej require 'helper' describe OmniAuth::FailureEndpoint do subject{ OmniAuth::FailureEndpoint } context "development" do before do @rack_env = ENV['RACK_ENV'] ENV['RACK_ENV'] = 'development' end it "raises out the error" do expect do subject.call('omniauth.error' => StandardError.new("Blah")) end.to raise_error(StandardError, "Blah") end it "raises out an OmniAuth::Error if no omniauth.error is set" do expect{ subject.call('omniauth.error.type' => 'example') }.to raise_error(OmniAuth::Error, "example") end after do ENV['RACK_ENV'] = @rack_env end end context "non-development" do let(:env){ {'omniauth.error.type' => 'invalid_request', 'omniauth.error.strategy' => ExampleStrategy.new({}) } } it "is a redirect" do status, _, _ = *subject.call(env) expect(status).to eq(302) end it "includes the SCRIPT_NAME" do _, head, _ = *subject.call(env.merge('SCRIPT_NAME' => '/random')) expect(head['Location']).to eq('/random/auth/failure?message=invalid_request&strategy=test') end it "respects the configured path prefix" do OmniAuth.config.stub(:path_prefix => '/boo') _, head, _ = *subject.call(env) expect(head["Location"]).to eq('/boo/failure?message=invalid_request&strategy=test') end it "includes the origin (escaped) if one is provided" do env.merge! 'omniauth.origin' => '/origin-example' _, head, _ = *subject.call(env) expect(head['Location']).to be_include('&origin=%2Forigin-example') end end end omniauth-1.1.4/spec/omniauth/strategies/ 0000755 0001750 0001750 00000000000 12132745645 017626 5 ustar ondrej ondrej omniauth-1.1.4/spec/omniauth/strategies/developer_spec.rb 0000644 0001750 0001750 00000004046 12132745645 023156 0 ustar ondrej ondrej require 'helper' describe OmniAuth::Strategies::Developer do let(:app){ Rack::Builder.new do |b| b.use Rack::Session::Cookie, {:secret => "abc123"} b.use OmniAuth::Strategies::Developer b.run lambda{|env| [200, {}, ['Not Found']]} end.to_app } context "request phase" do before(:each){ get '/auth/developer' } it "displays a form" do expect(last_response.status).to eq(200) expect(last_response.body).to be_include("