doorkeeper 5.0.2 → 5.1.0

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.
Files changed (214) hide show
  1. checksums.yaml +5 -5
  2. data/.hound.yml +2 -1
  3. data/.rubocop.yml +37 -4
  4. data/.travis.yml +11 -21
  5. data/Appraisals +29 -7
  6. data/Dangerfile +5 -2
  7. data/Gemfile +19 -5
  8. data/NEWS.md +80 -19
  9. data/README.md +75 -485
  10. data/Rakefile +10 -8
  11. data/app/controllers/doorkeeper/application_controller.rb +1 -2
  12. data/app/controllers/doorkeeper/application_metal_controller.rb +2 -13
  13. data/app/controllers/doorkeeper/applications_controller.rb +17 -5
  14. data/app/controllers/doorkeeper/token_info_controller.rb +2 -2
  15. data/app/controllers/doorkeeper/tokens_controller.rb +11 -11
  16. data/app/helpers/doorkeeper/dashboard_helper.rb +1 -1
  17. data/app/validators/redirect_uri_validator.rb +5 -2
  18. data/app/views/doorkeeper/applications/_form.html.erb +6 -0
  19. data/app/views/doorkeeper/applications/show.html.erb +1 -1
  20. data/app/views/layouts/doorkeeper/admin.html.erb +5 -3
  21. data/bin/console +16 -0
  22. data/config/locales/en.yml +1 -0
  23. data/doorkeeper.gemspec +24 -21
  24. data/gemfiles/rails_5_0.gemfile +9 -4
  25. data/gemfiles/rails_5_1.gemfile +9 -4
  26. data/gemfiles/rails_5_2.gemfile +10 -5
  27. data/gemfiles/rails_6_0.gemfile +17 -0
  28. data/gemfiles/rails_master.gemfile +9 -9
  29. data/lib/doorkeeper/config/option.rb +64 -0
  30. data/lib/doorkeeper/config.rb +191 -75
  31. data/lib/doorkeeper/engine.rb +1 -1
  32. data/lib/doorkeeper/grape/authorization_decorator.rb +4 -4
  33. data/lib/doorkeeper/grape/helpers.rb +3 -3
  34. data/lib/doorkeeper/helpers/controller.rb +3 -2
  35. data/lib/doorkeeper/models/access_grant_mixin.rb +20 -3
  36. data/lib/doorkeeper/models/access_token_mixin.rb +63 -19
  37. data/lib/doorkeeper/models/application_mixin.rb +43 -1
  38. data/lib/doorkeeper/models/concerns/expirable.rb +4 -2
  39. data/lib/doorkeeper/models/concerns/ownership.rb +1 -6
  40. data/lib/doorkeeper/models/concerns/reusable.rb +19 -0
  41. data/lib/doorkeeper/models/concerns/revocable.rb +2 -1
  42. data/lib/doorkeeper/models/concerns/scopes.rb +5 -1
  43. data/lib/doorkeeper/models/concerns/secret_storable.rb +108 -0
  44. data/lib/doorkeeper/oauth/authorization/code.rb +2 -2
  45. data/lib/doorkeeper/oauth/authorization/token.rb +12 -7
  46. data/lib/doorkeeper/oauth/authorization/uri_builder.rb +1 -1
  47. data/lib/doorkeeper/oauth/authorization_code_request.rb +6 -4
  48. data/lib/doorkeeper/oauth/client.rb +1 -1
  49. data/lib/doorkeeper/oauth/client_credentials/validation.rb +5 -4
  50. data/lib/doorkeeper/oauth/client_credentials_request.rb +1 -1
  51. data/lib/doorkeeper/oauth/code_response.rb +2 -2
  52. data/lib/doorkeeper/oauth/error_response.rb +10 -6
  53. data/lib/doorkeeper/oauth/forbidden_token_response.rb +1 -1
  54. data/lib/doorkeeper/oauth/helpers/scope_checker.rb +23 -8
  55. data/lib/doorkeeper/oauth/helpers/unique_token.rb +13 -1
  56. data/lib/doorkeeper/oauth/helpers/uri_checker.rb +37 -1
  57. data/lib/doorkeeper/oauth/invalid_token_response.rb +5 -1
  58. data/lib/doorkeeper/oauth/password_access_token_request.rb +7 -2
  59. data/lib/doorkeeper/oauth/pre_authorization.rb +11 -5
  60. data/lib/doorkeeper/oauth/refresh_token_request.rb +5 -2
  61. data/lib/doorkeeper/oauth/scopes.rb +5 -3
  62. data/lib/doorkeeper/oauth/token.rb +2 -2
  63. data/lib/doorkeeper/oauth/token_introspection.rb +74 -8
  64. data/lib/doorkeeper/oauth/token_response.rb +9 -9
  65. data/lib/doorkeeper/oauth.rb +5 -5
  66. data/lib/doorkeeper/orm/active_record/access_grant.rb +27 -13
  67. data/lib/doorkeeper/orm/active_record/access_token.rb +6 -13
  68. data/lib/doorkeeper/orm/active_record/application.rb +26 -7
  69. data/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb +10 -3
  70. data/lib/doorkeeper/orm/active_record.rb +6 -6
  71. data/lib/doorkeeper/rails/helpers.rb +1 -1
  72. data/lib/doorkeeper/rails/routes/mapping.rb +7 -7
  73. data/lib/doorkeeper/rails/routes.rb +11 -11
  74. data/lib/doorkeeper/rake/db.rake +13 -13
  75. data/lib/doorkeeper/rake.rb +1 -1
  76. data/lib/doorkeeper/request.rb +1 -1
  77. data/lib/doorkeeper/secret_storing/base.rb +64 -0
  78. data/lib/doorkeeper/secret_storing/bcrypt.rb +60 -0
  79. data/lib/doorkeeper/secret_storing/plain.rb +33 -0
  80. data/lib/doorkeeper/secret_storing/sha256_hash.rb +26 -0
  81. data/lib/doorkeeper/stale_records_cleaner.rb +1 -1
  82. data/lib/doorkeeper/version.rb +3 -3
  83. data/lib/doorkeeper.rb +69 -60
  84. data/lib/generators/doorkeeper/application_owner_generator.rb +10 -9
  85. data/lib/generators/doorkeeper/confidential_applications_generator.rb +10 -9
  86. data/lib/generators/doorkeeper/install_generator.rb +11 -9
  87. data/lib/generators/doorkeeper/migration_generator.rb +9 -9
  88. data/lib/generators/doorkeeper/pkce_generator.rb +10 -9
  89. data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +10 -9
  90. data/lib/generators/doorkeeper/templates/initializer.rb +120 -13
  91. data/lib/generators/doorkeeper/templates/migration.rb.erb +15 -7
  92. data/lib/generators/doorkeeper/views_generator.rb +6 -4
  93. data/spec/controllers/application_metal_controller_spec.rb +24 -10
  94. data/spec/controllers/applications_controller_spec.rb +54 -52
  95. data/spec/controllers/authorizations_controller_spec.rb +139 -145
  96. data/spec/controllers/protected_resources_controller_spec.rb +78 -76
  97. data/spec/controllers/token_info_controller_spec.rb +14 -12
  98. data/spec/controllers/tokens_controller_spec.rb +167 -108
  99. data/spec/dummy/Rakefile +3 -1
  100. data/spec/dummy/app/controllers/application_controller.rb +3 -1
  101. data/spec/dummy/app/controllers/custom_authorizations_controller.rb +2 -0
  102. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +4 -2
  103. data/spec/dummy/app/controllers/home_controller.rb +5 -3
  104. data/spec/dummy/app/controllers/metal_controller.rb +2 -0
  105. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +4 -2
  106. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  107. data/spec/dummy/app/models/user.rb +2 -0
  108. data/spec/dummy/config/application.rb +25 -1
  109. data/spec/dummy/config/environments/development.rb +2 -0
  110. data/spec/dummy/config/environments/production.rb +2 -0
  111. data/spec/dummy/config/environments/test.rb +3 -1
  112. data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
  113. data/spec/dummy/config/initializers/doorkeeper.rb +5 -2
  114. data/spec/dummy/config/initializers/secret_token.rb +3 -1
  115. data/spec/dummy/config/initializers/session_store.rb +3 -1
  116. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
  117. data/spec/dummy/config.ru +3 -1
  118. data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +17 -10
  119. data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +2 -0
  120. data/spec/dummy/db/schema.rb +1 -1
  121. data/spec/dummy/script/rails +5 -3
  122. data/spec/factories.rb +8 -6
  123. data/spec/generators/application_owner_generator_spec.rb +13 -26
  124. data/spec/generators/confidential_applications_generator_spec.rb +12 -28
  125. data/spec/generators/install_generator_spec.rb +17 -15
  126. data/spec/generators/migration_generator_spec.rb +13 -26
  127. data/spec/generators/pkce_generator_spec.rb +11 -26
  128. data/spec/generators/previous_refresh_token_generator_spec.rb +16 -29
  129. data/spec/generators/templates/routes.rb +2 -0
  130. data/spec/generators/views_generator_spec.rb +14 -12
  131. data/spec/grape/grape_integration_spec.rb +34 -32
  132. data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +9 -7
  133. data/spec/lib/config_spec.rb +268 -99
  134. data/spec/lib/doorkeeper_spec.rb +3 -1
  135. data/spec/lib/models/expirable_spec.rb +22 -8
  136. data/spec/lib/models/reusable_spec.rb +40 -0
  137. data/spec/lib/models/revocable_spec.rb +8 -6
  138. data/spec/lib/models/scopes_spec.rb +27 -13
  139. data/spec/lib/models/secret_storable_spec.rb +135 -0
  140. data/spec/lib/oauth/authorization/uri_builder_spec.rb +17 -15
  141. data/spec/lib/oauth/authorization_code_request_spec.rb +34 -11
  142. data/spec/lib/oauth/base_request_spec.rb +20 -8
  143. data/spec/lib/oauth/base_response_spec.rb +3 -1
  144. data/spec/lib/oauth/client/credentials_spec.rb +24 -22
  145. data/spec/lib/oauth/client_credentials/creator_spec.rb +56 -10
  146. data/spec/lib/oauth/client_credentials/issuer_spec.rb +27 -18
  147. data/spec/lib/oauth/client_credentials/validation_spec.rb +20 -15
  148. data/spec/lib/oauth/client_credentials_integration_spec.rb +7 -5
  149. data/spec/lib/oauth/client_credentials_request_spec.rb +27 -21
  150. data/spec/lib/oauth/client_spec.rb +15 -13
  151. data/spec/lib/oauth/code_request_spec.rb +8 -6
  152. data/spec/lib/oauth/code_response_spec.rb +9 -7
  153. data/spec/lib/oauth/error_response_spec.rb +19 -11
  154. data/spec/lib/oauth/error_spec.rb +4 -2
  155. data/spec/lib/oauth/forbidden_token_response_spec.rb +7 -5
  156. data/spec/lib/oauth/helpers/scope_checker_spec.rb +68 -31
  157. data/spec/lib/oauth/helpers/unique_token_spec.rb +8 -6
  158. data/spec/lib/oauth/helpers/uri_checker_spec.rb +115 -95
  159. data/spec/lib/oauth/invalid_token_response_spec.rb +3 -1
  160. data/spec/lib/oauth/password_access_token_request_spec.rb +79 -30
  161. data/spec/lib/oauth/pre_authorization_spec.rb +80 -54
  162. data/spec/lib/oauth/refresh_token_request_spec.rb +36 -33
  163. data/spec/lib/oauth/scopes_spec.rb +63 -61
  164. data/spec/lib/oauth/token_request_spec.rb +79 -24
  165. data/spec/lib/oauth/token_response_spec.rb +40 -38
  166. data/spec/lib/oauth/token_spec.rb +60 -44
  167. data/spec/lib/request/strategy_spec.rb +3 -1
  168. data/spec/lib/secret_storing/base_spec.rb +60 -0
  169. data/spec/lib/secret_storing/bcrypt_spec.rb +49 -0
  170. data/spec/lib/secret_storing/plain_spec.rb +44 -0
  171. data/spec/lib/secret_storing/sha256_hash_spec.rb +48 -0
  172. data/spec/lib/server_spec.rb +16 -14
  173. data/spec/lib/stale_records_cleaner_spec.rb +17 -17
  174. data/spec/models/doorkeeper/access_grant_spec.rb +80 -15
  175. data/spec/models/doorkeeper/access_token_spec.rb +198 -73
  176. data/spec/models/doorkeeper/application_spec.rb +142 -45
  177. data/spec/requests/applications/applications_request_spec.rb +98 -66
  178. data/spec/requests/applications/authorized_applications_spec.rb +20 -18
  179. data/spec/requests/endpoints/authorization_spec.rb +25 -23
  180. data/spec/requests/endpoints/token_spec.rb +38 -36
  181. data/spec/requests/flows/authorization_code_errors_spec.rb +26 -24
  182. data/spec/requests/flows/authorization_code_spec.rb +193 -151
  183. data/spec/requests/flows/client_credentials_spec.rb +54 -52
  184. data/spec/requests/flows/implicit_grant_errors_spec.rb +10 -8
  185. data/spec/requests/flows/implicit_grant_spec.rb +27 -25
  186. data/spec/requests/flows/password_spec.rb +59 -55
  187. data/spec/requests/flows/refresh_token_spec.rb +45 -43
  188. data/spec/requests/flows/revoke_token_spec.rb +40 -54
  189. data/spec/requests/flows/skip_authorization_spec.rb +23 -21
  190. data/spec/requests/protected_resources/metal_spec.rb +7 -5
  191. data/spec/requests/protected_resources/private_api_spec.rb +35 -33
  192. data/spec/routing/custom_controller_routes_spec.rb +71 -65
  193. data/spec/routing/default_routes_spec.rb +22 -20
  194. data/spec/routing/scoped_routes_spec.rb +20 -18
  195. data/spec/spec_helper.rb +15 -13
  196. data/spec/spec_helper_integration.rb +3 -1
  197. data/spec/support/dependencies/factory_bot.rb +3 -1
  198. data/spec/support/doorkeeper_rspec.rb +3 -1
  199. data/spec/support/helpers/access_token_request_helper.rb +3 -1
  200. data/spec/support/helpers/authorization_request_helper.rb +4 -2
  201. data/spec/support/helpers/config_helper.rb +2 -0
  202. data/spec/support/helpers/model_helper.rb +3 -1
  203. data/spec/support/helpers/request_spec_helper.rb +5 -3
  204. data/spec/support/helpers/url_helper.rb +9 -7
  205. data/spec/support/http_method_shim.rb +4 -9
  206. data/spec/support/orm/active_record.rb +3 -1
  207. data/spec/support/shared/controllers_shared_context.rb +18 -16
  208. data/spec/support/shared/hashing_shared_context.rb +36 -0
  209. data/spec/support/shared/models_shared_examples.rb +12 -10
  210. data/spec/validators/redirect_uri_validator_spec.rb +74 -45
  211. data/spec/version/version_spec.rb +7 -5
  212. metadata +61 -28
  213. data/gemfiles/rails_4_2.gemfile +0 -13
  214. data/spec/dummy/config/initializers/new_framework_defaults.rb +0 -8
