doorkeeper 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of doorkeeper might be problematic. Click here for more details.

Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/CHANGELOG.md +14 -2
  4. data/README.md +93 -42
  5. data/app/controllers/doorkeeper/application_controller.rb +1 -1
  6. data/app/controllers/doorkeeper/applications_controller.rb +4 -4
  7. data/app/controllers/doorkeeper/authorizations_controller.rb +3 -3
  8. data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
  9. data/app/controllers/doorkeeper/token_info_controller.rb +3 -3
  10. data/app/controllers/doorkeeper/tokens_controller.rb +29 -2
  11. data/app/helpers/doorkeeper/form_errors_helper.rb +2 -2
  12. data/app/validators/redirect_uri_validator.rb +1 -1
  13. data/app/views/doorkeeper/applications/_form.html.erb +3 -3
  14. data/app/views/doorkeeper/applications/edit.html.erb +1 -1
  15. data/app/views/doorkeeper/applications/new.html.erb +1 -1
  16. data/app/views/doorkeeper/applications/show.html.erb +1 -1
  17. data/app/views/doorkeeper/authorizations/new.html.erb +5 -5
  18. data/doorkeeper.gemspec +1 -1
  19. data/lib/doorkeeper.rb +31 -31
  20. data/lib/doorkeeper/config.rb +66 -37
  21. data/lib/doorkeeper/doorkeeper_for.rb +6 -3
  22. data/lib/doorkeeper/engine.rb +2 -2
  23. data/lib/doorkeeper/helpers/controller.rb +9 -9
  24. data/lib/doorkeeper/helpers/filter.rb +1 -1
  25. data/lib/doorkeeper/models/access_grant.rb +5 -5
  26. data/lib/doorkeeper/models/access_token.rb +22 -18
  27. data/lib/doorkeeper/models/active_record/access_token.rb +8 -8
  28. data/lib/doorkeeper/models/active_record/application.rb +5 -5
  29. data/lib/doorkeeper/models/application.rb +8 -9
  30. data/lib/doorkeeper/models/expirable.rb +1 -1
  31. data/lib/doorkeeper/models/mongo_mapper/access_grant.rb +2 -2
  32. data/lib/doorkeeper/models/mongo_mapper/access_token.rb +11 -11
  33. data/lib/doorkeeper/models/mongo_mapper/application.rb +4 -4
  34. data/lib/doorkeeper/models/mongoid/version.rb +2 -2
  35. data/lib/doorkeeper/models/mongoid2/access_grant.rb +7 -7
  36. data/lib/doorkeeper/models/mongoid2/access_token.rb +14 -14
  37. data/lib/doorkeeper/models/mongoid2/application.rb +7 -7
  38. data/lib/doorkeeper/models/mongoid3_4/access_grant.rb +7 -7
  39. data/lib/doorkeeper/models/mongoid3_4/access_token.rb +13 -13
  40. data/lib/doorkeeper/models/mongoid3_4/application.rb +6 -6
  41. data/lib/doorkeeper/models/ownership.rb +5 -5
  42. data/lib/doorkeeper/oauth/authorization/code.rb +5 -5
  43. data/lib/doorkeeper/oauth/authorization/token.rb +7 -7
  44. data/lib/doorkeeper/oauth/authorization_code_request.rb +18 -19
  45. data/lib/doorkeeper/oauth/client.rb +1 -1
  46. data/lib/doorkeeper/oauth/client_credentials/creator.rb +4 -4
  47. data/lib/doorkeeper/oauth/client_credentials/issuer.rb +6 -4
  48. data/lib/doorkeeper/oauth/client_credentials/validation.rb +2 -2
  49. data/lib/doorkeeper/oauth/client_credentials_request.rb +11 -15
  50. data/lib/doorkeeper/oauth/code_request.rb +5 -4
  51. data/lib/doorkeeper/oauth/code_response.rb +8 -7
  52. data/lib/doorkeeper/oauth/error.rb +1 -1
  53. data/lib/doorkeeper/oauth/error_response.rb +5 -5
  54. data/lib/doorkeeper/oauth/helpers/uri_checker.rb +1 -1
  55. data/lib/doorkeeper/oauth/invalid_token_response.rb +10 -10
  56. data/lib/doorkeeper/oauth/password_access_token_request.rb +57 -54
  57. data/lib/doorkeeper/oauth/pre_authorization.rb +7 -7
  58. data/lib/doorkeeper/oauth/refresh_token_request.rb +27 -24
  59. data/lib/doorkeeper/oauth/scopes.rb +3 -3
  60. data/lib/doorkeeper/oauth/token.rb +27 -1
  61. data/lib/doorkeeper/oauth/token_request.rb +14 -4
  62. data/lib/doorkeeper/rails/routes.rb +31 -22
  63. data/lib/doorkeeper/rails/routes/mapping.rb +11 -12
  64. data/lib/doorkeeper/request.rb +5 -5
  65. data/lib/doorkeeper/version.rb +1 -1
  66. data/lib/generators/doorkeeper/application_owner_generator.rb +1 -1
  67. data/lib/generators/doorkeeper/install_generator.rb +5 -5
  68. data/lib/generators/doorkeeper/migration_generator.rb +1 -1
  69. data/lib/generators/doorkeeper/mongo_mapper/indexes_generator.rb +2 -2
  70. data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +2 -2
  71. data/lib/generators/doorkeeper/templates/initializer.rb +16 -3
  72. data/lib/generators/doorkeeper/templates/migration.rb +16 -17
  73. data/lib/generators/doorkeeper/views_generator.rb +1 -1
  74. data/spec/controllers/applications_controller_spec.rb +7 -7
  75. data/spec/controllers/authorizations_controller_spec.rb +48 -48
  76. data/spec/controllers/protected_resources_controller_spec.rb +108 -107
  77. data/spec/controllers/token_info_controller_spec.rb +11 -11
  78. data/spec/controllers/tokens_controller_spec.rb +8 -8
  79. data/spec/dummy/app/controllers/custom_authorizations_controller.rb +2 -2
  80. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +3 -3
  81. data/spec/dummy/app/controllers/home_controller.rb +5 -5
  82. data/spec/dummy/app/controllers/metal_controller.rb +1 -1
  83. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +2 -2
  84. data/spec/dummy/app/models/user.rb +3 -3
  85. data/spec/dummy/config/application.rb +8 -9
  86. data/spec/dummy/config/boot.rb +1 -1
  87. data/spec/dummy/config/environments/test.rb +1 -1
  88. data/spec/dummy/config/initializers/doorkeeper.rb +5 -5
  89. data/spec/dummy/config/initializers/session_store.rb +1 -1
  90. data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
  91. data/spec/dummy/config/routes.rb +27 -27
  92. data/spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb +16 -17
  93. data/spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb +3 -3
  94. data/spec/dummy/db/schema.rb +39 -39
  95. data/spec/factories/access_grant.rb +3 -3
  96. data/spec/factories/access_token.rb +1 -1
  97. data/spec/factories/application.rb +3 -3
  98. data/spec/generators/application_owner_generator_spec.rb +6 -7
  99. data/spec/generators/install_generator_spec.rb +9 -9
  100. data/spec/generators/migration_generator_spec.rb +4 -4
  101. data/spec/lib/config_spec.rb +136 -44
  102. data/spec/lib/models/expirable_spec.rb +9 -9
  103. data/spec/lib/models/revocable_spec.rb +4 -4
  104. data/spec/lib/oauth/authorization/uri_builder_spec.rb +4 -4
  105. data/spec/lib/oauth/authorization_code_request_spec.rb +2 -2
  106. data/spec/lib/oauth/client/credentials_spec.rb +4 -4
  107. data/spec/lib/oauth/client/methods_spec.rb +10 -10
  108. data/spec/lib/oauth/client_credentials/issuer_spec.rb +9 -7
  109. data/spec/lib/oauth/client_credentials/validation_spec.rb +2 -2
  110. data/spec/lib/oauth/client_credentials_request_spec.rb +6 -6
  111. data/spec/lib/oauth/client_spec.rb +4 -4
  112. data/spec/lib/oauth/code_request_spec.rb +10 -9
  113. data/spec/lib/oauth/error_response_spec.rb +8 -8
  114. data/spec/lib/oauth/error_spec.rb +1 -1
  115. data/spec/lib/oauth/helpers/scope_checker_spec.rb +17 -17
  116. data/spec/lib/oauth/helpers/unique_token_spec.rb +7 -7
  117. data/spec/lib/oauth/helpers/uri_checker_spec.rb +33 -33
  118. data/spec/lib/oauth/invalid_token_response_spec.rb +4 -4
  119. data/spec/lib/oauth/password_access_token_request_spec.rb +13 -13
  120. data/spec/lib/oauth/pre_authorization_spec.rb +47 -7
  121. data/spec/lib/oauth/refresh_token_request_spec.rb +11 -21
  122. data/spec/lib/oauth/scopes_spec.rb +32 -32
  123. data/spec/lib/oauth/token_request_spec.rb +10 -9
  124. data/spec/lib/oauth/token_response_spec.rb +13 -15
  125. data/spec/lib/oauth/token_spec.rb +24 -10
  126. data/spec/lib/server_spec.rb +24 -2
  127. data/spec/models/doorkeeper/access_grant_spec.rb +8 -8
  128. data/spec/models/doorkeeper/access_token_spec.rb +79 -33
  129. data/spec/models/doorkeeper/application_spec.rb +29 -29
  130. data/spec/requests/applications/applications_request_spec.rb +15 -15
  131. data/spec/requests/applications/authorized_applications_spec.rb +7 -7
  132. data/spec/requests/endpoints/authorization_spec.rb +19 -12
  133. data/spec/requests/endpoints/token_spec.rb +26 -8
  134. data/spec/requests/flows/authorization_code_errors_spec.rb +17 -17
  135. data/spec/requests/flows/authorization_code_spec.rb +28 -28
  136. data/spec/requests/flows/client_credentials_spec.rb +3 -3
  137. data/spec/requests/flows/implicit_grant_errors_spec.rb +5 -5
  138. data/spec/requests/flows/implicit_grant_spec.rb +2 -2
  139. data/spec/requests/flows/password_spec.rb +32 -32
  140. data/spec/requests/flows/refresh_token_spec.rb +23 -23
  141. data/spec/requests/flows/revoke_token_spec.rb +165 -0
  142. data/spec/requests/flows/skip_authorization_spec.rb +10 -10
  143. data/spec/requests/protected_resources/metal_spec.rb +1 -1
  144. data/spec/requests/protected_resources/private_api_spec.rb +5 -5
  145. data/spec/routing/custom_controller_routes_spec.rb +4 -0
  146. data/spec/routing/default_routes_spec.rb +5 -1
  147. data/spec/spec_helper.rb +2 -2
  148. data/spec/spec_helper_integration.rb +8 -10
  149. data/spec/support/helpers/access_token_request_helper.rb +3 -3
  150. data/spec/support/helpers/authorization_request_helper.rb +3 -3
  151. data/spec/support/helpers/config_helper.rb +1 -1
  152. data/spec/support/helpers/model_helper.rb +2 -2
  153. data/spec/support/helpers/request_spec_helper.rb +3 -3
  154. data/spec/support/helpers/url_helper.rb +25 -21
  155. data/spec/support/orm/active_record.rb +4 -4
  156. data/spec/support/orm/mongo_mapper.rb +2 -3
  157. data/spec/support/orm/mongoid.rb +5 -6
  158. data/spec/support/shared/controllers_shared_context.rb +15 -15
  159. data/spec/support/shared/models_shared_examples.rb +13 -13
  160. data/spec/validators/redirect_uri_validator_spec.rb +9 -9
  161. metadata +5 -4
