omniauth-hackid 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +8 -0
- data/.travis.yml +8 -0
- data/Gemfile +5 -0
- data/README.md +102 -0
- data/Rakefile +8 -0
- data/example/Gemfile +5 -0
- data/example/Gemfile.lock +53 -0
- data/example/config.ru +36 -0
- data/lib/omniauth-hackid.rb +1 -0
- data/lib/omniauth/hackid.rb +2 -0
- data/lib/omniauth/hackid/version.rb +5 -0
- data/lib/omniauth/strategies/hackid.rb +223 -0
- data/omniauth-hackid.gemspec +23 -0
- data/test/access_token_options_test.rb +9 -0
- data/test/authorize_params_test.rb +24 -0
- data/test/build_access_token_test.rb +48 -0
- data/test/callback_url_test.rb +23 -0
- data/test/client_test.rb +14 -0
- data/test/credentials_test.rb +51 -0
- data/test/extra_test.rb +15 -0
- data/test/helper.rb +58 -0
- data/test/info_test.rb +132 -0
- data/test/raw_info_test.rb +37 -0
- data/test/signed_request_test.rb +109 -0
- data/test/strategy_test.rb +3 -0
- data/test/support/shared_examples.rb +85 -0
- data/test/test.rb +162 -0
- data/test/token_params_test.rb +5 -0
- data/test/uid_test.rb +10 -0
- metadata +138 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
3
|
+
require 'omniauth/hackid/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = 'omniauth-hackid'
|
|
7
|
+
s.version = OmniAuth::HackID::VERSION
|
|
8
|
+
s.authors = ['Steve Yadlowsky']
|
|
9
|
+
s.email = ['grizlo42@gmail.com']
|
|
10
|
+
s.summary = 'HackID strategy for OmniAuth'
|
|
11
|
+
s.homepage = 'https://github.com/grizlo42/omniauth-hackid'
|
|
12
|
+
|
|
13
|
+
s.files = `git ls-files`.split("\n")
|
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
16
|
+
s.require_paths = ['lib']
|
|
17
|
+
|
|
18
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
|
|
19
|
+
|
|
20
|
+
s.add_development_dependency 'minitest'
|
|
21
|
+
s.add_development_dependency 'mocha'
|
|
22
|
+
s.add_development_dependency 'rake'
|
|
23
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
class AccessTokenOptionsTest < StrategyTestCase
|
|
2
|
+
test 'has correct param name by default' do
|
|
3
|
+
assert_equal 'access_token', strategy.access_token_options[:param_name]
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
test 'has correct header format by default' do
|
|
7
|
+
assert_equal 'OAuth %s', strategy.access_token_options[:header_format]
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class AuthorizeParamsTest < StrategyTestCase
|
|
2
|
+
test 'includes default scope for email' do
|
|
3
|
+
assert strategy.authorize_params.is_a?(Hash)
|
|
4
|
+
assert_equal 'email', strategy.authorize_params[:scope]
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
test 'includes display parameter from request when present' do
|
|
8
|
+
@request.stubs(:params).returns({ 'display' => 'touch' })
|
|
9
|
+
assert strategy.authorize_params.is_a?(Hash)
|
|
10
|
+
assert_equal 'touch', strategy.authorize_params[:display]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
test 'includes state parameter from request when present' do
|
|
14
|
+
@request.stubs(:params).returns({ 'state' => 'some_state' })
|
|
15
|
+
assert strategy.authorize_params.is_a?(Hash)
|
|
16
|
+
assert_equal 'some_state', strategy.authorize_params[:state]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test 'overrides default scope with parameter passed from request' do
|
|
20
|
+
@request.stubs(:params).returns({ 'scope' => 'email' })
|
|
21
|
+
assert strategy.authorize_params.is_a?(Hash)
|
|
22
|
+
assert_equal 'email', strategy.authorize_params[:scope]
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module BuildAccessTokenTests
|
|
2
|
+
class TestCase < StrategyTestCase
|
|
3
|
+
include SignedRequestHelpers
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class ParamsContainSignedRequestWithAccessTokenTest < TestCase
|
|
7
|
+
def setup
|
|
8
|
+
super
|
|
9
|
+
|
|
10
|
+
@payload = {
|
|
11
|
+
'algorithm' => 'HMAC-SHA256',
|
|
12
|
+
'oauth_token' => 'm4c0d3z',
|
|
13
|
+
'expires' => Time.now.to_i
|
|
14
|
+
}
|
|
15
|
+
@raw_signed_request = signed_request(@payload, @client_secret)
|
|
16
|
+
@request.stubs(:params).returns({"signed_request" => @raw_signed_request})
|
|
17
|
+
|
|
18
|
+
strategy.stubs(:callback_url).returns('/')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test 'returns a new access token from the signed request' do
|
|
22
|
+
result = strategy.build_access_token
|
|
23
|
+
assert_kind_of ::OAuth2::AccessToken, result
|
|
24
|
+
assert_equal @payload['oauth_token'], result.token
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
test 'returns an access token with the correct expiry time' do
|
|
28
|
+
result = strategy.build_access_token
|
|
29
|
+
assert_equal @payload['expires'], result.expires_at
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class ParamsContainAccessTokenStringTest < TestCase
|
|
34
|
+
def setup
|
|
35
|
+
super
|
|
36
|
+
|
|
37
|
+
@request.stubs(:params).returns({'access_token' => 'm4c0d3z'})
|
|
38
|
+
|
|
39
|
+
strategy.stubs(:callback_url).returns('/')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
test 'returns a new access token' do
|
|
43
|
+
result = strategy.build_access_token
|
|
44
|
+
assert_kind_of ::OAuth2::AccessToken, result
|
|
45
|
+
assert_equal 'm4c0d3z', result.token
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class CallbackUrlTest < StrategyTestCase
|
|
2
|
+
test "returns the default callback url" do
|
|
3
|
+
url_base = 'http://auth.request.com'
|
|
4
|
+
@request.stubs(:url).returns("#{url_base}/some/page")
|
|
5
|
+
strategy.stubs(:script_name).returns('') # as not to depend on Rack env
|
|
6
|
+
assert_equal "#{url_base}/auth/facebook/callback", strategy.callback_url
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test "returns path from callback_path option" do
|
|
10
|
+
@options = { :callback_path => "/auth/FB/done"}
|
|
11
|
+
url_base = 'http://auth.request.com'
|
|
12
|
+
@request.stubs(:url).returns("#{url_base}/page/path")
|
|
13
|
+
strategy.stubs(:script_name).returns('') # as not to depend on Rack env
|
|
14
|
+
assert_equal "#{url_base}/auth/FB/done", strategy.callback_url
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
test "returns url from callback_url option" do
|
|
18
|
+
url = 'https://auth.myapp.com/auth/fb/callback'
|
|
19
|
+
@options = { :callback_url => url }
|
|
20
|
+
assert_equal url, strategy.callback_url
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
data/test/client_test.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class ClientTest < StrategyTestCase
|
|
2
|
+
test 'has correct Facebook site' do
|
|
3
|
+
assert_equal 'https://hackid.herokuapp.com', strategy.client.site
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
test 'has correct authorize url' do
|
|
7
|
+
assert_equal '/oauth/authorize', strategy.client.options[:authorize_url]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test 'has correct token url' do
|
|
11
|
+
assert_equal '/oauth/access_token', strategy.client.options[:token_url]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
class CredentialsTest < StrategyTestCase
|
|
2
|
+
def setup
|
|
3
|
+
super
|
|
4
|
+
@access_token = stub('OAuth2::AccessToken')
|
|
5
|
+
@access_token.stubs(:token)
|
|
6
|
+
@access_token.stubs(:expires?)
|
|
7
|
+
@access_token.stubs(:expires_at)
|
|
8
|
+
@access_token.stubs(:refresh_token)
|
|
9
|
+
strategy.stubs(:access_token).returns(@access_token)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
test 'returns a Hash' do
|
|
13
|
+
assert_kind_of Hash, strategy.credentials
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
test 'returns the token' do
|
|
17
|
+
@access_token.stubs(:token).returns('123')
|
|
18
|
+
assert_equal '123', strategy.credentials['token']
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
test 'returns the expiry status' do
|
|
22
|
+
@access_token.stubs(:expires?).returns(true)
|
|
23
|
+
assert strategy.credentials['expires']
|
|
24
|
+
|
|
25
|
+
@access_token.stubs(:expires?).returns(false)
|
|
26
|
+
refute strategy.credentials['expires']
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test 'returns the refresh token and expiry time when expiring' do
|
|
30
|
+
ten_mins_from_now = (Time.now + 600).to_i
|
|
31
|
+
@access_token.stubs(:expires?).returns(true)
|
|
32
|
+
@access_token.stubs(:refresh_token).returns('321')
|
|
33
|
+
@access_token.stubs(:expires_at).returns(ten_mins_from_now)
|
|
34
|
+
assert_equal '321', strategy.credentials['refresh_token']
|
|
35
|
+
assert_equal ten_mins_from_now, strategy.credentials['expires_at']
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test 'does not return the refresh token when test is nil and expiring' do
|
|
39
|
+
@access_token.stubs(:expires?).returns(true)
|
|
40
|
+
@access_token.stubs(:refresh_token).returns(nil)
|
|
41
|
+
assert_nil strategy.credentials['refresh_token']
|
|
42
|
+
refute_has_key 'refresh_token', strategy.credentials
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
test 'does not return the refresh token when not expiring' do
|
|
46
|
+
@access_token.stubs(:expires?).returns(false)
|
|
47
|
+
@access_token.stubs(:refresh_token).returns('XXX')
|
|
48
|
+
assert_nil strategy.credentials['refresh_token']
|
|
49
|
+
refute_has_key 'refresh_token', strategy.credentials
|
|
50
|
+
end
|
|
51
|
+
end
|
data/test/extra_test.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class ExtraTest < StrategyTestCase
|
|
2
|
+
def setup
|
|
3
|
+
super
|
|
4
|
+
@raw_info = { 'name' => 'Fred Smith' }
|
|
5
|
+
strategy.stubs(:raw_info).returns(@raw_info)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
test 'returns a Hash' do
|
|
9
|
+
assert_kind_of Hash, strategy.extra
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
test 'contains raw info' do
|
|
13
|
+
assert_equal({ 'raw_info' => @raw_info }, strategy.extra)
|
|
14
|
+
end
|
|
15
|
+
end
|
data/test/helper.rb
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'bundler/setup'
|
|
2
|
+
require 'minitest/autorun'
|
|
3
|
+
require 'mocha'
|
|
4
|
+
require 'helper'
|
|
5
|
+
require 'omniauth-hackid'
|
|
6
|
+
require 'openssl'
|
|
7
|
+
require 'base64'
|
|
8
|
+
require 'omniauth/strategies/hackid'
|
|
9
|
+
|
|
10
|
+
OmniAuth.config.test_mode = true
|
|
11
|
+
|
|
12
|
+
module BlockTestHelper
|
|
13
|
+
def test(name, &blk)
|
|
14
|
+
method_name = "test_#{name.gsub(/\s+/, '_')}"
|
|
15
|
+
raise "Method already defined: #{method_name}" if instance_methods.include?(method_name.to_sym)
|
|
16
|
+
define_method method_name, &blk
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
module CustomAssertions
|
|
21
|
+
def assert_has_key(key, hash, msg = nil)
|
|
22
|
+
msg = message(msg) { "Expected #{hash.inspect} to have key #{key.inspect}" }
|
|
23
|
+
assert hash.has_key?(key), msg
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def refute_has_key(key, hash, msg = nil)
|
|
27
|
+
msg = message(msg) { "Expected #{hash.inspect} not to have key #{key.inspect}" }
|
|
28
|
+
refute hash.has_key?(key), msg
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class TestCase < MiniTest::Unit::TestCase
|
|
33
|
+
extend BlockTestHelper
|
|
34
|
+
include CustomAssertions
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class StrategyTestCase < TestCase
|
|
38
|
+
def setup
|
|
39
|
+
@request = stub('Request')
|
|
40
|
+
@request.stubs(:params).returns({})
|
|
41
|
+
@request.stubs(:cookies).returns({})
|
|
42
|
+
@request.stubs(:env).returns({})
|
|
43
|
+
|
|
44
|
+
@client_id = '123'
|
|
45
|
+
@client_secret = '53cr3tz'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def strategy
|
|
49
|
+
@strategy ||= begin
|
|
50
|
+
args = [@client_id, @client_secret, @options].compact
|
|
51
|
+
OmniAuth::Strategies::HackID.new(nil, *args).tap do |strategy|
|
|
52
|
+
strategy.stubs(:request).returns(@request)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
Dir[File.expand_path('../support/**/*', __FILE__)].each &method(:require)
|
data/test/info_test.rb
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
class InfoTest < StrategyTestCase
|
|
2
|
+
test 'returns the secure facebook avatar url when `secure_image_url` option is specified' do
|
|
3
|
+
@options = { :secure_image_url => true }
|
|
4
|
+
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
|
5
|
+
strategy.stubs(:raw_info).returns(raw_info)
|
|
6
|
+
assert_equal 'https://graph.facebook.com/321/picture?type=square', strategy.info['image']
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test 'returns the image size specified in the `image_size` option' do
|
|
10
|
+
@options = { :image_size => 'normal' }
|
|
11
|
+
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
|
12
|
+
strategy.stubs(:raw_info).returns(raw_info)
|
|
13
|
+
assert_equal 'http://graph.facebook.com/321/picture?type=normal', strategy.info['image']
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class InfoTestOptionalDataPresent < StrategyTestCase
|
|
18
|
+
def setup
|
|
19
|
+
super
|
|
20
|
+
@raw_info ||= { 'name' => 'Fred Smith' }
|
|
21
|
+
strategy.stubs(:raw_info).returns(@raw_info)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test 'returns the name' do
|
|
25
|
+
assert_equal 'Fred Smith', strategy.info['name']
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
test 'returns the email' do
|
|
29
|
+
@raw_info['email'] = 'fred@smith.com'
|
|
30
|
+
assert_equal 'fred@smith.com', strategy.info['email']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test 'returns the username as nickname' do
|
|
34
|
+
@raw_info['username'] = 'fredsmith'
|
|
35
|
+
assert_equal 'fredsmith', strategy.info['nickname']
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test 'returns the first name' do
|
|
39
|
+
@raw_info['first_name'] = 'Fred'
|
|
40
|
+
assert_equal 'Fred', strategy.info['first_name']
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
test 'returns the last name' do
|
|
44
|
+
@raw_info['last_name'] = 'Smith'
|
|
45
|
+
assert_equal 'Smith', strategy.info['last_name']
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
test 'returns the location name as location' do
|
|
49
|
+
@raw_info['location'] = { 'id' => '104022926303756', 'name' => 'Palo Alto, California' }
|
|
50
|
+
assert_equal 'Palo Alto, California', strategy.info['location']
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
test 'returns bio as description' do
|
|
54
|
+
@raw_info['bio'] = 'I am great'
|
|
55
|
+
assert_equal 'I am great', strategy.info['description']
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
test 'returns the square format facebook avatar url' do
|
|
59
|
+
@raw_info['id'] = '321'
|
|
60
|
+
assert_equal 'http://graph.facebook.com/321/picture?type=square', strategy.info['image']
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
test 'returns the Facebook link as the Facebook url' do
|
|
64
|
+
@raw_info['link'] = 'http://www.facebook.com/fredsmith'
|
|
65
|
+
assert_kind_of Hash, strategy.info['urls']
|
|
66
|
+
assert_equal 'http://www.facebook.com/fredsmith', strategy.info['urls']['Facebook']
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
test 'returns website url' do
|
|
70
|
+
@raw_info['website'] = 'https://my-wonderful-site.com'
|
|
71
|
+
assert_kind_of Hash, strategy.info['urls']
|
|
72
|
+
assert_equal 'https://my-wonderful-site.com', strategy.info['urls']['Website']
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
test 'return both Facebook link and website urls' do
|
|
76
|
+
@raw_info['link'] = 'http://www.facebook.com/fredsmith'
|
|
77
|
+
@raw_info['website'] = 'https://my-wonderful-site.com'
|
|
78
|
+
assert_kind_of Hash, strategy.info['urls']
|
|
79
|
+
assert_equal 'http://www.facebook.com/fredsmith', strategy.info['urls']['Facebook']
|
|
80
|
+
assert_equal 'https://my-wonderful-site.com', strategy.info['urls']['Website']
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
test 'returns the positive verified status' do
|
|
84
|
+
@raw_info['verified'] = true
|
|
85
|
+
assert strategy.info['verified']
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
test 'returns the negative verified status' do
|
|
89
|
+
@raw_info['verified'] = false
|
|
90
|
+
refute strategy.info['verified']
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
class InfoTestOptionalDataNotPresent < StrategyTestCase
|
|
95
|
+
def setup
|
|
96
|
+
super
|
|
97
|
+
@raw_info ||= { 'name' => 'Fred Smith' }
|
|
98
|
+
strategy.stubs(:raw_info).returns(@raw_info)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
test 'has no email key' do
|
|
102
|
+
refute_has_key 'email', strategy.info
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
test 'has no nickname key' do
|
|
106
|
+
refute_has_key 'nickname', strategy.info
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
test 'has no first name key' do
|
|
110
|
+
refute_has_key 'first_name', strategy.info
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
test 'has no last name key' do
|
|
114
|
+
refute_has_key 'last_name', strategy.info
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
test 'has no location key' do
|
|
118
|
+
refute_has_key 'location', strategy.info
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
test 'has no description key' do
|
|
122
|
+
refute_has_key 'description', strategy.info
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
test 'has no urls' do
|
|
126
|
+
refute_has_key 'urls', strategy.info
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
test 'has no verified key' do
|
|
130
|
+
refute_has_key 'verified', strategy.info
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
class RawInfoTest < StrategyTestCase
|
|
2
|
+
def setup
|
|
3
|
+
super
|
|
4
|
+
@access_token = stub('OAuth2::AccessToken')
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
test 'performs a GET to https://graph.facebook.com/me' do
|
|
8
|
+
strategy.stubs(:access_token).returns(@access_token)
|
|
9
|
+
@access_token.expects(:get).with('/me').returns(stub_everything('OAuth2::Response'))
|
|
10
|
+
strategy.raw_info
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
test 'returns a Hash' do
|
|
14
|
+
strategy.stubs(:access_token).returns(@access_token)
|
|
15
|
+
raw_response = stub('Faraday::Response')
|
|
16
|
+
raw_response.stubs(:body).returns('{ "ohai": "thar" }')
|
|
17
|
+
raw_response.stubs(:status).returns(200)
|
|
18
|
+
raw_response.stubs(:headers).returns({'Content-Type' => 'application/json' })
|
|
19
|
+
oauth2_response = OAuth2::Response.new(raw_response)
|
|
20
|
+
@access_token.stubs(:get).with('/me').returns(oauth2_response)
|
|
21
|
+
assert_kind_of Hash, strategy.raw_info
|
|
22
|
+
assert_equal 'thar', strategy.raw_info['ohai']
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test 'returns an empty hash when the response is false' do
|
|
26
|
+
strategy.stubs(:access_token).returns(@access_token)
|
|
27
|
+
oauth2_response = stub('OAuth2::Response', :parsed => false)
|
|
28
|
+
@access_token.stubs(:get).with('/me').returns(oauth2_response)
|
|
29
|
+
assert_kind_of Hash, strategy.raw_info
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test 'should not include raw_info in extras hash when skip_info is specified' do
|
|
33
|
+
@options = { :skip_info => true }
|
|
34
|
+
strategy.stubs(:raw_info).returns({:foo => 'bar' })
|
|
35
|
+
refute_has_key 'raw_info', strategy.extra
|
|
36
|
+
end
|
|
37
|
+
end
|