@@ -1,30 +1,32 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- feature 'Authorized applications' do
3
+ require "spec_helper"
4
+
5
+ feature "Authorized applications" do
4
6
  background do
5
- @user = User.create!(name: 'Joe', password: 'sekret')
6
- @client = client_exists(name: 'Amazing Client App')
7
+ @user = User.create!(name: "Joe", password: "sekret")
8
+ @client = client_exists(name: "Amazing Client App")
7
9
  resource_owner_is_authenticated @user
8
10
  client_is_authorized @client, @user
9
11
  end
10
12
 
11
- scenario 'display user\'s authorized applications' do
12
- visit '/oauth/authorized_applications'
13
- i_should_see 'Amazing Client App'
13
+ scenario "display user's authorized applications" do
14
+ visit "/oauth/authorized_applications"
15
+ i_should_see "Amazing Client App"
14
16
  end
15
17
 
16
- scenario 'do not display other user\'s authorized applications' do
17
- client = client_exists(name: 'Another Client App')
18
- client_is_authorized client, User.create!(name: 'Joe', password: 'sekret')
19
- visit '/oauth/authorized_applications'
20
- i_should_not_see 'Another Client App'
18
+ scenario "do not display other user's authorized applications" do
19
+ client = client_exists(name: "Another Client App")
20
+ client_is_authorized client, User.create!(name: "Joe", password: "sekret")
21
+ visit "/oauth/authorized_applications"
22
+ i_should_not_see "Another Client App"
21
23
  end