@@ -2,207 +2,207 @@ require 'spec_helper_integration'
2
2
 
3
3
  module ControllerActions
4
4
  def index
5
- render :text => "index"
5
+ render text: 'index'
6
6
  end
7
7
 
8
8
  def show
9
- render :text => "show"
9
+ render text: 'show'
10
10
  end
11
11
  end
12
12
 
13
- shared_examples "specified for particular actions" do
14
- context "with valid token", :token => :valid do
15
- it "allows into index action" do
16
- get :index, :access_token => token_string
13
+ shared_examples 'specified for particular actions' do
14
+ context 'with valid token', token: :valid do
15
+ it 'allows into index action' do
16
+ get :index, access_token: token_string
17
17
  expect(response).to be_success
18
18
  end
19
19
 
20
- it "allows into show action" do
21
- get :show, :id => "3", :access_token => token_string
20
+ it 'allows into show action' do
21
+ get :show, id: '3', access_token: token_string
22
22
  expect(response).to be_success
23
23
  end
24
24
  end
25
25
 
26
- context "with invalid token", :token => :invalid do
27
- include_context "invalid token"
26
+ context 'with invalid token', token: :invalid do
27
+ include_context 'invalid token'
28
28
 
29
- it "does not allow into index action" do
30
- get :index, :access_token => token_string
29
+ it 'does not allow into index action' do
30
+ get :index, access_token: token_string
31
31
  expect(response.status).to eq 401
