panjiva-oauth2 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,126 +1,157 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panjiva-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
8
+ - Erik Michaels-Ober
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
  date: 2013-12-18 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: faraday
15
+ name: rake
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - ! '>='
18
+ - - ~>
18
19
  - !ruby/object:Gem::Version
19
- version: 0.6.1
20
- type: :runtime
20
+ version: '0.9'
21
+ type: :development
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - ! '>='
25
+ - - ~>
25
26
  - !ruby/object:Gem::Version
26
- version: 0.6.1
27
+ version: '0.9'
27
28
  - !ruby/object:Gem::Dependency
28
- name: multi_json
29
+ name: rdoc
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - ! '>='
32
+ - - ~>
32
33
  - !ruby/object:Gem::Version
33
- version: 0.0.5
34
- type: :runtime
34
+ version: '3.6'
35
+ type: :development
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - ! '>='
39
+ - - ~>
39
40
  - !ruby/object:Gem::Version
40
- version: 0.0.5
41
+ version: '3.6'
41
42
  - !ruby/object:Gem::Dependency
42
- name: json_pure
43
+ name: rspec
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
46
  - - ~>
46
47
  - !ruby/object:Gem::Version
47
- version: '1.5'
48
+ version: '2.6'
48
49
  type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
52
53
  - - ~>
53
54
  - !ruby/object:Gem::Version
54
- version: '1.5'
55
+ version: '2.6'
55
56
  - !ruby/object:Gem::Dependency
56
- name: rake
57
+ name: simplecov
57
58
  requirement: !ruby/object:Gem::Requirement
58
59
  requirements:
59
60
  - - ~>
60
61
  - !ruby/object:Gem::Version
61
- version: '0.8'
62
+ version: '0.4'
62
63
  type: :development
63
64
  prerelease: false
64
65
  version_requirements: !ruby/object:Gem::Requirement
65
66
  requirements:
66
67
  - - ~>
67
68
  - !ruby/object:Gem::Version
68
- version: '0.8'
69
+ version: '0.4'
69
70
  - !ruby/object:Gem::Dependency
70
- name: simplecov
71
+ name: yard
71
72
  requirement: !ruby/object:Gem::Requirement
72
73
  requirements:
73
74
  - - ~>
74
75
  - !ruby/object:Gem::Version
75
- version: '0.4'
76
+ version: '0.7'
76
77
  type: :development
77
78
  prerelease: false
78
79
  version_requirements: !ruby/object:Gem::Requirement
79
80
  requirements:
80
81
  - - ~>
81
82
  - !ruby/object:Gem::Version
82
- version: '0.4'
83
+ version: '0.7'
83
84
  - !ruby/object:Gem::Dependency
84
- name: rspec
85
+ name: ZenTest
85
86
  requirement: !ruby/object:Gem::Requirement
86
87
  requirements:
87
88
  - - ~>
88
89
  - !ruby/object:Gem::Version
89
- version: '2.5'
90
+ version: '4.5'
90
91
  type: :development
91
92
  prerelease: false
92
93
  version_requirements: !ruby/object:Gem::Requirement
93
94
  requirements:
94
95
  - - ~>
95
96
  - !ruby/object:Gem::Version
96
- version: '2.5'
97
+ version: '4.5'
97
98
  - !ruby/object:Gem::Dependency
98
- name: ZenTest
99
+ name: multi_xml
99
100
  requirement: !ruby/object:Gem::Requirement
100
101
  requirements:
101
- - - ~>
102
+ - - ! '>='
102
103
  - !ruby/object:Gem::Version
103
- version: '4.5'
104
+ version: '0'
104
105
  type: :development
105
106
  prerelease: false
106
107
  version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: faraday
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: 0.6.1
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 0.6.1
126
+ - !ruby/object:Gem::Dependency
127
+ name: multi_json
128
+ requirement: !ruby/object:Gem::Requirement
107
129
  requirements:
108
130
  - - ~>
109
131
  - !ruby/object:Gem::Version
110
- version: '4.5'
132
+ version: 1.0.0
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ~>
138
+ - !ruby/object:Gem::Version
139
+ version: 1.0.0
111
140
  description: A Ruby wrapper for the OAuth 2.0 protocol built with a similar style
112
141
  to the original OAuth gem.
113
- email: michael@intridea.com
142
+ email:
143
+ - michael@intridea.com
144
+ - sferik@gmail.com
114
145
  executables: []