22
24
 
23
- scenario 'user revoke access to application' do
24
- visit '/oauth/authorized_applications'
25
- i_should_see 'Amazing Client App'
26
- click_on 'Revoke'
27
- i_should_see 'Application revoked'
28
- i_should_not_see 'Amazing Client App'
25
+ scenario "user revoke access to application" do
26
+ visit "/oauth/authorized_applications"
27
+ i_should_see "Amazing Client App"
28
+ click_on "Revoke"
29
+ i_should_see "Application revoked"
30
+ i_should_not_see "Amazing Client App"
29
31
  end
30
32
  end
@@ -1,69 +1,71 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- feature 'Authorization endpoint' do
3
+ require "spec_helper"
4
+
5
+ feature "Authorization endpoint" do
4
6
  background do
5
- config_is_set(:authenticate_resource_owner) { User.first || redirect_to('/sign_in') }
6
- client_exists(name: 'MyApp')
7
+ config_is_set(:authenticate_resource_owner) { User.first || redirect_to("/sign_in") }
8
+ client_exists(name: "MyApp")
7
9
  end
8
10
 
9
- scenario 'requires resource owner to be authenticated' do
11
+ scenario "requires resource owner to be authenticated" do
10
12
  visit authorization_endpoint_url(client: @client)
11
- i_should_see 'Sign in'
12
- i_should_be_on '/'
13
+ i_should_see "Sign in"
14
+ i_should_be_on "/"
13
15
  end
