oa-oauth 0.2.6 → 0.3.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/Gemfile +4 -0
  2. data/lib/omniauth/oauth.rb +65 -47
  3. data/lib/omniauth/strategies/google_oauth2.rb +59 -0
  4. data/lib/omniauth/strategies/oauth.rb +8 -2
  5. data/lib/omniauth/strategies/oauth/blogger.rb +58 -0
  6. data/lib/omniauth/strategies/{dopplr.rb → oauth/dopplr.rb} +19 -21
  7. data/lib/omniauth/strategies/{douban.rb → oauth/douban.rb} +18 -18
  8. data/lib/omniauth/strategies/oauth/dropbox.rb +40 -0
  9. data/lib/omniauth/strategies/{evernote.rb → oauth/evernote.rb} +11 -13
  10. data/lib/omniauth/strategies/oauth/flattr.rb +47 -0
  11. data/lib/omniauth/strategies/oauth/flickr.rb +39 -0
  12. data/lib/omniauth/strategies/{goodreads.rb → oauth/goodreads.rb} +9 -9
  13. data/lib/omniauth/strategies/{google.rb → oauth/google.rb} +19 -20
  14. data/lib/omniauth/strategies/oauth/google_health.rb +71 -0
  15. data/lib/omniauth/strategies/oauth/google_health_sandbox.rb +74 -0
  16. data/lib/omniauth/strategies/oauth/hyves.rb +69 -0
  17. data/lib/omniauth/strategies/{identica.rb → oauth/identica.rb} +20 -16
  18. data/lib/omniauth/strategies/{linked_in.rb → oauth/linked_in.rb} +14 -14
  19. data/lib/omniauth/strategies/{meetup.rb → oauth/meetup.rb} +18 -16
  20. data/lib/omniauth/strategies/{miso.rb → oauth/miso.rb} +14 -7
  21. data/lib/omniauth/strategies/{netflix.rb → oauth/netflix.rb} +16 -14
  22. data/lib/omniauth/strategies/oauth/orkut.rb +63 -0
  23. data/lib/omniauth/strategies/oauth/plurk.rb +57 -0
  24. data/lib/omniauth/strategies/{qzone.rb → oauth/qzone.rb} +15 -12
  25. data/lib/omniauth/strategies/oauth/rdio.rb +48 -0
  26. data/lib/omniauth/strategies/oauth/smug_mug.rb +47 -0
  27. data/lib/omniauth/strategies/{t163.rb → oauth/t163.rb} +17 -17
  28. data/lib/omniauth/strategies/oauth/tqq.rb +63 -0
  29. data/lib/omniauth/strategies/oauth/trade_me.rb +50 -0
  30. data/lib/omniauth/strategies/oauth/trip_it.rb +24 -0
  31. data/lib/omniauth/strategies/{tsina.rb → oauth/tsina.rb} +21 -15
  32. data/lib/omniauth/strategies/{tsohu.rb → oauth/tsohu.rb} +15 -17
  33. data/lib/omniauth/strategies/{tumblr.rb → oauth/tumblr.rb} +13 -15
  34. data/lib/omniauth/strategies/{twitter.rb → oauth/twitter.rb} +17 -16
  35. data/lib/omniauth/strategies/{type_pad.rb → oauth/type_pad.rb} +18 -27
  36. data/lib/omniauth/strategies/{vimeo.rb → oauth/vimeo.rb} +18 -14
  37. data/lib/omniauth/strategies/{yahoo.rb → oauth/yahoo.rb} +17 -12
  38. data/lib/omniauth/strategies/{yammer.rb → oauth/yammer.rb} +17 -12
  39. data/lib/omniauth/strategies/{you_tube.rb → oauth/you_tube.rb} +16 -14
  40. data/lib/omniauth/strategies/oauth2.rb +7 -5
  41. data/lib/omniauth/strategies/oauth2/angellist.rb +57 -0
  42. data/lib/omniauth/strategies/oauth2/bitly.rb +43 -0
  43. data/lib/omniauth/strategies/oauth2/cobot.rb +54 -0
  44. data/lib/omniauth/strategies/{dailymile.rb → oauth2/dailymile.rb} +19 -20
  45. data/lib/omniauth/strategies/{doit.rb → oauth2/doit.rb} +18 -18
  46. data/lib/omniauth/strategies/{facebook.rb → oauth2/facebook.rb} +38 -21
  47. data/lib/omniauth/strategies/{foursquare.rb → oauth2/foursquare.rb} +20 -19
  48. data/lib/omniauth/strategies/{github.rb → oauth2/github.rb} +21 -19
  49. data/lib/omniauth/strategies/oauth2/glitch.rb +45 -0
  50. data/lib/omniauth/strategies/oauth2/gowalla.rb +72 -0
  51. data/lib/omniauth/strategies/{instagram.rb → oauth2/instagram.rb} +19 -17
  52. data/lib/omniauth/strategies/oauth2/liveid.rb +67 -0
  53. data/lib/omniauth/strategies/oauth2/mailchimp.rb +39 -0
  54. data/lib/omniauth/strategies/oauth2/mailru.rb +75 -0
  55. data/lib/omniauth/strategies/{mixi.rb → oauth2/mixi.rb} +23 -18
  56. data/lib/omniauth/strategies/{renren.rb → oauth2/renren.rb} +25 -23
  57. data/lib/omniauth/strategies/oauth2/salesforce.rb +48 -0
  58. data/lib/omniauth/strategies/oauth2/sound_cloud.rb +60 -0
  59. data/lib/omniauth/strategies/{taobao.rb → oauth2/taobao.rb} +24 -22
  60. data/lib/omniauth/strategies/{teambox.rb → oauth2/teambox.rb} +19 -17
  61. data/lib/omniauth/strategies/{thirty_seven_signals.rb → oauth2/thirty_seven_signals.rb} +17 -17
  62. data/lib/omniauth/strategies/oauth2/viadeo.rb +72 -0
  63. data/lib/omniauth/strategies/oauth2/vkontakte.rb +104 -0
  64. data/lib/omniauth/strategies/oauth2/we_pay.rb +48 -0
  65. data/lib/omniauth/strategies/xauth.rb +3 -3
  66. data/lib/omniauth/strategies/{instapaper.rb → xauth/instapaper.rb} +9 -12
  67. data/lib/omniauth/version.rb +3 -3
  68. data/oa-oauth.gemspec +17 -18
  69. data/spec/omniauth/strategies/{bitly_spec.rb → google_oauth2_spec.rb} +1 -1
  70. data/spec/omniauth/strategies/{dopplr_spec.rb → oauth/dopplr_spec.rb} +1 -1
  71. data/spec/omniauth/strategies/{douban_spec.rb → oauth/douban_spec.rb} +1 -1
  72. data/spec/omniauth/strategies/oauth/dropbox_spec.rb +5 -0
  73. data/spec/omniauth/strategies/{evernote_spec.rb → oauth/evernote_spec.rb} +1 -1
  74. data/spec/omniauth/strategies/oauth/flattr_spec.rb +5 -0
  75. data/spec/omniauth/strategies/oauth/flickr_spec.rb +6 -0
  76. data/spec/omniauth/strategies/{goodreads_spec.rb → oauth/goodreads_spec.rb} +1 -1
  77. data/spec/omniauth/strategies/oauth/google_health_sandbox_spec.rb +5 -0
  78. data/spec/omniauth/strategies/oauth/google_health_spec.rb +5 -0
  79. data/spec/omniauth/strategies/{google_spec.rb → oauth/google_spec.rb} +1 -1
  80. data/spec/omniauth/strategies/{hyves_spec.rb → oauth/hyves_spec.rb} +1 -1
  81. data/spec/omniauth/strategies/{identica_spec.rb → oauth/identica_spec.rb} +1 -1
  82. data/spec/omniauth/strategies/{linked_in_spec.rb → oauth/linked_in_spec.rb} +1 -1
  83. data/spec/omniauth/strategies/{meetup_spec.rb → oauth/meetup_spec.rb} +3 -3
  84. data/spec/omniauth/strategies/{miso_spec.rb → oauth/miso_spec.rb} +1 -1
  85. data/spec/omniauth/strategies/{netflix_spec.rb → oauth/netflix_spec.rb} +1 -1
  86. data/spec/omniauth/strategies/oauth/oauth_spec.rb +131 -0
  87. data/spec/omniauth/strategies/oauth/orkut_spec.rb +5 -0
  88. data/spec/omniauth/strategies/{plurk_spec.rb → oauth/plurk_spec.rb} +1 -1
  89. data/spec/omniauth/strategies/{rdio_spec.rb → oauth/rdio_spec.rb} +1 -1
  90. data/spec/omniauth/strategies/{smug_mug_spec.rb → oauth/smug_mug_spec.rb} +1 -1
  91. data/spec/omniauth/strategies/{t163_spec.rb → oauth/t163_spec.rb} +1 -1
  92. data/spec/omniauth/strategies/{trade_me_spec.rb → oauth/trade_me_spec.rb} +1 -1
  93. data/spec/omniauth/strategies/{trip_it_spec.rb → oauth/trip_it_spec.rb} +1 -1
  94. data/spec/omniauth/strategies/{tsina_spec.rb → oauth/tsina_spec.rb} +1 -1
  95. data/spec/omniauth/strategies/{tumblr_spec.rb → oauth/tumblr_spec.rb} +1 -1
  96. data/spec/omniauth/strategies/oauth/twitter_spec.rb +43 -0
  97. data/spec/omniauth/strategies/{type_pad_spec.rb → oauth/type_pad_spec.rb} +1 -1
  98. data/spec/omniauth/strategies/{vimeo_spec.rb → oauth/vimeo_spec.rb} +1 -1
  99. data/spec/omniauth/strategies/{yahoo_spec.rb → oauth/yahoo_spec.rb} +1 -1
  100. data/spec/omniauth/strategies/{yammer_spec.rb → oauth/yammer_spec.rb} +1 -1
  101. data/spec/omniauth/strategies/{you_tube_spec.rb → oauth/you_tube_spec.rb} +1 -1
  102. data/spec/omniauth/strategies/oauth2/angellist_spec.rb +5 -0
  103. data/spec/omniauth/strategies/oauth2/bitly_spec.rb +5 -0
  104. data/spec/omniauth/strategies/oauth2/cobot_spec.rb +5 -0
  105. data/spec/omniauth/strategies/{dailymile_spec.rb → oauth2/dailymile_spec.rb} +1 -1
  106. data/spec/omniauth/strategies/{doit_spec.rb → oauth2/doit_spec.rb} +1 -1
  107. data/spec/omniauth/strategies/{facebook_spec.rb → oauth2/facebook_spec.rb} +1 -1
  108. data/spec/omniauth/strategies/{foursquare_spec.rb → oauth2/foursquare_spec.rb} +1 -1
  109. data/spec/omniauth/strategies/{github_spec.rb → oauth2/github_spec.rb} +1 -1
  110. data/spec/omniauth/strategies/oauth2/glitch_spec.rb +5 -0
  111. data/spec/omniauth/strategies/{gowalla_spec.rb → oauth2/gowalla_spec.rb} +1 -1
  112. data/spec/omniauth/strategies/oauth2/instagram_spec.rb +5 -0
  113. data/spec/omniauth/strategies/oauth2/liveid_spec.rb +5 -0
  114. data/spec/omniauth/strategies/oauth2/mailchimp_spec.rb +6 -0
  115. data/spec/omniauth/strategies/{mailru_spec.rb → oauth2/mailru_spec.rb} +1 -1
  116. data/spec/omniauth/strategies/{salesforce_spec.rb → oauth2/salesforce_spec.rb} +1 -1
  117. data/spec/omniauth/strategies/oauth2/sound_cloud_spec.rb +5 -0
  118. data/spec/omniauth/strategies/oauth2/taobao_spec.rb +5 -0
  119. data/spec/omniauth/strategies/{teambox_spec.rb → oauth2/teambox_spec.rb} +1 -1
  120. data/spec/omniauth/strategies/{thirty_seven_signals_spec.rb → oauth2/thirty_seven_signals_spec.rb} +1 -1
  121. data/spec/omniauth/strategies/oauth2/viadeo_spec.rb +5 -0
  122. data/spec/omniauth/strategies/{vkontakte_spec.rb → oauth2/vkontakte_spec.rb} +1 -1
  123. data/spec/omniauth/strategies/oauth2/we_pay_spec.rb +5 -0
  124. data/spec/spec_helper.rb +4 -0
  125. metadata +277 -151
  126. data/lib/omniauth/strategies/bitly.rb +0 -46
  127. data/lib/omniauth/strategies/gowalla.rb +0 -72
  128. data/lib/omniauth/strategies/hyves.rb +0 -67
  129. data/lib/omniauth/strategies/mailru.rb +0 -107
  130. data/lib/omniauth/strategies/plurk.rb +0 -58
  131. data/lib/omniauth/strategies/rdio.rb +0 -45
  132. data/lib/omniauth/strategies/salesforce.rb +0 -44
  133. data/lib/omniauth/strategies/smug_mug.rb +0 -42
  134. data/lib/omniauth/strategies/sound_cloud.rb +0 -46
  135. data/lib/omniauth/strategies/tqq.rb +0 -64
  136. data/lib/omniauth/strategies/trade_me.rb +0 -45
  137. data/lib/omniauth/strategies/trip_it.rb +0 -22
  138. data/lib/omniauth/strategies/vkontakte.rb +0 -87
  139. data/spec/omniauth/strategies/oauth2_spec.rb +0 -0
  140. data/spec/omniauth/strategies/oauth_spec.rb +0 -77
  141. data/spec/omniauth/strategies/sound_cloud_spec.rb +0 -5
  142. data/spec/omniauth/strategies/taobao_spec.rb +0 -5
  143. data/spec/omniauth/strategies/twitter_spec.rb +0 -20