32
- expect(response.headers["WWW-Authenticate"]).to match(/^Bearer/)
32
+ expect(response.headers['WWW-Authenticate']).to match(/^Bearer/)
33
33
  end
34
34
 
35
- it "allows into show action" do
36
- get :show, :id => "5", :access_token => token_string
35
+ it 'allows into show action' do
36
+ get :show, id: '5', access_token: token_string
37
37
  expect(response).to be_success
38
38
  end
39
39
  end
40
40
  end
41
41
 
42
- shared_examples "specified with except" do
43
- context "with valid token", :token => :valid do
44
- it "allows into index action" do
45
- get :index, :access_token => token_string
42
+ shared_examples 'specified with except' do
43
+ context 'with valid token', token: :valid do
44
+ it 'allows into index action' do
45
+ get :index, access_token: token_string
46
46
  expect(response).to be_success
47
47
  end
48
48
 
49
- it "allows into show action" do
50
- get :show, :id => "4", :access_token => token_string
49
+ it 'allows into show action' do
50
+ get :show, id: '4', access_token: token_string
51
51
  expect(response).to be_success
52
52
  end
53
53
  end
54
54
 
55
- context "with invalid token", :token => :invalid do
56
- it "allows into index action" do
57
- get :index, :access_token => token_string
55
+ context 'with invalid token', token: :invalid do
56
+ it 'allows into index action' do
57
+ get :index, access_token: token_string
58
58
  expect(response).to be_success