115
146
  extensions: []
116
147
  extra_rdoc_files: []
117
148
  files:
149
+ - .autotest
118
150
  - .document
119
151
  - .gemtest
120
152
  - .gitignore
121
153
  - .rspec
122
154
  - .travis.yml
123
- - CHANGELOG.md
124
155
  - Gemfile
125
156
  - LICENSE.md
126
157
  - README.md
@@ -128,18 +159,20 @@ files:
128
159
  - lib/oauth2.rb
129
160
  - lib/oauth2/access_token.rb
130
161
  - lib/oauth2/client.rb
131
- - lib/oauth2/response_object.rb
162
+ - lib/oauth2/error.rb
163
+ - lib/oauth2/response.rb
164
+ - lib/oauth2/strategy/auth_code.rb
132
165
  - lib/oauth2/strategy/base.rb
133
166
  - lib/oauth2/strategy/password.rb
134
- - lib/oauth2/strategy/web_server.rb
135
167
  - lib/oauth2/version.rb
136
168
  - oauth2.gemspec
169
+ - spec/helper.rb
137
170
  - spec/oauth2/access_token_spec.rb
138
171
  - spec/oauth2/client_spec.rb
172
+ - spec/oauth2/response_spec.rb
173
+ - spec/oauth2/strategy/auth_code_spec.rb
139
174
  - spec/oauth2/strategy/base_spec.rb
140
175
  - spec/oauth2/strategy/password_spec.rb
141
- - spec/oauth2/strategy/web_server_spec.rb
142
- - spec/spec_helper.rb
143
176
  homepage: http://github.com/intridea/oauth2
144
177
  licenses: []
145
178
  metadata: {}