@@ -0,0 +1,48 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ # OAuth 2.0 based authentication with WePay. In order to
7
+ # sign up for an application, you need to [register an application](https://wepay.com/developer/register)
8
+ # and provide the proper credentials to this middleware.
9
+ class WePay < OmniAuth::Strategies::OAuth2
10
+ # @param [Rack Application] app standard middleware application argument
11
+ # @param [String] client_id the application ID for your client
12
+ # @param [String] client_secret the application secret
13
+ def initialize(app, client_id=nil, client_secret=nil, options={}, &block)
14
+ client_options = {
15
+ :authorize_url => 'https://www.wepay.com/session/authorize',
16
+ :token_url => 'https://wepayapi.com/v1/oauth2/token',
17
+ }
18
+ super(app, :we_pay, client_id, client_secret, client_options, options, &block)
19
+ end
20
+
21
+ def auth_hash
22
+ OmniAuth::Utils.deep_merge(
23
+ super, {
24
+ 'uid' => user_data['user_id'],
25
+ 'user_info' => user_info,
26
+ 'extra' => {
27
+ 'user_hash' => user_data,
28
+ },
29
+ }
30
+ )
31
+ end
32
+
33
+ def user_data
34
+ @data ||= MultiJson.decode(@access_token.get('/v1/user'))['result']
35
+ end
36
+
37
+ def user_info
38
+ {
39
+ 'email' => user_data['email'],
40
+ 'name' => "#{user_data['firstName']} #{user_data['lastName']}".strip,
41
+ 'first_name' => user_data['firstName'],
42
+ 'last_name' => user_data['lastName'],
43
+ 'image' => user_data['picture'],
44
+ }
45
+ end
46
+ end
47
+ end
48
+ end
@@ -4,12 +4,12 @@ require 'multi_json'
4
4
  module OmniAuth