59
59
  end
60
60
 
61
- it "does not allow into show action" do
62
- get :show, :id => "14", :access_token => token_string
61
+ it 'does not allow into show action' do
62
+ get :show, id: '14', access_token: token_string
63
63
  expect(response.status).to eq 401
64
- expect(response.headers["WWW-Authenticate"]).to match(/^Bearer/)
64
+ expect(response.headers['WWW-Authenticate']).to match(/^Bearer/)
65
65
  end
66
66
  end
67
67
  end
68
68
 
69
- describe "Doorkeeper_for helper" do
70
- context "accepts token code specified as" do
69
+ describe 'Doorkeeper_for helper' do
70
+ context 'accepts token code specified as' do
71
71
  controller do
72
72
  doorkeeper_for :all
73
73
 
74
74
  def index
75
- render :text => "index"
75
+ render text: 'index'
76
76
  end
77
77
  end
78
78
 
79
- let(:token_string) { "1A2BC3" }
79
+ let(:token_string) { '1A2BC3' }
80
80
 
81
- it "access_token param" do
81
+ it 'access_token param' do
82
82
  expect(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string)
83
- get :index, :access_token => token_string
83
+ get :index, access_token: token_string
84
84
  end
85
85
 
86
- it "bearer_token param" do
86
+ it 'bearer_token param' do
87
87
  expect(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string)
