oauth2 0.7.0 → 0.7.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/lib/oauth2/response.rb +5 -3
- data/lib/oauth2/version.rb +1 -1
- data/oauth2.gemspec +1 -1
- data/spec/helper.rb +3 -1
- data/spec/oauth2/access_token_spec.rb +2 -2
- data/spec/oauth2/client_spec.rb +1 -1
- data/spec/oauth2/response_spec.rb +2 -1
- data/spec/oauth2/strategy/auth_code_spec.rb +1 -1
- metadata +7 -7
data/lib/oauth2/response.rb
CHANGED
@@ -49,9 +49,11 @@ module OAuth2
|
|
49
49
|
# Procs that, when called, will parse a response body according
|
50
50
|
# to the specified format.
|
51
51
|
PARSERS = {
|
52
|
-
|
53
|
-
|
54
|
-
:
|
52
|
+
# Can't reliably detect whether MultiJson responds to load, since it's
|
53
|
+
# a reserved word. Use adapter as a proxy for new features.
|
54
|
+
:json => lambda{ |body| MultiJson.respond_to?(:adapter) ? MultiJson.load(body) : MultiJson.decode(body) rescue body },
|
55
|
+
:query => lambda{ |body| Rack::Utils.parse_query(body) },
|
56
|
+
:text => lambda{ |body| body }
|
55
57
|
}
|
56
58
|
|
57
59
|
# Content type assignments for various potential HTTP content types.
|
data/lib/oauth2/version.rb
CHANGED
data/oauth2.gemspec
CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/oauth2/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.add_dependency 'faraday', '~> 0.8'
|
6
6
|
gem.add_dependency 'httpauth', '~> 0.1'
|
7
|
-
gem.add_dependency 'multi_json', '~> 1.
|
7
|
+
gem.add_dependency 'multi_json', '~> 1.0'
|
8
8
|
gem.add_dependency 'rack', '~> 1.4'
|
9
9
|
gem.add_development_dependency 'addressable'
|
10
10
|
gem.add_development_dependency 'multi_xml'
|
data/spec/helper.rb
CHANGED
@@ -4,8 +4,8 @@ VERBS = [:get, :post, :put, :delete]
|
|
4
4
|
|
5
5
|
describe AccessToken do
|
6
6
|
let(:token) {'monkey'}
|
7
|
-
let(:token_body) {MultiJson.
|
8
|
-
let(:refresh_body) {MultiJson.
|
7
|
+
let(:token_body) {MultiJson.encode(:access_token => 'foo', :expires_in => 600, :refresh_token => 'bar')}
|
8
|
+
let(:refresh_body) {MultiJson.encode(:access_token => 'refreshed_foo', :expires_in => 600, :refresh_token => 'refresh_bar')}
|
9
9
|
let(:client) do
|
10
10
|
Client.new('abc', 'def', :site => 'https://api.example.com') do |builder|
|
11
11
|
builder.request :url_encoded
|
data/spec/oauth2/client_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe OAuth2::Client do
|
|
10
10
|
stub.get('/success') {|env| [200, {'Content-Type' => 'text/awesome'}, 'yay']}
|
11
11
|
stub.get('/reflect') {|env| [200, {}, env[:body]]}
|
12
12
|
stub.post('/reflect') {|env| [200, {}, env[:body]]}
|
13
|
-
stub.get('/unauthorized') {|env| [401, {'Content-Type' => 'application/json'}, MultiJson.
|
13
|
+
stub.get('/unauthorized') {|env| [401, {'Content-Type' => 'application/json'}, MultiJson.encode(:error => error_value, :error_description => error_description_value)]}
|
14
14
|
stub.get('/conflict') {|env| [409, {'Content-Type' => 'text/plain'}, 'not authorized']}
|
15
15
|
stub.get('/redirect') {|env| [302, {'Content-Type' => 'text/plain', 'location' => '/success' }, '']}
|
16
16
|
stub.post('/redirect') {|env| [303, {'Content-Type' => 'text/plain', 'location' => '/reflect' }, '']}
|
@@ -52,7 +52,7 @@ describe OAuth2::Response do
|
|
52
52
|
|
53
53
|
it "parses application/json body" do
|
54
54
|
headers = {'Content-Type' => 'application/json'}
|
55
|
-
body = MultiJson.
|
55
|
+
body = MultiJson.encode(:foo => 'bar', :answer => 42)
|
56
56
|
response = double('response', :headers => headers, :body => body)
|
57
57
|
subject = Response.new(response)
|
58
58
|
subject.parsed.keys.size.should == 2
|
@@ -67,6 +67,7 @@ describe OAuth2::Response do
|
|
67
67
|
response = double('response', :headers => headers, :body => body)
|
68
68
|
|
69
69
|
MultiJson.should_not_receive(:decode)
|
70
|
+
MultiJson.should_not_receive(:load)
|
70
71
|
Rack::Utils.should_not_receive(:parse_query)
|
71
72
|
|
72
73
|
subject = Response.new(response)
|
@@ -4,7 +4,7 @@ describe OAuth2::Strategy::AuthCode do
|
|
4
4
|
let(:code) {'sushi'}
|
5
5
|
let(:kvform_token) {'expires_in=600&access_token=salmon&refresh_token=trout&extra_param=steve'}
|
6
6
|
let(:facebook_token) {kvform_token.gsub('_in', '')}
|
7
|
-
let(:json_token) {MultiJson.
|
7
|
+
let(:json_token) {MultiJson.encode(:expires_in => 600, :access_token => 'salmon', :refresh_token => 'trout', :extra_param => 'steve')}
|
8
8
|
|
9
9
|
let(:client) do
|
10
10
|
OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com') do |builder|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Bleigh
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-04-
|
19
|
+
date: 2012-04-27 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: faraday
|
@@ -56,11 +56,11 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - ~>
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
hash:
|
59
|
+
hash: 15
|
60
60
|
segments:
|
61
61
|
- 1
|
62
|
-
-
|
63
|
-
version: "1.
|
62
|
+
- 0
|
63
|
+
version: "1.0"
|
64
64
|
type: :runtime
|
65
65
|
version_requirements: *id003
|
66
66
|
- !ruby/object:Gem::Dependency
|