5
5
  module Strategies
6
6
  class XAuth
7
- include OmniAuth::Strategy
8
-
9
7
  attr_reader :name
10
8
  attr_accessor :consumer_key, :consumer_secret, :consumer_options
11
9
 
12
- def initialize(app, name, consumer_key = nil, consumer_secret = nil, consumer_options = {}, options = {}, &block)
10
+ include OmniAuth::Strategy
11
+
12
+ def initialize(app, name, consumer_key=nil, consumer_secret=nil, consumer_options={}, options={}, &block)
13
13
  self.consumer_key = consumer_key
14
14
  self.consumer_secret = consumer_secret
15
15
  self.consumer_options = consumer_options
@@ -4,18 +4,13 @@ require 'multi_json'
4
4
  module OmniAuth
5
5
  module Strategies
6
6
  class Instapaper < OmniAuth::Strategies::XAuth
7
-
8
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
7
+ def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block)
9
8
  client_options = {
10
- :title => 'Instapaper',
11
- :site => 'https://www.instapaper.com',
12
- :access_token_path => '/api/1/oauth/access_token'
9
+ :token_url => 'https://www.instapaper.com/api/1/oauth/access_token',
13
10
  }
14
11
  super(app, :instapaper, consumer_key, consumer_secret, client_options, options, &block)