88
- get :index, :bearer_token => token_string
88
+ get :index, bearer_token: token_string
89
89
  end
90
90
 
91
- it "Authorization header" do
91
+ it 'Authorization header' do
92
92
  expect(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string)
93
- request.env["HTTP_AUTHORIZATION"] = "Bearer #{token_string}"
93
+ request.env['HTTP_AUTHORIZATION'] = "Bearer #{token_string}"
94
94
  get :index
95
95
  end
96
96
 
97
- it "different kind of Authorization header" do
97
+ it 'different kind of Authorization header' do
98
98
  expect(Doorkeeper::AccessToken).not_to receive(:authenticate)
99
- request.env["HTTP_AUTHORIZATION"] = "Basic #{Base64.encode64("foo:bar")}"
99
+ request.env['HTTP_AUTHORIZATION'] = "MAC #{token_string}"
100
100
  get :index
101
101
  end
102
102
 
103
- it "doesn't change Authorization header value" do
103
+ it 'does not change Authorization header value' do
104
104
  expect(Doorkeeper::AccessToken).to receive(:authenticate).exactly(2).times
105
- request.env["HTTP_AUTHORIZATION"] = "Bearer #{token_string}"
105
+ request.env['HTTP_AUTHORIZATION'] = "Bearer #{token_string}"
106
106
  get :index
107
107
  controller.send(:remove_instance_variable, :@token)
108
108
  get :index
109
109
  end
110
110
  end
111
111
 
112
- context "defined for all actions" do
112
+ context 'defined for all actions' do
113
113
  controller do
114
114
  doorkeeper_for :all
115
115
 
116
116
  include ControllerActions
117
117
  end
118
118
 
119
- context "with valid token", :token => :valid do
120
- it "allows into index action" do
121
- get :index, :access_token => token_string
119
+ context 'with valid token', token: :valid do
120
+ it 'allows into index action' do
121
+ get :index, access_token: token_string
122
122
  expect(response).to be_success
123
123
  end
124
124
 
125
- it "allows into show action" do
126
- get :show, :id => "4", :access_token => token_string
125
+ it 'allows into show action' do
126
+ get :show, id: '4', access_token: token_string
127
127
  expect(response).to be_success
128
128
  end
129
129
  end
130
130
 
131
- context "with invalid token", :token => :invalid do
132
- it "does not allow into index action" do
133
- get :index, :access_token => token_string
131
+ context 'with invalid token', token: :invalid do
132
+ it 'does not allow into index action' do
133
+ get :index, access_token: token_string
134
134
  expect(response.status).to eq 401
135
- expect(response.header["WWW-Authenticate"]).to match(/^Bearer/)
135
+ expect(response.header['WWW-Authenticate']).to match(/^Bearer/)
136
136
  end
137
137
 
138
- it "does not allow into show action" do
139
- get :show, :id => "4", :access_token => token_string
138
+ it 'does not allow into show action' do
139
+ get :show, id: '4', access_token: token_string
140
140
  expect(response.status).to eq 401
141
- expect(response.header["WWW-Authenticate"]).to match(/^Bearer/)
141
+ expect(response.header['WWW-Authenticate']).to match(/^Bearer/)
142
142
  end
143
143
  end
144
144
  end
145
145
 
146
- context "defined only for index action" do
146
+ context 'defined only for index action' do
147
147
  controller do
148
148
  doorkeeper_for :index