14
16
 
15
- context 'with authenticated resource owner' do
17
+ context "with authenticated resource owner" do
16
18
  background do
17
19
  create_resource_owner
18
20
  sign_in
19
21
  end
20
22
 
21
- scenario 'displays the authorization form' do
23
+ scenario "displays the authorization form" do
22
24
  visit authorization_endpoint_url(client: @client)
23
- i_should_see 'Authorize MyApp to use your account?'
25
+ i_should_see "Authorize MyApp to use your account?"
24
26
  end
25
27
 
26
- scenario 'displays all requested scopes' do
28
+ scenario "displays all requested scopes" do
27
29
  default_scopes_exist :public
28
30
  optional_scopes_exist :write
29
- visit authorization_endpoint_url(client: @client, scope: 'public write')
30
- i_should_see 'Access your public data'
31
- i_should_see 'Update your data'
31
+ visit authorization_endpoint_url(client: @client, scope: "public write")
32
+ i_should_see "Access your public data"
33
+ i_should_see "Update your data"
32
34
  end
33
35
  end
34
36
 
35
- context 'with a invalid request' do
37
+ context "with a invalid request" do
36
38
  background do
37
39
  create_resource_owner
38
40
  sign_in
39
41
  end
40
42
 
41
- scenario 'displays the related error' do
42
- visit authorization_endpoint_url(client: @client, response_type: '')
43
- i_should_not_see 'Authorize'
43
+ scenario "displays the related error" do
44
+ visit authorization_endpoint_url(client: @client, response_type: "")
45
+ i_should_not_see "Authorize"
44
46
  i_should_see_translated_error_message :unsupported_response_type
