rack-oauth2 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +4 -4
- data/VERSION +1 -1
- data/lib/rack/oauth2/client/grant.rb +4 -2
- data/lib/rack/oauth2/client/grant/authorization_code.rb +2 -1
- data/spec/rack/oauth2/access_token/legacy_spec.rb +1 -1
- data/spec/rack/oauth2/client/grant/authorization_code_spec.rb +36 -0
- data/spec/rack/oauth2/client/grant/client_credentials_spec.rb +7 -0
- data/spec/rack/oauth2/client/grant/password_spec.rb +33 -0
- data/spec/rack/oauth2/client/grant/refresh_token_spec.rb +21 -0
- data/spec/rack/oauth2/server/abstract/error_spec.rb +8 -0
- metadata +66 -2
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rack-oauth2 (0.8.
|
4
|
+
rack-oauth2 (0.8.5)
|
5
5
|
activesupport (>= 2.3)
|
6
6
|
attr_required (>= 0.0.3)
|
7
7
|
httpclient (>= 2.2.0.2)
|
@@ -24,10 +24,10 @@ GEM
|
|
24
24
|
bouncy-castle-java
|
25
25
|
json (1.5.3)
|
26
26
|
json (1.5.3-java)
|
27
|
-
rack (1.3.
|
27
|
+
rack (1.3.2)
|
28
28
|
rake (0.9.2)
|
29
|
-
rcov (0.9.
|
30
|
-
rcov (0.9.
|
29
|
+
rcov (0.9.10)
|
30
|
+
rcov (0.9.10-java)
|
31
31
|
rspec (2.6.0)
|
32
32
|
rspec-core (~> 2.6.0)
|
33
33
|
rspec-expectations (~> 2.6.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.6
|
@@ -5,17 +5,19 @@ module Rack
|
|
5
5
|
include AttrRequired, AttrOptional
|
6
6
|
|
7
7
|
def initialize(attributes = {})
|
8
|
-
required_attributes.each do |key|
|
8
|
+
(required_attributes + optional_attributes).each do |key|
|
9
9
|
self.send "#{key}=", attributes[key]
|
10
10
|
end
|
11
11
|
attr_missing!
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_hash
|
15
|
-
required_attributes.inject({
|
15
|
+
(required_attributes + optional_attributes).inject({
|
16
16
|
:grant_type => self.class.name.demodulize.underscore.to_sym
|
17
17
|
}) do |hash, key|
|
18
18
|
hash.merge! key => self.send(key)
|
19
|
+
end.delete_if do |key, value|
|
20
|
+
value.blank?
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -16,7 +16,7 @@ describe Rack::OAuth2::AccessToken::Legacy do
|
|
16
16
|
|
17
17
|
describe '.authenticate' do
|
18
18
|
it 'should set Authorization header' do
|
19
|
-
request.header.should_receive(:[]=).with('Authorization', '
|
19
|
+
request.header.should_receive(:[]=).with('Authorization', 'OAuth access_token')
|
20
20
|
token.authenticate(request)
|
21
21
|
end
|
22
22
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe Rack::OAuth2::Client::Grant::AuthorizationCode do
|
4
|
+
let(:grant) { Rack::OAuth2::Client::Grant::AuthorizationCode }
|
5
|
+
|
6
|
+
context 'when code is given' do
|
7
|
+
let :attributes do
|
8
|
+
{:code => 'code'}
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'when redirect_uri is given' do
|
12
|
+
let :attributes do
|
13
|
+
{:code => 'code', :redirect_uri => 'https://client.example.com/callback'}
|
14
|
+
end
|
15
|
+
subject { grant.new attributes }
|
16
|
+
its(:redirect_uri) { should == 'https://client.example.com/callback' }
|
17
|
+
its(:to_hash) do
|
18
|
+
should == {:grant_type => :authorization_code, :code => 'code', :redirect_uri => 'https://client.example.com/callback'}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'otherwise' do
|
23
|
+
subject { grant.new attributes }
|
24
|
+
its(:redirect_uri) { should be_nil }
|
25
|
+
its(:to_hash) do
|
26
|
+
should == {:grant_type => :authorization_code, :code => 'code'}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'otherwise' do
|
32
|
+
it do
|
33
|
+
expect { grant.new }.should raise_error AttrRequired::AttrMissing
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe Rack::OAuth2::Client::Grant::Password do
|
4
|
+
let(:grant) { Rack::OAuth2::Client::Grant::Password }
|
5
|
+
|
6
|
+
context 'when username is given' do
|
7
|
+
let :attributes do
|
8
|
+
{:username => 'username'}
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'when password is given' do
|
12
|
+
let :attributes do
|
13
|
+
{:username => 'username', :password => 'password'}
|
14
|
+
end
|
15
|
+
subject { grant.new attributes }
|
16
|
+
its(:to_hash) do
|
17
|
+
should == {:grant_type => :password, :username => 'username', :password => 'password'}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'otherwise' do
|
22
|
+
it do
|
23
|
+
expect { grant.new attributes }.should raise_error AttrRequired::AttrMissing
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'otherwise' do
|
29
|
+
it do
|
30
|
+
expect { grant.new }.should raise_error AttrRequired::AttrMissing
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe Rack::OAuth2::Client::Grant::RefreshToken do
|
4
|
+
let(:grant) { Rack::OAuth2::Client::Grant::RefreshToken }
|
5
|
+
|
6
|
+
context 'when refresh_token is given' do
|
7
|
+
let :attributes do
|
8
|
+
{:refresh_token => 'refresh_token'}
|
9
|
+
end
|
10
|
+
subject { grant.new attributes }
|
11
|
+
its(:to_hash) do
|
12
|
+
should == {:grant_type => :refresh_token, :refresh_token => 'refresh_token'}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'otherwise' do
|
17
|
+
it do
|
18
|
+
expect { grant.new }.should raise_error AttrRequired::AttrMissing
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -49,3 +49,11 @@ end
|
|
49
49
|
describe Rack::OAuth2::Server::Abstract::Forbidden do
|
50
50
|
its(:status) { should == 403 }
|
51
51
|
end
|
52
|
+
|
53
|
+
describe Rack::OAuth2::Server::Abstract::ServerError do
|
54
|
+
its(:status) { should == 500 }
|
55
|
+
end
|
56
|
+
|
57
|
+
describe Rack::OAuth2::Server::Abstract::TemporarilyUnavailable do
|
58
|
+
its(:status) { should == 503 }
|
59
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 51
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
- 6
|
10
|
+
version: 0.8.6
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- nov matake
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-
|
18
|
+
date: 2011-08-09 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rack
|
@@ -20,6 +25,10 @@ dependencies:
|
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 13
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 1
|
23
32
|
version: "1.1"
|
24
33
|
type: :runtime
|
25
34
|
version_requirements: *id001
|
@@ -31,6 +40,11 @@ dependencies:
|
|
31
40
|
requirements:
|
32
41
|
- - ">="
|
33
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 1
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 4
|
47
|
+
- 3
|
34
48
|
version: 1.4.3
|
35
49
|
type: :runtime
|
36
50
|
version_requirements: *id002
|
@@ -42,6 +56,12 @@ dependencies:
|
|
42
56
|
requirements:
|
43
57
|
- - ">="
|
44
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 123
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 2
|
63
|
+
- 0
|
64
|
+
- 2
|
45
65
|
version: 2.2.0.2
|
46
66
|
type: :runtime
|
47
67
|
version_requirements: *id003
|
@@ -53,6 +73,10 @@ dependencies:
|
|
53
73
|
requirements:
|
54
74
|
- - ">="
|
55
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 5
|
77
|
+
segments:
|
78
|
+
- 2
|
79
|
+
- 3
|
56
80
|
version: "2.3"
|
57
81
|
type: :runtime
|
58
82
|
version_requirements: *id004
|
@@ -64,6 +88,9 @@ dependencies:
|
|
64
88
|
requirements:
|
65
89
|
- - ">="
|
66
90
|
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
92
|
+
segments:
|
93
|
+
- 0
|
67
94
|
version: "0"
|
68
95
|
type: :runtime
|
69
96
|
version_requirements: *id005
|
@@ -75,6 +102,11 @@ dependencies:
|
|
75
102
|
requirements:
|
76
103
|
- - ">="
|
77
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 25
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
- 0
|
109
|
+
- 3
|
78
110
|
version: 0.0.3
|
79
111
|
type: :runtime
|
80
112
|
version_requirements: *id006
|
@@ -86,6 +118,10 @@ dependencies:
|
|
86
118
|
requirements:
|
87
119
|
- - ">="
|
88
120
|
- !ruby/object:Gem::Version
|
121
|
+
hash: 27
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
- 8
|
89
125
|
version: "0.8"
|
90
126
|
type: :development
|
91
127
|
version_requirements: *id007
|
@@ -97,6 +133,10 @@ dependencies:
|
|
97
133
|
requirements:
|
98
134
|
- - ">="
|
99
135
|
- !ruby/object:Gem::Version
|
136
|
+
hash: 25
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
- 9
|
100
140
|
version: "0.9"
|
101
141
|
type: :development
|
102
142
|
version_requirements: *id008
|
@@ -108,6 +148,9 @@ dependencies:
|
|
108
148
|
requirements:
|
109
149
|
- - ">="
|
110
150
|
- !ruby/object:Gem::Version
|
151
|
+
hash: 7
|
152
|
+
segments:
|
153
|
+
- 2
|
111
154
|
version: "2"
|
112
155
|
type: :development
|
113
156
|
version_requirements: *id009
|
@@ -119,6 +162,11 @@ dependencies:
|
|
119
162
|
requirements:
|
120
163
|
- - ">="
|
121
164
|
- !ruby/object:Gem::Version
|
165
|
+
hash: 11
|
166
|
+
segments:
|
167
|
+
- 1
|
168
|
+
- 6
|
169
|
+
- 2
|
122
170
|
version: 1.6.2
|
123
171
|
type: :development
|
124
172
|
version_requirements: *id010
|
@@ -200,6 +248,10 @@ files:
|
|
200
248
|
- spec/rack/oauth2/access_token/mac_spec.rb
|
201
249
|
- spec/rack/oauth2/access_token_spec.rb
|
202
250
|
- spec/rack/oauth2/client/error_spec.rb
|
251
|
+
- spec/rack/oauth2/client/grant/authorization_code_spec.rb
|
252
|
+
- spec/rack/oauth2/client/grant/client_credentials_spec.rb
|
253
|
+
- spec/rack/oauth2/client/grant/password_spec.rb
|
254
|
+
- spec/rack/oauth2/client/grant/refresh_token_spec.rb
|
203
255
|
- spec/rack/oauth2/client_spec.rb
|
204
256
|
- spec/rack/oauth2/server/abstract/error_spec.rb
|
205
257
|
- spec/rack/oauth2/server/authorize/code_spec.rb
|
@@ -233,12 +285,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
233
285
|
requirements:
|
234
286
|
- - ">="
|
235
287
|
- !ruby/object:Gem::Version
|
288
|
+
hash: 3
|
289
|
+
segments:
|
290
|
+
- 0
|
236
291
|
version: "0"
|
237
292
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
293
|
none: false
|
239
294
|
requirements:
|
240
295
|
- - ">="
|
241
296
|
- !ruby/object:Gem::Version
|
297
|
+
hash: 23
|
298
|
+
segments:
|
299
|
+
- 1
|
300
|
+
- 3
|
301
|
+
- 6
|
242
302
|
version: 1.3.6
|
243
303
|
requirements: []
|
244
304
|
|
@@ -267,6 +327,10 @@ test_files:
|
|
267
327
|
- spec/rack/oauth2/access_token/mac_spec.rb
|
268
328
|
- spec/rack/oauth2/access_token_spec.rb
|
269
329
|
- spec/rack/oauth2/client/error_spec.rb
|
330
|
+
- spec/rack/oauth2/client/grant/authorization_code_spec.rb
|
331
|
+
- spec/rack/oauth2/client/grant/client_credentials_spec.rb
|
332
|
+
- spec/rack/oauth2/client/grant/password_spec.rb
|
333
|
+
- spec/rack/oauth2/client/grant/refresh_token_spec.rb
|
270
334
|
- spec/rack/oauth2/client_spec.rb
|
271
335
|
- spec/rack/oauth2/server/abstract/error_spec.rb
|
272
336
|
- spec/rack/oauth2/server/authorize/code_spec.rb
|