@@ -1,21 +0,0 @@
1
- # CHANGELOG
2
-
3
- * [0.4.1 - April 20, 2011](https://github.com/intridea/oauth2/compare/v0.4.0...v0.4.1)
4
- * [0.4.0 - April 20, 2011](https://github.com/intridea/oauth2/compare/v0.3.0...v0.4.0)
5
- * [0.3.0 - April 8, 2011](https://github.com/intridea/oauth2/compare/v0.2.0...v0.3.0)
6
- * [0.2.0 - April 1, 2011](https://github.com/intridea/oauth2/compare/v0.1.1...v0.2.0)
7
- * [0.1.1 - January 12, 2011](https://github.com/intridea/oauth2/compare/v0.1.0...v0.1.1)
8
- * [0.1.0 - October 13, 2010](https://github.com/intridea/oauth2/compare/v0.0.13...v0.1.0)
9
- * [0.0.13 - August 17, 2010](https://github.com/intridea/oauth2/compare/v0.0.12...v0.0.13)
10
- * [0.0.12 - August 17, 2010](https://github.com/intridea/oauth2/compare/v0.0.11...v0.0.12)
11
- * [0.0.11 - August 17, 2010](https://github.com/intridea/oauth2/compare/v0.0.10...v0.0.11)
12
- * [0.0.10 - June 19, 2010](https://github.com/intridea/oauth2/compare/v0.0.9...v0.0.10)
13
- * [0.0.9 - June 18, 2010](https://github.com/intridea/oauth2/compare/v0.0.8...v0.0.9)
14
- * [0.0.8 - April 27, 2010](https://github.com/intridea/oauth2/compare/v0.0.7...v0.0.8)
15
- * [0.0.7 - April 27, 2010](https://github.com/intridea/oauth2/compare/v0.0.6...v0.0.7)
16
- * [0.0.6 - April 25, 2010](https://github.com/intridea/oauth2/compare/v0.0.5...v0.0.6)
17
- * [0.0.5 - April 23, 2010](https://github.com/intridea/oauth2/compare/v0.0.4...v0.0.5)
18
- * [0.0.4 - April 22, 2010](https://github.com/intridea/oauth2/compare/v0.0.3...v0.0.4)
19
- * [0.0.3 - April 22, 2010](https://github.com/intridea/oauth2/compare/v0.0.2...v0.0.3)
20
- * [0.0.2 - April 22, 2010](https://github.com/intridea/oauth2/compare/v0.0.1...v0.0.2)
21
- * [0.0.1 - April 22, 2010](https://github.com/intridea/oauth2/compare/311d9f42e52b832119170d90e818f0f0b0078851...v0.0.1)
@@ -1,58 +0,0 @@
1
- module OAuth2
2
- module ResponseObject
3
- def self.from(response)
4
- object = MultiJson.decode(response.body)
5
-
6
- case object
7
- when Array
8
- ResponseArray.new(response, object)
9
- when Hash
10
- ResponseHash.new(response, object)
11
- else
12
- ResponseString.new(response)
13
- end
14
- rescue
15
- ResponseString.new(response)
16
- end
17
-
18
- def self.included(base)
19
- base.class_eval do
20
- attr_accessor :response
21
- end
22
- end
23
-
24
- def headers; response.headers end
25
- def status; response.status end
26
- end
27
-
28
- class ResponseHash < Hash
29
- include ResponseObject
30
-
31
- def initialize(response, hash)
32
- self.response = response
33
- hash.keys.each{|k| self[k] = hash[k]}
34
- end
35
- end
36
-
37
- class ResponseArray < Array
38
- include ResponseObject
39
-
40
- def initialize(response, array)
41
- self.response = response
42
- super(array)
43
- end
44
- end
45
-
46
- # This special String class is returned from HTTP requests
47
- # and contains the original full response along with convenience
48
- # methods for accessing the HTTP status code and headers. It
49
- # is returned from all access token requests.
50
- class ResponseString < String
51
- include ResponseObject
52
-
53
- def initialize(response)
54
- super(response.body.to_s)
55
- self.response = response
56
- end
57
- end
58
- end
@@ -1,58 +0,0 @@
1
- require 'multi_json'
2
-
3
- module OAuth2
4
- module Strategy
5
- class WebServer < Base
6
- def authorize_params(options={}) #:nodoc:
7
- super(options).merge('response_type' => 'code')
8
- end
9
-
10
- # Retrieve an access token given the specified validation code.
11
- # Note that you must also provide a <tt>:redirect_uri</tt> option
12
- # in order to successfully verify your request for most OAuth 2.0
13
- # endpoints.
14
- def get_access_token(code, options={})
15
- response = @client.request(@client.token_method, @client.access_token_url, access_token_params(code, options))
16
- parse_response(response)
17
- end
18
-
19
- def refresh_access_token(refresh_token, options={})
20
- response = @client.request(@client.token_method, @client.access_token_url, refresh_token_params(refresh_token, options))
21
- parse_response(response, refresh_token)
22
- end
23
-
24
- def access_token_params(code, options={}) #:nodoc:
25
- super(options).merge({
26
- 'grant_type' => 'authorization_code',
27
- 'code' => code,
28
- })
29
- end
30
-
31
- def refresh_token_params(refresh_token, options={}) #:nodoc:
32
- super(options).merge({
33
- 'grant_type' => 'refresh_token',
34
- 'refresh_token' => refresh_token,
35
- })
36
- end
37
-
38
- def parse_response(response, refresh_token = nil)
39
- if response.is_a? Hash
40
- params = response
41
- else
42
- params = MultiJson.decode(response) rescue nil
43
- # the ActiveSupport JSON parser won't cause an exception when
44
- # given a formencoded string, so make sure that it was
45
- # actually parsed in an Hash. This covers even the case where
46
- # it caused an exception since it'll still be nil.
47
- params = Rack::Utils.parse_query(response) unless params.is_a? Hash
48
- end
49
-
50
- access = params.delete('access_token')
51
- refresh = params.delete('refresh_token') || refresh_token
52
- # params['expires'] is only for Facebook
53
- expires_in = params.delete('expires_in') || params.delete('expires')
54
- OAuth2::AccessToken.new(@client, access, refresh, expires_in, params)
55
- end
56
- end
57
- end
58
- end
@@ -1,138 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe OAuth2::Strategy::WebServer do
4
- let(:client) do
5
- cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
6
- cli.connection.build do |b|
7
- b.adapter :test do |stub|
8
- stub.get('/oauth/access_token?client_id=abc&client_secret=def&code=sushi&grant_type=authorization_code') do |env|
9
- case @mode
10
- when "formencoded"
11
- [200, {}, 'expires_in=600&access_token=salmon&refresh_token=trout&extra_param=steve']
12
- when "json"
13
- [200, {}, '{"expires_in":600,"access_token":"salmon","refresh_token":"trout","extra_param":"steve"}']
14
- when "from_facebook"
15
- [200, {}, 'expires=600&access_token=salmon&refresh_token=trout&extra_param=steve']
16
- end
17
- end
18
- stub.post('/oauth/access_token', { 'client_id' => 'abc', 'client_secret' => 'def', 'code' => 'sushi', 'grant_type' => 'authorization_code' }) do |env|
19
- case @mode
20
- when "formencoded"
21
- [200, {}, 'expires_in=600&access_token=salmon&refresh_token=trout&extra_param=steve']
22
- when "json"
23
- [200, {}, '{"expires_in":600,"access_token":"salmon","refresh_token":"trout","extra_param":"steve"}']
24
- when "from_facebook"
25
- [200, {}, 'expires=600&access_token=salmon&refresh_token=trout&extra_param=steve']
26
- end
27
- end
28
- stub.get('/oauth/access_token?client_id=abc&client_secret=def&grant_type=refresh_token&refresh_token=trout') do |env|
29
- case @mode
30
- when "formencoded"
31
- [200, {}, 'expires_in=600&access_token=tuna']
32
- when "json"
33
- [200, {}, '{"expires_in":600,"access_token":"tuna"}']
34
- end
35
- end
36
- stub.post('/oauth/access_token', { 'client_id' => 'abc', 'client_secret' => 'def', 'refresh_token' => 'trout', 'grant_type' => 'refresh_token' }) do |env|
37
- case @mode
38
- when "formencoded"
39
- [200, {}, 'expires_in=600&access_token=tuna']
40
- when "json"
41
- [200, {}, '{"expires_in":600,"access_token":"tuna"}']
42
- end
43
- end
44
- end
45
- end
46
- cli
47
- end
48
- subject{client.web_server}
49
-
50
- describe '#authorize_url' do
51
- it 'should include the client_id' do
52
- subject.authorize_url.should be_include('client_id=abc')
53
- end
54
-
55
- it 'should include the type' do
56
- subject.authorize_url.should be_include('response_type=code')
57
- end
58
-
59
- it 'should include passed in options' do
60
- cb = 'http://myserver.local/oauth/callback'
61
- subject.authorize_url(:redirect_uri => cb).should be_include("redirect_uri=#{Rack::Utils.escape(cb)}")
62
- end
63
- end
64
-
65
- %w(json formencoded from_facebook).each do |mode|
66
- [false, true].each do |parse_json|
67
- [:get, :post].each do |verb|
68
- describe "#get_access_token (#{mode}, token_method=#{verb} parse_json=#{parse_json})" do
69
- before do
70
- @mode = mode
71
- client.json=parse_json
72
- client.token_method=verb
73
- @access = subject.get_access_token('sushi')
74
- end
75
-
76
- it 'returns AccessToken with same Client' do
77
- @access.client.should == client
78
- end
79
-
80
- it 'returns AccessToken with #token' do
81
- @access.token.should == 'salmon'
82
- end
83
-
84
- it 'returns AccessToken with #refresh_token' do
85
- @access.refresh_token.should == 'trout'
86
- end
87
-
88
- it 'returns AccessToken with #expires_in' do
89
- @access.expires_in.should == 600
90
- end
91
-
92
- it 'returns AccessToken with #expires_at' do
93
- @access.expires_at.should be_kind_of(Time)
94
- end
95
-
96
- it 'returns AccessToken with params accessible via []' do
97
- @access['extra_param'].should == 'steve'
98
- end
99
- end
100
- end
101
- end
102
- end
103
-
104
- %w(json formencoded).each do |mode|
105
- [false, true].each do |parse_json|
106
- [:get].each do |verb|
107
- describe "#refresh_access_token (#{mode}, token_method=#{verb} parse_json=#{parse_json})" do
108
- before do
109
- @mode = mode
110
- client.json=parse_json
111
- client.token_method=verb
112
- @access = subject.refresh_access_token('trout')
113
- end
114
-
115
- it 'returns AccessToken with same Client' do
116
- @access.client.should == client
117
- end
118
-
119
- it 'returns AccessToken with #token' do
120
- @access.token.should == 'tuna'
121
- end
122
-
123
- it 'returns AccessToken with #refresh_token' do
124
- @access.refresh_token.should == 'trout'
125
- end
126
-
127
- it 'returns AccessToken with #expires_in' do
128
- @access.expires_in.should == 600
129
- end
130
-
131
- it 'returns AccessToken with #expires_at' do
132
- @access.expires_at.should be_kind_of(Time)
133
- end
134
- end
135
- end
136
- end
137
- end
138
- end