omniauth-paypal-oauth2 1.4.4 → 1.4.5
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +4 -3
- data/README.md +3 -2
- data/examples/shared_examples.rb +36 -0
- data/lib/omniauth/paypal_oauth2/version.rb +3 -3
- data/lib/omniauth/strategies/paypal_oauth2.rb +76 -73
- data/omniauth-paypal-oauth2.gemspec +15 -14
- data/spec/omniauth/strategies/paypal_oauth2_spec.rb +49 -0
- data/spec/spec_helper.rb +2 -2
- metadata +28 -9
- data/CNAME +0 -1
- data/spec/omniauth/strategies/paypal_spec.rb +0 -50
- data/spec/support/shared_examples.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f496baba52d3379ce046ae4ff2d9de74fd034dbd
|
4
|
+
data.tar.gz: e6a0a3ba604b957893497d3230627a5c87fc66fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a487349f65691e079eff850bc5059c08c61d2271ec6db797ec8079ec0c6c01f9a58506c27d7081445e38c4ad35dfd3925f696ab35cfb6a0054ce37934faa9ef
|
7
|
+
data.tar.gz: 1ff3a3aa9f6323d10db483f913efef97bc5f9e324d374f2766f1e3b6b64cef73d83a616f2ac6736e54421835be9b4e468c4a16d0b1ce01a89c7956e717d7213a
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
omniauth-paypal-oauth2 (1.4.
|
4
|
+
omniauth-paypal-oauth2 (1.4.4)
|
5
|
+
json (~> 2.0, >= 2.0.3)
|
5
6
|
omniauth-oauth2 (~> 1.4.0)
|
6
7
|
|
7
8
|
GEM
|
@@ -44,11 +45,11 @@ PLATFORMS
|
|
44
45
|
x86-mingw32
|
45
46
|
|
46
47
|
DEPENDENCIES
|
47
|
-
json
|
48
|
+
json (~> 2.0, >= 2.0.3)
|
48
49
|
omniauth-oauth2 (~> 1.4.0)
|
49
50
|
omniauth-paypal-oauth2!
|
50
51
|
rake
|
51
|
-
rspec (~> 2.
|
52
|
+
rspec (~> 2.99.0)
|
52
53
|
|
53
54
|
BUNDLED WITH
|
54
55
|
1.11.2
|
data/README.md
CHANGED
@@ -44,7 +44,7 @@ Here's an example for adding the middleware to a Rails app in `config/initialize
|
|
44
44
|
|
45
45
|
```ruby
|
46
46
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
47
|
-
provider :paypal_oauth2, ENV["PAYPAL_CLIENT_ID"], ENV["PAYPAL_CLIENT_SECRET"]
|
47
|
+
provider :paypal_oauth2, ENV["PAYPAL_CLIENT_ID"], ENV["PAYPAL_CLIENT_SECRET"], :strategy_class => OmniAuth::Strategies::PayPalOauth2
|
48
48
|
end
|
49
49
|
```
|
50
50
|
|
@@ -137,7 +137,8 @@ First define your application id and secret in `config/initializers/devise.rb`.
|
|
137
137
|
Configuration options can be passed as the last parameter here as key/value pairs.
|
138
138
|
|
139
139
|
```ruby
|
140
|
-
|
140
|
+
require "omniauth-paypal-oauth2"
|
141
|
+
config.omniauth :paypal_oauth2, "PAYPAL_CLIENT_ID", "PAYPAL_CLIENT_SECRET", :strategy_class => OmniAuth::Strategies::PayPalOauth2, { }
|
141
142
|
```
|
142
143
|
|
143
144
|
Then add the following to 'config/routes.rb' so the callback routes are defined.
|
@@ -0,0 +1,36 @@
|
|
1
|
+
shared_examples 'an oauth2 strategy' do
|
2
|
+
describe '#client' do
|
3
|
+
it 'should be initialized with symbolized client_options' do
|
4
|
+
@options = { :client_options => { 'authorize_url' => 'https://example.com' } }
|
5
|
+
expect(subject.client.options[:authorize_url]).to eq('https://example.com')
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#authorize_params' do
|
10
|
+
it 'should include any authorize params passed in the :authorize_params option' do
|
11
|
+
@options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
|
12
|
+
expect(subject.authorize_params['foo']).to eq('bar')
|
13
|
+
expect(subject.authorize_params['baz']).to eq('zip')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should include top-level options that are marked as :authorize_options' do
|
17
|
+
@options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
18
|
+
expect(subject.authorize_params['scope']).to eq('bar')
|
19
|
+
expect(subject.authorize_params['foo']).to eq('baz')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#token_params' do
|
24
|
+
it 'should include any token params passed in the :token_params option' do
|
25
|
+
@options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
|
26
|
+
expect(subject.token_params['foo']).to eq('bar')
|
27
|
+
expect(subject.token_params['baz']).to eq('zip')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should include top-level options that are marked as :token_options' do
|
31
|
+
@options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
32
|
+
expect(subject.token_params['scope']).to eq('bar')
|
33
|
+
expect(subject.token_params['foo']).to eq('baz')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,90 +1,93 @@
|
|
1
1
|
require 'omniauth-oauth2'
|
2
2
|
|
3
3
|
module OmniAuth
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
module Strategies
|
5
|
+
class PayPalOauth2 < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_SCOPE = "email,profile"
|
7
|
+
DEFAULT_RESPONSE_TYPE = "code"
|
8
|
+
SANDBOX_SITE = "https://api.sandbox.paypal.com"
|
9
|
+
SANDBOX_AUTHORIZE_URL = 'https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize'
|
10
10
|
|
11
|
-
|
12
|
-
:site => 'https://api.paypal.com',
|
13
|
-
:authorize_url => 'https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize',
|
14
|
-
:token_url => '/v1/identity/openidconnect/tokenservice',
|
15
|
-
:setup => true
|
16
|
-
}
|
11
|
+
option :name, "paypal_oauth2"
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
option :client_options, {
|
14
|
+
:site => 'https://api.paypal.com',
|
15
|
+
:authorize_url => 'https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize',
|
16
|
+
:token_url => '/v1/identity/openidconnect/tokenservice',
|
17
|
+
:setup => true
|
18
|
+
}
|
21
19
|
|
22
|
-
|
20
|
+
option :authorize_options, [:scope, :response_type]
|
21
|
+
option :provider_ignores_state, true
|
22
|
+
option :sandbox, false
|
23
23
|
|
24
|
-
|
25
|
-
prune!({
|
26
|
-
'name' => raw_info['name'],
|
27
|
-
'email' => raw_info['email'],
|
28
|
-
'first_name' => raw_info['given_name'],
|
29
|
-
'last_name' => raw_info['family_name'],
|
30
|
-
'given_name' => raw_info['given_name'],
|
31
|
-
'family_name' => raw_info['family_name'],
|
32
|
-
'location' => (raw_info['address'] || {})['locality'],
|
33
|
-
'phone' => raw_info['phone_number']
|
34
|
-
})
|
35
|
-
end
|
24
|
+
uid { @parsed_uid ||= (/\/([^\/]+)\z/.match raw_info['user_id'])[1] } #https://www.paypal.com/webapps/auth/identity/user/baCNqjGvIxzlbvDCSsfhN3IrQDtQtsVr79AwAjMxekw => baCNqjGvIxzlbvDCSsfhN3IrQDtQtsVr79AwAjMxekw
|
36
25
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
})
|
50
|
-
end
|
26
|
+
info do
|
27
|
+
prune!({
|
28
|
+
'name' => raw_info['name'],
|
29
|
+
'email' => raw_info['email'],
|
30
|
+
'first_name' => raw_info['given_name'],
|
31
|
+
'last_name' => raw_info['family_name'],
|
32
|
+
'given_name' => raw_info['given_name'],
|
33
|
+
'family_name' => raw_info['family_name'],
|
34
|
+
'location' => (raw_info['address'] || {})['locality'],
|
35
|
+
'phone' => raw_info['phone_number']
|
36
|
+
})
|
37
|
+
end
|
51
38
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
39
|
+
extra do
|
40
|
+
prune!({
|
41
|
+
'account_type' => raw_info['account_type'],
|
42
|
+
'user_id' => raw_info['user_id'],
|
43
|
+
'address' => raw_info['address'],
|
44
|
+
'verified_account' => (raw_info['verified_account'] == 'true'),
|
45
|
+
'language' => raw_info['language'],
|
46
|
+
'zoneinfo' => raw_info['zoneinfo'],
|
47
|
+
'locale' => raw_info['locale'],
|
48
|
+
'account_creation_date' => raw_info['account_creation_date'],
|
49
|
+
'age_range' => raw_info['age_range'],
|
50
|
+
'birthday' => raw_info['birthday']
|
51
|
+
})
|
52
|
+
end
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
def setup_phase
|
55
|
+
if options.sandbox
|
56
|
+
options.client_options[:site] = SANDBOX_SITE
|
57
|
+
options.client_options[:authorize_url] = SANDBOX_AUTHORIZE_URL
|
58
|
+
end
|
59
|
+
super
|
60
|
+
end
|
63
61
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
params[:response_type] ||= DEFAULT_RESPONSE_TYPE
|
68
|
-
end
|
69
|
-
end
|
62
|
+
def raw_info
|
63
|
+
@raw_info ||= load_identity()
|
64
|
+
end
|
70
65
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
66
|
+
def authorize_params
|
67
|
+
super.tap do |params|
|
68
|
+
params[:scope] ||= DEFAULT_SCOPE
|
69
|
+
params[:response_type] ||= DEFAULT_RESPONSE_TYPE
|
70
|
+
end
|
71
|
+
end
|
78
72
|
|
79
|
-
|
80
|
-
hash.delete_if do |_, value|
|
81
|
-
prune!(value) if value.is_a?(Hash)
|
82
|
-
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
83
|
-
end
|
84
|
-
end
|
73
|
+
private
|
85
74
|
|
75
|
+
def load_identity
|
76
|
+
access_token.options[:mode] = :query
|
77
|
+
access_token.options[:param_name] = :access_token
|
78
|
+
access_token.options[:grant_type] = :authorization_code
|
79
|
+
access_token.get('/v1/identity/openidconnect/userinfo', { :params => { :schema => 'openid'}}).parsed || {}
|
80
|
+
end
|
81
|
+
|
82
|
+
def prune!(hash)
|
83
|
+
hash.delete_if do |_, value|
|
84
|
+
prune!(value) if value.is_a?(Hash)
|
85
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
86
90
|
end
|
87
|
-
end
|
88
91
|
end
|
89
92
|
|
90
|
-
OmniAuth.config.add_camelization
|
93
|
+
OmniAuth.config.add_camelization('oauth', 'OAuth')
|
@@ -3,21 +3,22 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
require 'omniauth/paypal_oauth2/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
s.name = 'omniauth-paypal-oauth2'
|
7
|
+
s.version = '1.4.5'
|
8
|
+
s.authors = ['Jonas Hübotter']
|
9
|
+
s.email = ['jonas@slooob.com']
|
10
|
+
s.summary = 'A PayPal OAuth2 strategy for OmniAuth 1.x'
|
11
|
+
s.homepage = 'https://github.com/jonhue/omniauth-paypal-oauth2'
|
12
|
+
s.license = 'MIT'
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
17
|
+
s.require_paths = ['lib']
|
18
18
|
|
19
|
-
|
19
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.4.0'
|
20
|
+
s.add_runtime_dependency 'json', '~> 2.0', '>= 2.0.3'
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
s.add_development_dependency 'rspec', '~> 2.99.0'
|
23
|
+
s.add_development_dependency 'rake'
|
23
24
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omniauth-paypal-oauth2'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::PayPalOauth2 do
|
5
|
+
subject do
|
6
|
+
OmniAuth::Strategies::PayPalOauth2.new(nil, @options || {})
|
7
|
+
end
|
8
|
+
|
9
|
+
it_should_behave_like 'an oauth2 strategy'
|
10
|
+
|
11
|
+
describe '#client' do
|
12
|
+
it 'has correct PayPal site' do
|
13
|
+
expect(subject.client.site).to eq('https://api.paypal.com')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'has correct PayPal sandbox site' do
|
17
|
+
@options = { :sandbox => true }
|
18
|
+
subject.setup_phase
|
19
|
+
expect(subject.client.site).to eq('https://api.sandbox.paypal.com')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has correct authorize url' do
|
23
|
+
expect(subject.client.options[:authorize_url]).to eq('https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'has correct sandbox authorize url' do
|
27
|
+
@options = { :sandbox => true }
|
28
|
+
subject.setup_phase
|
29
|
+
expect(subject.client.options[:authorize_url]).to eq('https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'has correct token url' do
|
33
|
+
expect(subject.client.options[:token_url]).to eq('/v1/identity/openidconnect/tokenservice')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'runs the setup block if passed one' do
|
37
|
+
counter = ''
|
38
|
+
@options = { :setup => Proc.new { |env| counter = 'ok' } }
|
39
|
+
subject.setup_phase
|
40
|
+
expect(counter).to eq("ok")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#callback_path' do
|
45
|
+
it "has the correct callback path" do
|
46
|
+
expect(subject.callback_path).to eq('/auth/paypal_oauth2/callback')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-paypal-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Hübotter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth-oauth2
|
@@ -24,20 +24,40 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.4.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.0.3
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.0.3
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: rspec
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
30
50
|
requirements:
|
31
51
|
- - "~>"
|
32
52
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
53
|
+
version: 2.99.0
|
34
54
|
type: :development
|
35
55
|
prerelease: false
|
36
56
|
version_requirements: !ruby/object:Gem::Requirement
|
37
57
|
requirements:
|
38
58
|
- - "~>"
|
39
59
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
60
|
+
version: 2.99.0
|
41
61
|
- !ruby/object:Gem::Dependency
|
42
62
|
name: rake
|
43
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,28 +74,27 @@ dependencies:
|
|
54
74
|
version: '0'
|
55
75
|
description:
|
56
76
|
email:
|
57
|
-
- jonas
|
77
|
+
- jonas@slooob.com
|
58
78
|
executables: []
|
59
79
|
extensions: []
|
60
80
|
extra_rdoc_files: []
|
61
81
|
files:
|
62
82
|
- ".gitignore"
|
63
|
-
- CNAME
|
64
83
|
- Gemfile
|
65
84
|
- Gemfile.lock
|
66
85
|
- LICENSE
|
67
86
|
- README.md
|
68
87
|
- Rakefile
|
69
88
|
- _config.yml
|
89
|
+
- examples/shared_examples.rb
|
70
90
|
- lib/omniauth-paypal-oauth2.rb
|
71
91
|
- lib/omniauth/paypal_oauth2.rb
|
72
92
|
- lib/omniauth/paypal_oauth2/version.rb
|
73
93
|
- lib/omniauth/strategies/paypal_oauth2.rb
|
74
94
|
- omniauth-paypal-oauth2.gemspec
|
75
|
-
- spec/omniauth/strategies/
|
95
|
+
- spec/omniauth/strategies/paypal_oauth2_spec.rb
|
76
96
|
- spec/spec_helper.rb
|
77
|
-
|
78
|
-
homepage: http://omniauth-paypal-oauth2.jonhue.me
|
97
|
+
homepage: https://github.com/jonhue/omniauth-paypal-oauth2
|
79
98
|
licenses:
|
80
99
|
- MIT
|
81
100
|
metadata: {}
|
data/CNAME
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
omniauth-paypal-oauth2.jonhue.me
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'omniauth-paypal-oauth2'
|
3
|
-
|
4
|
-
describe OmniAuth::Strategies::PayPalOauth2 do
|
5
|
-
subject do
|
6
|
-
OmniAuth::Strategies::PayPalOauth2.new(nil, @options || {})
|
7
|
-
end
|
8
|
-
|
9
|
-
it_should_behave_like 'an oauth2 strategy'
|
10
|
-
|
11
|
-
describe '#client' do
|
12
|
-
it 'has correct PayPal site' do
|
13
|
-
expect(subject.client.site).to eq('https://api.paypal.com')
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'has correct PayPal sandbox site' do
|
17
|
-
@options = { :sandbox => true }
|
18
|
-
subject.setup_phase
|
19
|
-
expect(subject.client.site).to eq('https://api.sandbox.paypal.com')
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'has correct authorize url' do
|
23
|
-
expect(subject.client.options[:authorize_url]).to eq('https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'has correct sandbox authorize url' do
|
27
|
-
@options = { :sandbox => true }
|
28
|
-
subject.setup_phase
|
29
|
-
expect(subject.client.options[:authorize_url]).to eq('https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize')
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'has correct token url' do
|
33
|
-
expect(subject.client.options[:token_url]).to eq('/v1/identity/openidconnect/tokenservice')
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'runs the setup block if passed one' do
|
37
|
-
counter = ''
|
38
|
-
@options = { :setup => Proc.new { |env| counter = 'ok' } }
|
39
|
-
subject.setup_phase
|
40
|
-
expect(counter).to eq("ok")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#callback_path' do
|
45
|
-
it "has the correct callback path" do
|
46
|
-
expect(subject.callback_path).to eq('/auth/paypal_oauth2/callback')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# NOTE it would be useful if this lived in omniauth-oauth2 eventually
|
2
|
-
shared_examples 'an oauth2 strategy' do
|
3
|
-
describe '#client' do
|
4
|
-
it 'should be initialized with symbolized client_options' do
|
5
|
-
@options = { :client_options => { 'authorize_url' => 'https://example.com' } }
|
6
|
-
expect(subject.client.options[:authorize_url]).to eq('https://example.com')
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '#authorize_params' do
|
11
|
-
it 'should include any authorize params passed in the :authorize_params option' do
|
12
|
-
@options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
|
13
|
-
expect(subject.authorize_params['foo']).to eq('bar')
|
14
|
-
expect(subject.authorize_params['baz']).to eq('zip')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should include top-level options that are marked as :authorize_options' do
|
18
|
-
@options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
19
|
-
expect(subject.authorize_params['scope']).to eq('bar')
|
20
|
-
expect(subject.authorize_params['foo']).to eq('baz')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#token_params' do
|
25
|
-
it 'should include any token params passed in the :token_params option' do
|
26
|
-
@options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
|
27
|
-
expect(subject.token_params['foo']).to eq('bar')
|
28
|
-
expect(subject.token_params['baz']).to eq('zip')
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should include top-level options that are marked as :token_options' do
|
32
|
-
@options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
33
|
-
expect(subject.token_params['scope']).to eq('bar')
|
34
|
-
expect(subject.token_params['foo']).to eq('baz')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|