45
47
  end
46
48
 
47
49
  scenario "displays unsupported_response_type error when using a disabled response type" do
48
- config_is_set(:grant_flows, ['implicit'])
49
- visit authorization_endpoint_url(client: @client, response_type: 'code')
50
+ config_is_set(:grant_flows, ["implicit"])
51
+ visit authorization_endpoint_url(client: @client, response_type: "code")
50
52
  i_should_not_see "Authorize"
51
53
  i_should_see_translated_error_message :unsupported_response_type
52
54
  end
53
55
  end
54
56
 
55
- context 'forgery protection enabled' do
57
+ context "forgery protection enabled" do
56
58
  background do
57
59
  create_resource_owner
58
60
  sign_in
59
61
  end
60
62
 
61
- scenario 'raises exception on forged requests' do
63
+ scenario "raises exception on forged requests" do
62
64
  allowing_forgery_protection do
63
65
  expect do
64
66
  page.driver.post authorization_endpoint_url(client_id: @client.uid,
65
67
  redirect_uri: @client.redirect_uri,
66
- response_type: 'code')
68
+ response_type: "code")
67
69
  end.to raise_error(ActionController::InvalidAuthenticityToken)
68
70
  end
69
71
  end
@@ -1,73 +1,75 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- describe 'Token endpoint' do
3
+ require "spec_helper"
4
+
5
+ describe "Token endpoint" do
4
6
  before do