149
149
 
150
150
  include ControllerActions
151
151
  end
152
- include_examples "specified for particular actions"
152
+ include_examples 'specified for particular actions'
153
153
  end
154
154
 
155
- context "defined for actions except index" do
155
+ context 'defined for actions except index' do
156
156
  controller do
157
- doorkeeper_for :all, :except => :index
157
+ doorkeeper_for :all, except: :index
158
158
 
159
159
  include ControllerActions
160
160
  end
161
- include_examples "specified with except"
161
+ include_examples 'specified with except'
162
162
  end
163
163
 
164
- context "defined with scopes" do
164
+ context 'defined with scopes' do
165
165
  controller do
166
- doorkeeper_for :all, :scopes => [:write]
166
+ doorkeeper_for :all, scopes: [:write]
167
167
 
168
168
  include ControllerActions
169
169
  end
170
170
 
171
- let(:token_string) { "1A2DUWE" }
171
+ let(:token_string) { '1A2DUWE' }
172
172
 
173
- it "allows if the token has particular scopes" do
174
- token = double(Doorkeeper::AccessToken, :accessible? => true, :scopes => ['write', 'public'])
173
+ it 'allows if the token has particular scopes' do
174
+ token = double(Doorkeeper::AccessToken, accessible?: true, scopes: %w(write public))
175
175
  expect(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string).and_return(token)
176
- get :index, :access_token => token_string
176
+ get :index, access_token: token_string
177
177
  expect(response).to be_success
178
178
  end
179
179
 
180
- it "does not allow if the token does not include given scope" do
181
- token = double(Doorkeeper::AccessToken, :accessible? => true, :scopes => ['public'], :revoked? => false, :expired? => false)
180
+ it 'does not allow if the token does not include given scope' do
181
+ token = double(Doorkeeper::AccessToken, accessible?: true, scopes: ['public'], revoked?: false, expired?: false)
182
182
  expect(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string).and_return(token)
183
- get :index, :access_token => token_string
183
+ get :index, access_token: token_string
184
184
  expect(response.status).to eq 401
185
- expect(response.header["WWW-Authenticate"]).to match(/^Bearer/)
185
+ expect(response.header['WWW-Authenticate']).to match(/^Bearer/)
186
186
  end
187
187
  end
188
188
 
189
- context "when custom unauthorized render options are configured" do
189
+ context 'when custom unauthorized render options are configured' do
190
190
  controller do
191
191
  doorkeeper_for :all
192
192
 
193
193
  include ControllerActions
194
194
  end
195
195
 
196
- context "with a JSON custom render", :token => :invalid do
196
+ context 'with a JSON custom render', token: :invalid do
197
197
  before do
198
- expect(controller).to receive(:doorkeeper_unauthorized_render_options).and_return({ :json => ActiveSupport::JSON.encode({ :error => "Unauthorized" }) } )
198
+ expect(controller).to receive(:doorkeeper_unauthorized_render_options).and_return(json: ActiveSupport::JSON.encode(error: 'Unauthorized'))
199
199
  end
200
200
 
201
- it "it renders a custom JSON response", :token => :invalid do
202
- get :index, :access_token => token_string
201
+ it 'it renders a custom JSON response', token: :invalid do
202
+ get :index, access_token: token_string
203
203
  expect(response.status).to eq 401
204
204
  expect(response.content_type).to eq('application/json')
205
- expect(response.header["WWW-Authenticate"]).to match(/^Bearer/)
205
+ expect(response.header['WWW-Authenticate']).to match(/^Bearer/)
206
206
  parsed_body = JSON.parse(response.body)
207
207
  expect(parsed_body).not_to be_nil
208
208
  expect(parsed_body['error']).to eq('Unauthorized')
@@ -210,29 +210,30 @@ describe "Doorkeeper_for helper" do
210
210
 
211
211
  end
212
212
 