15
12
  end
16
13
 
17
- protected
18
-
19
14
  def user_data
20
15
  @data ||= MultiJson.decode(@access_token.get('/api/1/account/verify_credentials').body)[0]
21
16
  end
@@ -23,15 +18,17 @@ module OmniAuth
23
18
  def user_info
24
19
  {
25
20
  'nickname' => user_data['username'],
26
- 'name' => user_data['username']
21
+ 'name' => user_data['username'],
27
22
  }
28
23
  end
29
24
 
30
25
  def auth_hash
31
- OmniAuth::Utils.deep_merge(super, {
32
- 'uid' => user_data['user_id'],
33
- 'user_info' => user_info
34
- })
26
+ OmniAuth::Utils.deep_merge(super,
27
+ {
28
+ 'uid' => user_data['user_id'],
29
+ 'user_info' => user_info,
30
+ }
31
+ )
35
32
  end
36
33
 
37
34
  end
@@ -4,13 +4,13 @@ module OmniAuth
4
4
  MAJOR = 0
5
5
  end
6
6
  unless defined?(::OmniAuth::Version::MINOR)
7
- MINOR = 2
7
+ MINOR = 3
8
8
  end
9
9
  unless defined?(::OmniAuth::Version::PATCH)
10
- PATCH = 6
10
+ PATCH = 0
11
11
  end