5
7
  client_exists
6
- authorization_code_exists application: @client, scopes: 'public'
8
+ authorization_code_exists application: @client, scopes: "public"
7
9
  end
8
10
 
9
- it 'respond with correct headers' do
11
+ it "respond with correct headers" do
10
12
  post token_endpoint_url(code: @authorization.token, client: @client)
11
- should_have_header 'Pragma', 'no-cache'
13
+ should_have_header "Pragma", "no-cache"
12
14
 
13
15
  # Rails 5.2 changed headers
14
16
  if ::Rails::VERSION::MAJOR >= 5 && ::Rails::VERSION::MINOR >= 2 || ::Rails::VERSION::MAJOR >= 6
15
- should_have_header 'Cache-Control', 'private, no-store'
17
+ should_have_header "Cache-Control", "private, no-store"
16
18
  else
17
- should_have_header 'Cache-Control', 'no-store'
19
+ should_have_header "Cache-Control", "no-store"
18
20
  end
19
21
 
20
- should_have_header 'Content-Type', 'application/json; charset=utf-8'
22
+ should_have_header "Content-Type", "application/json; charset=utf-8"
21
23
  end
22
24
 
23
- it 'accepts client credentials with basic auth header' do
25
+ it "accepts client credentials with basic auth header" do
24
26
  post token_endpoint_url,
25
27
  params: {
26
28
  code: @authorization.token,
27
- redirect_uri: @client.redirect_uri
29
+ redirect_uri: @client.redirect_uri,
28
30
  },
29
- headers: { 'HTTP_AUTHORIZATION' => basic_auth_header_for_client(@client) }
31
+ headers: { "HTTP_AUTHORIZATION" => basic_auth_header_for_client(@client) }
30
32
 