213
- context "with a text custom render", :token => :invalid do
213
+ context 'with a text custom render', token: :invalid do
214
214
  before do
215
- expect(controller).to receive(:doorkeeper_unauthorized_render_options).and_return({ :text => "Unauthorized" } )
215
+ expect(controller).to receive(:doorkeeper_unauthorized_render_options).and_return(text: 'Unauthorized')
216
216
  end
217
217
 
218
- it "it renders a custom JSON response", :token => :invalid do
219
- get :index, :access_token => token_string
218
+ it 'it renders a custom JSON response', token: :invalid do
219
+ get :index, access_token: token_string
220
220
  expect(response.status).to eq 401
221
221
  expect(response.content_type).to eq('text/html')
222
- expect(response.header["WWW-Authenticate"]).to match(/^Bearer/)
222
+ expect(response.header['WWW-Authenticate']).to match(/^Bearer/)
223
223
  expect(response.body).to eq('Unauthorized')
224
224
  end
225
225
  end
226
226
  end
227
227
 
228
- context "when defined with conditional if block" do
228
+ context 'when defined with conditional if block' do
229
229
  controller do
230
- doorkeeper_for :index, :if => lambda { the_false }
231
- doorkeeper_for :show, :if => lambda { the_true }
230
+ doorkeeper_for :index, if: -> { the_false }
231
+ doorkeeper_for :show, if: -> { the_true }
232
232
 
233
233
  include ControllerActions
234
234
 
235
235
  private
236
+
236
237
  def the_true
237
238
  true
238
239
  end
@@ -242,36 +243,36 @@ describe "Doorkeeper_for helper" do
242
243
  end
243
244
  end
244
245
 
245
- context "with valid token", :token => :valid do
246
- it "enables access if passed block evaluates to false" do
247
- get :index, :access_token => token_string
246
+ context 'with valid token', token: :valid do
247
+ it 'enables access if passed block evaluates to false' do
248
+ get :index, access_token: token_string
248
249
  expect(response).to be_success
249
250
  end
250
251
 
251
- it "enables access if passed block evaluates to true" do
252
- get :show, :id => 1, :access_token => token_string
252
+ it 'enables access if passed block evaluates to true' do
253
+ get :show, id: 1, access_token: token_string
253
254
  expect(response).to be_success
254
255
  end
255
256
  end
256
257
 
257
- context "with invalid token", :token => :invalid do
258
- it "enables access if passed block evaluates to false" do
259
- get :index, :access_token => token_string
258
+ context 'with invalid token', token: :invalid do
259
+ it 'enables access if passed block evaluates to false' do
260
+ get :index, access_token: token_string
260
261
  expect(response).to be_success
261
262
  end
262
263
 
263
- it "does not enable access if passed block evaluates to true" do
264
- get :show, :id => 3, :access_token => token_string
264
+ it 'does not enable access if passed block evaluates to true' do
265
+ get :show, id: 3, access_token: token_string
265
266
  expect(response.status).to eq 401
266
- expect(response.header["WWW-Authenticate"]).to match(/^Bearer/)
267
+ expect(response.header['WWW-Authenticate']).to match(/^Bearer/)
267
268
  end
268
269
  end
269
270
  end
270
271
 
271
- context "when defined with conditional unless block" do
272
+ context 'when defined with conditional unless block' do
272
273
  controller do
273
- doorkeeper_for :index, :unless => lambda { the_false }
274
- doorkeeper_for :show, :unless => lambda { the_true }
274
+ doorkeeper_for :index, unless: -> { the_false }
275
+ doorkeeper_for :show, unless: -> { the_true }
275
276
 
276
277
  include ControllerActions
277
278
 
@@ -286,25 +287,25 @@ describe "Doorkeeper_for helper" do
286
287
  end
287
288
  end
288
289
 
