Unfinished OpenID en Google Hybrid specs.

This commit is contained in:
Boy van Amstel 2011-07-21 18:45:53 +02:00
parent b4803075ea
commit e6a2f336be
5 changed files with 111 additions and 5 deletions

View File

@ -3,6 +3,7 @@ require File.expand_path('../lib/omniauth/version', __FILE__)
source 'http://rubygems.org'
gem 'oa-core', OmniAuth::Version::STRING, :path => '../oa-core'
gem 'oa-oauth', OmniAuth::Version::STRING, :path => '../oa-oauth'
platforms :jruby do
gem 'jruby-openssl', '~> 0.7'

View File

@ -1,6 +1,6 @@
require 'rack/openid'
require 'omniauth/openid'
require File.expand_path('../../../../../oa-oauth/lib/omniauth/oauth', __FILE__)
require 'oauth'
module OmniAuth
module Strategies

View File

@ -1,6 +1,36 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../../../../oa-oauth/lib/omniauth/oauth', __FILE__)
require 'rack/openid'
require 'omniauth/openid'
require 'oauth'
require 'openid/store/filesystem'
describe OmniAuth::Strategies::GoogleHybrid do
it "should be awesome"
describe OmniAuth::Strategies::GoogleHybrid, :type => :strategy do
include OmniAuth::Test::StrategyTestCase
def strategy
[OmniAuth::Strategies::GoogleHybrid, nil,
:name => 'google_hybrid',
:identifier => 'https://www.google.com/accounts/o8/id',
:scope => ["https://www.google.com/m8/feeds/", "https://mail.google.com/mail/feed/atom/"],
:consumer_key => '[your key here]',
:consumer_secret => '[your secret here]']
end
before do
@identifier_url = 'https://www.google.com/accounts/o8/id'
# TODO: change this mock to actually return some sort of OpenID response
stub_request(:get, @identifier_url)
end
describe 'get /auth/google_hybrid' do
before do
get '/auth/google_hybrid'
end
it 'should redirect to the Google OpenID login' do
#last_response.should be_redirect
#last_response.headers['Location'].should =~ %r{^#{@identifier_url}.*}
end
end
end

View File

@ -1,6 +1,68 @@
require File.expand_path('../../../spec_helper', __FILE__)
require 'rack/openid'
require 'omniauth/openid'
describe OmniAuth::Strategies::OpenID do
describe OmniAuth::Strategies::OpenID, :type => :strategy do
include OmniAuth::Test::StrategyTestCase
def strategy
[OmniAuth::Strategies::OpenID]
end
describe '/auth/open_id without an identifier URL' do
before do
get '/auth/open_id'
end
it 'should respond with OK' do
last_response.should be_ok
end
it 'should respond with HTML' do
last_response.content_type.should == 'text/html'
end
it 'should render an identifier URL input' do
last_response.body.should =~ %r{<input[^>]*#{OmniAuth::Strategies::OpenID::IDENTIFIER_URL_PARAMETER}}
end
end
describe '/auth/open_id with an identifier URL' do
before do
@identifier_url = 'http://openid.example.com/user'
# TODO: change this mock to actually return some sort of OpenID response
get '/auth/open_id?openid_url=' + @identifier_url
end
it 'should redirect to the OpenID identity URL' do
#last_response.should be_redirect
#last_response.headers['Location'].should =~ %r{^#{@identifier_url}.*}
end
# it 'should tell the OpenID server to return to the callback URL' do
# return_to = CGI.escape(last_request.url + '/callback')
# last_response.headers['Location'].should =~ %r{[\?&]openid.return_to=#{return_to}}
# end
end
# describe 'followed by /auth/open_id/callback' do
# before do
# @identifier_url = 'http://me.example.org'
# # TODO: change this mock to actually return some sort of OpenID response
# stub_request(:get, @identifier_url)
# get '/auth/open_id/callback'
# end
#
# sets_an_auth_hash
# sets_provider_to 'open_id'
# sets_uid_to 'http://me.example.org'
#
# it 'should call through to the master app' do
# last_response.body.should == 'true'
# end
# end
end

View File

@ -12,3 +12,16 @@ RSpec.configure do |config|
config.include Rack::Test::Methods
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
end
def strategy_class
meta = self.class.metadata
while meta.key?(:example_group)
meta = meta[:example_group]
end
meta[:describes]
end
def app
lambda{|env| [200, {}, ['Hello']]}
end