31
- should_have_json 'access_token', Doorkeeper::AccessToken.first.token
33
+ should_have_json "access_token", Doorkeeper::AccessToken.first.token
32
34
  end
33
35
 
34
- it 'returns null for expires_in when a permanent token is set' do
36
+ it "returns null for expires_in when a permanent token is set" do
35
37
  config_is_set(:access_token_expires_in, nil)
36
38
  post token_endpoint_url(code: @authorization.token, client: @client)
37
- should_have_json 'access_token', Doorkeeper::AccessToken.first.token
38
- should_not_have_json 'expires_in'
39
+ should_have_json "access_token", Doorkeeper::AccessToken.first.token
40
+ should_not_have_json "expires_in"
39
41
  end
40
42
 
41
- it 'returns unsupported_grant_type for invalid grant_type param' do
42
- post token_endpoint_url(code: @authorization.token, client: @client, grant_type: 'nothing')
43
+ it "returns unsupported_grant_type for invalid grant_type param" do
44
+ post token_endpoint_url(code: @authorization.token, client: @client, grant_type: "nothing")
43
45
 
44
- should_not_have_json 'access_token'
45
- should_have_json 'error', 'unsupported_grant_type'
46
- should_have_json 'error_description', translated_error_message('unsupported_grant_type')
46
+ should_not_have_json "access_token"
47
+ should_have_json "error", "unsupported_grant_type"
48
+ should_have_json "error_description", translated_error_message("unsupported_grant_type")
47
49
  end
48
50
 
49
- it 'returns unsupported_grant_type for disabled grant flows' do
50
- config_is_set(:grant_flows, ['implicit'])
51
- post token_endpoint_url(code: @authorization.token, client: @client, grant_type: 'authorization_code')
51
+ it "returns unsupported_grant_type for disabled grant flows" do
52
+ config_is_set(:grant_flows, ["implicit"])
53
+ post token_endpoint_url(code: @authorization.token, client: @client, grant_type: "authorization_code")
52
54
 
53
- should_not_have_json 'access_token'
54
- should_have_json 'error', 'unsupported_grant_type'
55
- should_have_json 'error_description', translated_error_message('unsupported_grant_type')
55
+ should_not_have_json "access_token"
56
+ should_have_json "error", "unsupported_grant_type"
57
+ should_have_json "error_description", translated_error_message("unsupported_grant_type")
56
58
  end
57
59
 
58
- it 'returns unsupported_grant_type when refresh_token is not in use' do
59
- post token_endpoint_url(code: @authorization.token, client: @client, grant_type: 'refresh_token')
60
+ it "returns unsupported_grant_type when refresh_token is not in use" do
61
+ post token_endpoint_url(code: @authorization.token, client: @client, grant_type: "refresh_token")
60
62
 
61
- should_not_have_json 'access_token'
62
- should_have_json 'error', 'unsupported_grant_type'
63
- should_have_json 'error_description', translated_error_message('unsupported_grant_type')
63
+ should_not_have_json "access_token"
64
+ should_have_json "error", "unsupported_grant_type"
65
+ should_have_json "error_description", translated_error_message("unsupported_grant_type")
64
66
  end
65
67
 
66
- it 'returns invalid_request if grant_type is missing' do
67
- post token_endpoint_url(code: @authorization.token, client: @client, grant_type: '')
68
+ it "returns invalid_request if grant_type is missing" do
69
+ post token_endpoint_url(code: @authorization.token, client: @client, grant_type: "")
68
70
 
69
- should_not_have_json 'access_token'
70
- should_have_json 'error', 'invalid_request'
71
- should_have_json 'error_description', translated_error_message('invalid_request')
71
+ should_not_have_json "access_token"
72
+ should_have_json "error", "invalid_request"
73
+ should_have_json "error_description", translated_error_message("invalid_request")
72
74
  end
73
75
  end