289
- context "with valid token", :token => :valid do
290
- it "allows access if passed block evaluates to false" do
291
- get :index, :access_token => token_string
290
+ context 'with valid token', token: :valid do
291
+ it 'allows access if passed block evaluates to false' do
292
+ get :index, access_token: token_string
292
293
  expect(response).to be_success
293
294
  end
294
295
 
295
- it "allows access if passed block evaluates to true" do
296
- get :show, :id => 1, :access_token => token_string
296
+ it 'allows access if passed block evaluates to true' do
297
+ get :show, id: 1, access_token: token_string
297
298
  expect(response).to be_success
298
299
  end
299
300
  end
300
301
 
301
- context "with invalid token", :token => :invalid do
302
- it "does not allow access if passed block evaluates to false" do
303
- get :index, :access_token => token_string
302
+ context 'with invalid token', token: :invalid do
303
+ it 'does not allow access if passed block evaluates to false' do
304
+ get :index, access_token: token_string
304
305
  end
305
306
 
306
- it "allows access if passed block evaluates to true" do
307
- get :show, :id => 3, :access_token => token_string
307
+ it 'allows access if passed block evaluates to true' do
308
+ get :show, id: 3, access_token: token_string
308
309
  expect(response).to be_success
309
310
  end
310
311
  end
@@ -2,7 +2,7 @@ require 'spec_helper_integration'
2
2
 
3
3
  describe Doorkeeper::TokenInfoController do
4
4
 
5
- describe "when requesting tokeninfo with valid token" do
5
+ describe 'when requesting tokeninfo with valid token' do
6
6
 
7
7
  let(:doorkeeper_token) { FactoryGirl.create(:access_token) }
8
8
 
@@ -14,40 +14,40 @@ describe Doorkeeper::TokenInfoController do
14
14
  get :show
15
15
  end
16
16
 
17
- describe "successful request" do
17
+ describe 'successful request' do
18
18
 
19
- it "responds with tokeninfo" do
19
+ it 'responds with tokeninfo' do
20
20
  do_get
21
21
  expect(response.body).to eq(doorkeeper_token.to_json)
22
22
  end
23
23
 
24
- it "responds with a 200 status" do
24
+ it 'responds with a 200 status' do
25
25
  do_get
26
26
  expect(response.status).to eq 200
27
27
  end
28
28
  end
29
29
 
30
- describe "invalid token response" do
30
+ describe 'invalid token response' do
31
31
  before(:each) do
32
32
  allow(controller).to receive(:doorkeeper_token).and_return(nil)
33
33
  end
34
- it "responds with 401 when doorkeeper_token is not valid" do
34
+ it 'responds with 401 when doorkeeper_token is not valid' do
35
35
  do_get
36
36
  expect(response.status).to eq 401
37
- expect(response.headers["WWW-Authenticate"]).to match(/^Bearer/)
37
+ expect(response.headers['WWW-Authenticate']).to match(/^Bearer/)
38
38
  end
39
39
 
40
- it "responds with 401 when doorkeeper_token is invalid, expired or revoked" do
40
+ it 'responds with 401 when doorkeeper_token is invalid, expired or revoked' do
41
41
  allow(controller).to receive(:doorkeeper_token).and_return(doorkeeper_token)
42
42
  allow(doorkeeper_token).to receive(:accessible?).and_return(false)
43
43
  do_get
44
44
  expect(response.status).to eq 401
45
- expect(response.headers["WWW-Authenticate"]).to match(/^Bearer/)
45
+ expect(response.headers['WWW-Authenticate']).to match(/^Bearer/)
46
46
  end
47
47
 
48
- it "responds body message for error" do
48
+ it 'responds body message for error' do
49
49
  do_get
50
- expect(response.body).to eq(Doorkeeper::OAuth::ErrorResponse.new(:name => :invalid_request, :status => :unauthorized).body.to_json)
50
+ expect(response.body).to eq(Doorkeeper::OAuth::ErrorResponse.new(name: :invalid_request, status: :unauthorized).body.to_json)
51
51
  end
52
52
  end
53
53