12
12
  unless defined?(::OmniAuth::Version::PRE)
13
- PRE = nil
13
+ PRE = "rc3"
14
14
  end
15
15
  unless defined?(::OmniAuth::Version::STRING)
16
16
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
data/oa-oauth.gemspec CHANGED
@@ -1,32 +1,31 @@
1
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
2
2
  require File.expand_path('../lib/omniauth/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.add_runtime_dependency 'faraday', '~> 0.6.1'
6
- gem.add_runtime_dependency 'multi_json', '~> 1.0.0'
7
- gem.add_runtime_dependency 'multi_xml', '~> 0.2.2'
8
- gem.add_runtime_dependency 'oa-core', OmniAuth::Version::STRING
9
- gem.add_runtime_dependency 'oauth', '~> 0.4.0'
10
- gem.add_runtime_dependency 'oauth2', '~> 0.4.1'
11
- gem.add_development_dependency 'evernote', '~> 0.9'
12
- gem.add_development_dependency 'maruku', '~> 0.6'
5
+ gem.add_dependency 'faraday', '~> 0.7.3'
6
+ gem.add_dependency 'multi_json', '~> 1.0.0'
7
+ gem.add_dependency 'multi_xml', '~> 0.3.0'
8
+ gem.add_dependency 'oa-core', OmniAuth::Version::STRING
9
+ gem.add_dependency 'oauth', '~> 0.4.0'
10
+ gem.add_dependency 'oauth2', '~> 0.5.0'
11
+ gem.add_development_dependency 'evernote', '~> 1.0'
13
12
  gem.add_development_dependency 'rack-test', '~> 0.5'
14
13
  gem.add_development_dependency 'rake', '~> 0.8'
14
+ gem.add_development_dependency 'rdiscount', '~> 1.6'
15
15
  gem.add_development_dependency 'rspec', '~> 2.5'
16
16
  gem.add_development_dependency 'simplecov', '~> 0.4'
17
- gem.add_development_dependency 'webmock', '~> 1.6'
17
+ gem.add_development_dependency 'vcr', '~> 1.10'
18
+ gem.add_development_dependency 'webmock', '~> 1.7'
18
19
  gem.add_development_dependency 'yard', '~> 0.7'
19
- gem.add_development_dependency 'ZenTest', '~> 4.5'
20
- gem.name = 'oa-oauth'
21
- gem.version = OmniAuth::Version::STRING
20
+ gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
22
21
  gem.description = %q{OAuth strategies for OmniAuth.}
23
- gem.summary = gem.description
24
22
  gem.email = ['michael@intridea.com', 'sferik@gmail.com']
25
- gem.homepage = 'http://github.com/intridea/omniauth'
26
- gem.authors = ['Michael Bleigh', 'Erik Michaels-Ober']
27
- gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
28
23
  gem.files = `git ls-files`.split("\n")
29
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
+ gem.homepage = 'http://github.com/intridea/omniauth'
25
+ gem.name = 'oa-oauth'
30
26
  gem.require_paths = ['lib']
31
27
  gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
28
+ gem.summary = gem.description
29
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
30
+ gem.version = OmniAuth::Version::STRING
32
31
  end
@@ -1,5 +1,5 @@
1
1
  require File.expand_path('../../../spec_helper', __FILE__)
2
2
 
3
- describe OmniAuth::Strategies::Bitly do
3
+ describe OmniAuth::Strategies::GoogleOAuth2 do
4
4
  it_should_behave_like "an oauth2 strategy"
5
5
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Dopplr do
4
4
  it_should_behave_like "an oauth strategy"
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Douban do
4
4
  it_should_behave_like 'an oauth strategy'
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Dropbox do
4
+ it_should_behave_like "an oauth strategy"
5
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Evernote do
4
4
  it_should_behave_like "an oauth strategy"
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Flattr do
4
+ it_should_behave_like 'an oauth strategy'
5
+ end
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Flickr do
4
+ it_should_behave_like "an oauth strategy"
5
+ end
6
+
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Goodreads do
4
4
  it_should_behave_like 'an oauth strategy'
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::GoogleHealthSandbox do
4
+ it_should_behave_like 'an oauth strategy'
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::GoogleHealth do
4
+ it_should_behave_like 'an oauth strategy'
5
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Google do
4
4
  it_should_behave_like 'an oauth strategy'
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Hyves do
4
4
  it_should_behave_like "an oauth strategy"
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Identica do
4
4
  it_should_behave_like 'an oauth strategy'
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::LinkedIn do
4
4
  it_should_behave_like "an oauth strategy"
@@ -1,13 +1,13 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Meetup do
4
4
  it_should_behave_like 'an oauth strategy'
5
- it 'should use the authenticate (sign in) path by default' do
5
+ it 'should use the authenticate (sign in) URL by default' do
6
6
  s = strategy_class.new(app, 'abc', 'def')
7
7
  s.consumer.options[:authorize_path].should == 'http://www.meetup.com/authenticate'
8
8
  end
9
9
 
10
- it 'should use the authorize path if :sign_in is false' do
10
+ it 'should use the authorize URL if :sign_in is false' do
11
11
  s = strategy_class.new(app, 'abc', 'def', :sign_in => false)
12
12
  s.consumer.options[:authorize_path].should == 'http://www.meetup.com/authorize'
13
13
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Miso do
4
4
  it_should_behave_like 'an oauth strategy'
@@ -1,4 +1,4 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
1
+ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::Strategies::Netflix do
4
4
  it_should_behave_like "an oauth strategy"
@@ -0,0 +1,131 @@
1
+ require 'spec_helper'
2
+
3
+ describe "OmniAuth::Strategies::OAuth" do
4
+
5
+ def app
6
+ Rack::Builder.new {
7
+ use OmniAuth::Test::PhonySession
8
+ use OmniAuth::Builder do
9
+ provider :oauth, 'example.org', 'abc', 'def', :site => 'https://api.example.org'
10
+ provider :oauth, 'example.org_with_authorize_params', 'abc', 'def', { :site => 'https://api.example.org' }, :authorize_params => {:abc => 'def'}
11
+ end
12
+ run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
13
+ }.to_app
14
+ end
15
+
16
+ def session
17
+ last_request.env['rack.session']
18
+ end
19
+
20
+ before do
21
+ stub_request(:post, 'https://api.example.org/oauth/request_token').
22
+ to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret&oauth_callback_confirmed=true")
23
+ end
24
+
25
+ describe '/auth/{name}' do
26
+ context 'successful' do
27
+ before do
28
+ get '/auth/example.org'
29
+ end
30
+ it 'should redirect to authorize_url' do
31
+ last_response.should be_redirect
32
+ last_response.headers['Location'].should == 'https://api.example.org/oauth/authorize?oauth_token=yourtoken'
33
+ end
34
+
35
+ it 'should redirect to authorize_url with authorize_params when set' do
36
+ get '/auth/example.org_with_authorize_params'
37
+ last_response.should be_redirect
38
+ [
39
+ 'https://api.example.org/oauth/authorize?abc=def&oauth_token=yourtoken',
40
+ 'https://api.example.org/oauth/authorize?oauth_token=yourtoken&abc=def'
41
+ ].should be_include(last_response.headers['Location'])
42
+ end
43
+
44
+ it 'should set appropriate session variables' do
45
+ session['oauth'].should == {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}
46
+ end
47
+ end
48
+
49
+ context 'unsuccessful' do
50
+ before do
51
+ stub_request(:post, 'https://api.example.org/oauth/request_token').
52
+ to_raise(::Net::HTTPFatalError.new(%Q{502 "Bad Gateway"}, nil))
53
+ get '/auth/example.org'
54
+ end
55
+
56
+ it 'should call fail! with :service_unavailable' do
57
+ last_request.env['omniauth.error'].should be_kind_of(::Net::HTTPFatalError)
58
+ last_request.env['omniauth.error.type'] = :service_unavailable
59
+ end
60
+
61
+ context "SSL failure" do
62
+ before do
63
+ stub_request(:post, 'https://api.example.org/oauth/request_token').
64
+ to_raise(::OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"))
65
+ get '/auth/example.org'
66
+ end
67
+
68
+ it 'should call fail! with :service_unavailable' do
69
+ last_request.env['omniauth.error'].should be_kind_of(::OpenSSL::SSL::SSLError)
70
+ last_request.env['omniauth.error.type'] = :service_unavailable
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ describe '/auth/{name}/callback' do
77
+ before do
78
+ stub_request(:post, 'https://api.example.org/oauth/access_token').
79
+ to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret")
80
+ get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
81
+ end
82
+
83
+ it 'should exchange the request token for an access token' do
84
+ last_request.env['omniauth.auth']['provider'].should == 'example.org'
85
+ last_request.env['omniauth.auth']['extra']['access_token'].should be_kind_of(OAuth::AccessToken)
86
+ end
87
+
88
+ it 'should call through to the master app' do
89
+ last_response.body.should == 'true'
90
+ end
91
+
92
+ context "bad gateway (or any 5xx) for access_token" do
93
+ before do
94
+ stub_request(:post, 'https://api.example.org/oauth/access_token').
95
+ to_raise(::Net::HTTPFatalError.new(%Q{502 "Bad Gateway"}, nil))
96
+ get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
97
+ end
98
+
99
+ it 'should call fail! with :service_unavailable' do
100
+ last_request.env['omniauth.error'].should be_kind_of(::Net::HTTPFatalError)
101
+ last_request.env['omniauth.error.type'] = :service_unavailable
102
+ end
103
+ end
104
+
105
+ context "SSL failure" do
106
+ before do
107
+ stub_request(:post, 'https://api.example.org/oauth/access_token').
108
+ to_raise(::OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"))
109
+ get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
110
+ end
111
+
112
+ it 'should call fail! with :service_unavailable' do
113
+ last_request.env['omniauth.error'].should be_kind_of(::OpenSSL::SSL::SSLError)
114
+ last_request.env['omniauth.error.type'] = :service_unavailable
115
+ end
116
+ end
117
+ end
118
+
119
+ describe '/auth/{name}/callback with expired session' do
120
+ before do
121
+ stub_request(:post, 'https://api.example.org/oauth/access_token').
122
+ to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret")
123
+ get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {}}
124
+ end
125
+
126
+ it 'should call fail! with :session_expired' do
127
+ last_request.env['omniauth.error'].should be_kind_of(::OmniAuth::NoSessionError)
128
+ last_request.env['omniauth.error.type'] = :session_expired
129
+ end
130
+ end
131
+ end