@@ -1,9 +1,11 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- feature 'Authorization Code Flow Errors' do
3
+ require "spec_helper"
4
+
5
+ feature "Authorization Code Flow Errors" do
4
6
  let(:client_params) { {} }
5
7
  background do
6
- config_is_set(:authenticate_resource_owner) { User.first || redirect_to('/sign_in') }
8
+ config_is_set(:authenticate_resource_owner) { User.first || redirect_to("/sign_in") }
7
9
  client_exists client_params
8
10
  create_resource_owner
9
11
  sign_in
@@ -22,35 +24,35 @@ feature 'Authorization Code Flow Errors' do
22
24
  end
23
25
  end
24
26
 
25
- context 'when access was denied' do
26
- scenario 'redirects with error' do
27
+ context "when access was denied" do
28
+ scenario "redirects with error" do
27
29
  visit authorization_endpoint_url(client: @client)
28
- click_on 'Deny'
30
+ click_on "Deny"
29
31
 
30
32
  i_should_be_on_client_callback @client
31
- url_should_not_have_param 'code'
32
- url_should_have_param 'error', 'access_denied'
33
- url_should_have_param 'error_description', translated_error_message(:access_denied)
33
+ url_should_not_have_param "code"
34
+ url_should_have_param "error", "access_denied"
35
+ url_should_have_param "error_description", translated_error_message(:access_denied)
34
36
  end
35
37
 
36
- scenario 'redirects with state parameter' do
37
- visit authorization_endpoint_url(client: @client, state: 'return-this')
38
- click_on 'Deny'
38
+ scenario "redirects with state parameter" do
39
+ visit authorization_endpoint_url(client: @client, state: "return-this")
40
+ click_on "Deny"
39
41
 
40
42
  i_should_be_on_client_callback @client
41
- url_should_not_have_param 'code'
42
- url_should_have_param 'state', 'return-this'
43
+ url_should_not_have_param "code"
44
+ url_should_have_param "state", "return-this"
43
45
  end
44
46
  end
45
47
  end
46
48
 
47
- describe 'Authorization Code Flow Errors', 'after authorization' do
49
+ describe "Authorization Code Flow Errors", "after authorization" do
48
50
  before do
49
51
  client_exists
50
52
  authorization_code_exists application: @client
51
53
  end
52
54
 
53
- it 'returns :invalid_grant error when posting an already revoked grant code' do
55
+ it "returns :invalid_grant error when posting an already revoked grant code" do
54
56
  # First successful request
55
57
  post token_endpoint_url(code: @authorization.token, client: @client)
56
58
 
@@ -59,18 +61,18 @@ describe 'Authorization Code Flow Errors', 'after authorization' do
59
61
  post token_endpoint_url(code: @authorization.token, client: @client)
60
62
  end.to_not(change { Doorkeeper::AccessToken.count })
61
63
 
62
- should_not_have_json 'access_token'
63
- should_have_json 'error', 'invalid_grant'
64
- should_have_json 'error_description', translated_error_message('invalid_grant')
64
+ should_not_have_json "access_token"
65
+ should_have_json "error", "invalid_grant"
66
+ should_have_json "error_description", translated_error_message("invalid_grant")
65
67
  end
66
68
 
67
- it 'returns :invalid_grant error for invalid grant code' do
68
- post token_endpoint_url(code: 'invalid', client: @client)
69
+ it "returns :invalid_grant error for invalid grant code" do
70
+ post token_endpoint_url(code: "invalid", client: @client)
69
71
 
70
72
  access_token_should_not_exist
71
73
 
72
- should_not_have_json 'access_token'
73
- should_have_json 'error', 'invalid_grant'
74
- should_have_json 'error_description', translated_error_message('invalid_grant')
74
+ should_not_have_json "access_token"
75
+ should_have_json "error", "invalid_grant"
76
+ should_have_json "error_description", translated_error_message("invalid_grant")
75
77
  end
76
78
  end