doorkeeper 5.0.3 → 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 (215) hide show
  1. checksums.yaml +4 -4
  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 +81 -21
  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 +20 -8
  14. data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
  15. data/app/controllers/doorkeeper/token_info_controller.rb +2 -2
  16. data/app/controllers/doorkeeper/tokens_controller.rb +11 -11
  17. data/app/helpers/doorkeeper/dashboard_helper.rb +1 -1
  18. data/app/validators/redirect_uri_validator.rb +5 -2
  19. data/app/views/doorkeeper/applications/_form.html.erb +6 -0
  20. data/app/views/doorkeeper/applications/show.html.erb +1 -1
  21. data/app/views/layouts/doorkeeper/admin.html.erb +5 -3
  22. data/bin/console +16 -0
  23. data/config/locales/en.yml +1 -0
  24. data/doorkeeper.gemspec +24 -21
  25. data/gemfiles/rails_5_0.gemfile +9 -4
  26. data/gemfiles/rails_5_1.gemfile +9 -4
  27. data/gemfiles/rails_5_2.gemfile +10 -5
  28. data/gemfiles/rails_6_0.gemfile +17 -0
  29. data/gemfiles/rails_master.gemfile +9 -9
  30. data/lib/doorkeeper/config/option.rb +64 -0
  31. data/lib/doorkeeper/config.rb +191 -75
  32. data/lib/doorkeeper/engine.rb +1 -1
  33. data/lib/doorkeeper/grape/authorization_decorator.rb +4 -4
  34. data/lib/doorkeeper/grape/helpers.rb +3 -3
  35. data/lib/doorkeeper/helpers/controller.rb +3 -2
  36. data/lib/doorkeeper/models/access_grant_mixin.rb +20 -3
  37. data/lib/doorkeeper/models/access_token_mixin.rb +63 -19
  38. data/lib/doorkeeper/models/application_mixin.rb +43 -1
  39. data/lib/doorkeeper/models/concerns/expirable.rb +4 -2
  40. data/lib/doorkeeper/models/concerns/ownership.rb +1 -6
  41. data/lib/doorkeeper/models/concerns/reusable.rb +19 -0
  42. data/lib/doorkeeper/models/concerns/revocable.rb +2 -1
  43. data/lib/doorkeeper/models/concerns/scopes.rb +5 -1
  44. data/lib/doorkeeper/models/concerns/secret_storable.rb +108 -0
  45. data/lib/doorkeeper/oauth/authorization/code.rb +2 -2
  46. data/lib/doorkeeper/oauth/authorization/token.rb +12 -7
  47. data/lib/doorkeeper/oauth/authorization/uri_builder.rb +1 -1
  48. data/lib/doorkeeper/oauth/authorization_code_request.rb +6 -4
  49. data/lib/doorkeeper/oauth/client.rb +1 -1
  50. data/lib/doorkeeper/oauth/client_credentials/validation.rb +5 -4
  51. data/lib/doorkeeper/oauth/client_credentials_request.rb +1 -1
  52. data/lib/doorkeeper/oauth/code_response.rb +2 -2
  53. data/lib/doorkeeper/oauth/error_response.rb +10 -6
  54. data/lib/doorkeeper/oauth/forbidden_token_response.rb +1 -1
  55. data/lib/doorkeeper/oauth/helpers/scope_checker.rb +23 -8
  56. data/lib/doorkeeper/oauth/helpers/unique_token.rb +13 -1
  57. data/lib/doorkeeper/oauth/helpers/uri_checker.rb +37 -1
  58. data/lib/doorkeeper/oauth/invalid_token_response.rb +5 -1
  59. data/lib/doorkeeper/oauth/password_access_token_request.rb +7 -2
  60. data/lib/doorkeeper/oauth/pre_authorization.rb +11 -5
  61. data/lib/doorkeeper/oauth/refresh_token_request.rb +5 -2
  62. data/lib/doorkeeper/oauth/scopes.rb +5 -3
  63. data/lib/doorkeeper/oauth/token.rb +2 -2
  64. data/lib/doorkeeper/oauth/token_introspection.rb +74 -8
  65. data/lib/doorkeeper/oauth/token_response.rb +9 -9
  66. data/lib/doorkeeper/oauth.rb +5 -5
  67. data/lib/doorkeeper/orm/active_record/access_grant.rb +27 -13
  68. data/lib/doorkeeper/orm/active_record/access_token.rb +6 -13
  69. data/lib/doorkeeper/orm/active_record/application.rb +21 -57
  70. data/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb +10 -3
  71. data/lib/doorkeeper/orm/active_record.rb +6 -6
  72. data/lib/doorkeeper/rails/helpers.rb +1 -1
  73. data/lib/doorkeeper/rails/routes/mapping.rb +7 -7
  74. data/lib/doorkeeper/rails/routes.rb +11 -11
  75. data/lib/doorkeeper/rake/db.rake +13 -13
  76. data/lib/doorkeeper/rake.rb +1 -1
  77. data/lib/doorkeeper/request.rb +1 -1
  78. data/lib/doorkeeper/secret_storing/base.rb +64 -0
  79. data/lib/doorkeeper/secret_storing/bcrypt.rb +60 -0
  80. data/lib/doorkeeper/secret_storing/plain.rb +33 -0
  81. data/lib/doorkeeper/secret_storing/sha256_hash.rb +26 -0
  82. data/lib/doorkeeper/stale_records_cleaner.rb +1 -1
  83. data/lib/doorkeeper/version.rb +3 -3
  84. data/lib/doorkeeper.rb +69 -60
  85. data/lib/generators/doorkeeper/application_owner_generator.rb +10 -9
  86. data/lib/generators/doorkeeper/confidential_applications_generator.rb +10 -9
  87. data/lib/generators/doorkeeper/install_generator.rb +11 -9
  88. data/lib/generators/doorkeeper/migration_generator.rb +9 -9
  89. data/lib/generators/doorkeeper/pkce_generator.rb +10 -9
  90. data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +10 -9
  91. data/lib/generators/doorkeeper/templates/initializer.rb +120 -13
  92. data/lib/generators/doorkeeper/templates/migration.rb.erb +15 -7
  93. data/lib/generators/doorkeeper/views_generator.rb +6 -4
  94. data/spec/controllers/application_metal_controller_spec.rb +24 -10
  95. data/spec/controllers/applications_controller_spec.rb +54 -52
  96. data/spec/controllers/authorizations_controller_spec.rb +139 -145
  97. data/spec/controllers/protected_resources_controller_spec.rb +78 -76
  98. data/spec/controllers/token_info_controller_spec.rb +14 -12
  99. data/spec/controllers/tokens_controller_spec.rb +167 -108
  100. data/spec/dummy/Rakefile +3 -1
  101. data/spec/dummy/app/controllers/application_controller.rb +3 -1
  102. data/spec/dummy/app/controllers/custom_authorizations_controller.rb +2 -0
  103. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +4 -2
  104. data/spec/dummy/app/controllers/home_controller.rb +5 -3
  105. data/spec/dummy/app/controllers/metal_controller.rb +2 -0
  106. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +4 -2
  107. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  108. data/spec/dummy/app/models/user.rb +2 -0
  109. data/spec/dummy/config/application.rb +25 -1
  110. data/spec/dummy/config/environments/development.rb +2 -0
  111. data/spec/dummy/config/environments/production.rb +2 -0
  112. data/spec/dummy/config/environments/test.rb +3 -1
  113. data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
  114. data/spec/dummy/config/initializers/doorkeeper.rb +5 -2
  115. data/spec/dummy/config/initializers/secret_token.rb +3 -1
  116. data/spec/dummy/config/initializers/session_store.rb +3 -1
  117. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
  118. data/spec/dummy/config.ru +3 -1
  119. data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +17 -10
  120. data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +2 -0
  121. data/spec/dummy/db/schema.rb +1 -1
  122. data/spec/dummy/script/rails +5 -3
  123. data/spec/factories.rb +8 -6
  124. data/spec/generators/application_owner_generator_spec.rb +13 -26
  125. data/spec/generators/confidential_applications_generator_spec.rb +12 -28
  126. data/spec/generators/install_generator_spec.rb +17 -15
  127. data/spec/generators/migration_generator_spec.rb +13 -26
  128. data/spec/generators/pkce_generator_spec.rb +11 -26
  129. data/spec/generators/previous_refresh_token_generator_spec.rb +16 -29
  130. data/spec/generators/templates/routes.rb +2 -0
  131. data/spec/generators/views_generator_spec.rb +14 -12
  132. data/spec/grape/grape_integration_spec.rb +34 -32
  133. data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +9 -7
  134. data/spec/lib/config_spec.rb +268 -99
  135. data/spec/lib/doorkeeper_spec.rb +3 -1
  136. data/spec/lib/models/expirable_spec.rb +22 -8
  137. data/spec/lib/models/reusable_spec.rb +40 -0
  138. data/spec/lib/models/revocable_spec.rb +8 -6
  139. data/spec/lib/models/scopes_spec.rb +27 -13
  140. data/spec/lib/models/secret_storable_spec.rb +135 -0
  141. data/spec/lib/oauth/authorization/uri_builder_spec.rb +17 -15
  142. data/spec/lib/oauth/authorization_code_request_spec.rb +34 -11
  143. data/spec/lib/oauth/base_request_spec.rb +20 -8
  144. data/spec/lib/oauth/base_response_spec.rb +3 -1
  145. data/spec/lib/oauth/client/credentials_spec.rb +24 -22
  146. data/spec/lib/oauth/client_credentials/creator_spec.rb +56 -10
  147. data/spec/lib/oauth/client_credentials/issuer_spec.rb +27 -18
  148. data/spec/lib/oauth/client_credentials/validation_spec.rb +20 -15
  149. data/spec/lib/oauth/client_credentials_integration_spec.rb +7 -5
  150. data/spec/lib/oauth/client_credentials_request_spec.rb +27 -21
  151. data/spec/lib/oauth/client_spec.rb +15 -13
  152. data/spec/lib/oauth/code_request_spec.rb +8 -6
  153. data/spec/lib/oauth/code_response_spec.rb +9 -7
  154. data/spec/lib/oauth/error_response_spec.rb +19 -11
  155. data/spec/lib/oauth/error_spec.rb +4 -2
  156. data/spec/lib/oauth/forbidden_token_response_spec.rb +7 -5
  157. data/spec/lib/oauth/helpers/scope_checker_spec.rb +68 -31
  158. data/spec/lib/oauth/helpers/unique_token_spec.rb +8 -6
  159. data/spec/lib/oauth/helpers/uri_checker_spec.rb +115 -95
  160. data/spec/lib/oauth/invalid_token_response_spec.rb +3 -1
  161. data/spec/lib/oauth/password_access_token_request_spec.rb +79 -30
  162. data/spec/lib/oauth/pre_authorization_spec.rb +80 -54
  163. data/spec/lib/oauth/refresh_token_request_spec.rb +36 -33
  164. data/spec/lib/oauth/scopes_spec.rb +63 -61
  165. data/spec/lib/oauth/token_request_spec.rb +79 -24
  166. data/spec/lib/oauth/token_response_spec.rb +40 -38
  167. data/spec/lib/oauth/token_spec.rb +60 -44
  168. data/spec/lib/request/strategy_spec.rb +3 -1
  169. data/spec/lib/secret_storing/base_spec.rb +60 -0
  170. data/spec/lib/secret_storing/bcrypt_spec.rb +49 -0
  171. data/spec/lib/secret_storing/plain_spec.rb +44 -0
  172. data/spec/lib/secret_storing/sha256_hash_spec.rb +48 -0
  173. data/spec/lib/server_spec.rb +16 -14
  174. data/spec/lib/stale_records_cleaner_spec.rb +17 -17
  175. data/spec/models/doorkeeper/access_grant_spec.rb +80 -15
  176. data/spec/models/doorkeeper/access_token_spec.rb +198 -73
  177. data/spec/models/doorkeeper/application_spec.rb +280 -288
  178. data/spec/requests/applications/applications_request_spec.rb +98 -66
  179. data/spec/requests/applications/authorized_applications_spec.rb +20 -18
  180. data/spec/requests/endpoints/authorization_spec.rb +25 -23
  181. data/spec/requests/endpoints/token_spec.rb +38 -36
  182. data/spec/requests/flows/authorization_code_errors_spec.rb +26 -24
  183. data/spec/requests/flows/authorization_code_spec.rb +193 -151
  184. data/spec/requests/flows/client_credentials_spec.rb +54 -52
  185. data/spec/requests/flows/implicit_grant_errors_spec.rb +10 -8
  186. data/spec/requests/flows/implicit_grant_spec.rb +27 -25
  187. data/spec/requests/flows/password_spec.rb +59 -55
  188. data/spec/requests/flows/refresh_token_spec.rb +45 -43
  189. data/spec/requests/flows/revoke_token_spec.rb +40 -54
  190. data/spec/requests/flows/skip_authorization_spec.rb +23 -21
  191. data/spec/requests/protected_resources/metal_spec.rb +7 -5
  192. data/spec/requests/protected_resources/private_api_spec.rb +35 -33
  193. data/spec/routing/custom_controller_routes_spec.rb +71 -65
  194. data/spec/routing/default_routes_spec.rb +22 -20
  195. data/spec/routing/scoped_routes_spec.rb +20 -18
  196. data/spec/spec_helper.rb +15 -13
  197. data/spec/spec_helper_integration.rb +3 -1
  198. data/spec/support/dependencies/factory_bot.rb +3 -1
  199. data/spec/support/doorkeeper_rspec.rb +3 -1
  200. data/spec/support/helpers/access_token_request_helper.rb +3 -1
  201. data/spec/support/helpers/authorization_request_helper.rb +4 -2
  202. data/spec/support/helpers/config_helper.rb +2 -0
  203. data/spec/support/helpers/model_helper.rb +3 -1
  204. data/spec/support/helpers/request_spec_helper.rb +5 -3
  205. data/spec/support/helpers/url_helper.rb +9 -7
  206. data/spec/support/http_method_shim.rb +4 -9
  207. data/spec/support/orm/active_record.rb +3 -1
  208. data/spec/support/shared/controllers_shared_context.rb +18 -16
  209. data/spec/support/shared/hashing_shared_context.rb +36 -0
  210. data/spec/support/shared/models_shared_examples.rb +12 -10
  211. data/spec/validators/redirect_uri_validator_spec.rb +74 -45
  212. data/spec/version/version_spec.rb +7 -5
  213. metadata +60 -26
  214. data/gemfiles/rails_4_2.gemfile +0 -13
  215. data/spec/dummy/config/initializers/new_framework_defaults.rb +0 -8
@@ -1,45 +1,51 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- describe 'Custom controller for routes' do
3
+ require "spec_helper"
4
+
5
+ describe "Custom controller for routes" do
4
6
  before :all do
7
+ Doorkeeper.configure do
8
+ orm DOORKEEPER_ORM
9
+ end
10
+
5
11
  Rails.application.routes.disable_clear_and_finalize = true
6
12
 
7
13
  Rails.application.routes.draw do
8
- scope 'inner_space' do
9
- use_doorkeeper scope: 'scope' do
10
- controllers authorizations: 'custom_authorizations',
11
- tokens: 'custom_authorizations',
12
- applications: 'custom_authorizations',
13
- token_info: 'custom_authorizations'
14
-
15
- as authorizations: 'custom_auth',
16
- tokens: 'custom_token',
17
- token_info: 'custom_token_info'
14
+ scope "inner_space" do
15
+ use_doorkeeper scope: "scope" do
16
+ controllers authorizations: "custom_authorizations",
17
+ tokens: "custom_authorizations",
18
+ applications: "custom_authorizations",
19
+ token_info: "custom_authorizations"
20
+
21
+ as authorizations: "custom_auth",
22
+ tokens: "custom_token",
23
+ token_info: "custom_token_info"
18
24
  end
19
25
  end
20
26
 
21
- scope 'space' do
27
+ scope "space" do
22
28
  use_doorkeeper do
23
- controllers authorizations: 'custom_authorizations',
24
- tokens: 'custom_authorizations',
25
- applications: 'custom_authorizations',
26
- token_info: 'custom_authorizations'
27
-
28
- as authorizations: 'custom_auth',
29
- tokens: 'custom_token',
30
- token_info: 'custom_token_info'
29
+ controllers authorizations: "custom_authorizations",
30
+ tokens: "custom_authorizations",
31
+ applications: "custom_authorizations",
32
+ token_info: "custom_authorizations"
33
+
34
+ as authorizations: "custom_auth",
35
+ tokens: "custom_token",
36
+ token_info: "custom_token_info"
31
37
  end
32
38
  end
33
39
 
34
- scope 'outer_space' do
40
+ scope "outer_space" do
35
41
  use_doorkeeper do
36
- controllers authorizations: 'custom_authorizations',
37
- tokens: 'custom_authorizations',
38
- token_info: 'custom_authorizations'
42
+ controllers authorizations: "custom_authorizations",
43
+ tokens: "custom_authorizations",
44
+ token_info: "custom_authorizations"
39
45
 
40
- as authorizations: 'custom_auth',
41
- tokens: 'custom_token',
42
- token_info: 'custom_token_info'
46
+ as authorizations: "custom_auth",
47
+ tokens: "custom_token",
48
+ token_info: "custom_token_info"
43
49
 
44
50
  skip_controllers :tokens, :applications, :token_info
45
51
  end
@@ -50,78 +56,78 @@ describe 'Custom controller for routes' do
50
56
  after :all do
51
57
  Rails.application.routes.clear!
52
58
 
53
- load File.expand_path('../dummy/config/routes.rb', __dir__)
59
+ load File.expand_path("../dummy/config/routes.rb", __dir__)
54
60
  end
55
61
 
56
- it 'GET /inner_space/scope/authorize routes to custom authorizations controller' do
57
- expect(get('/inner_space/scope/authorize')).to route_to('custom_authorizations#new')
62
+ it "GET /inner_space/scope/authorize routes to custom authorizations controller" do
63
+ expect(get("/inner_space/scope/authorize")).to route_to("custom_authorizations#new")
58
64
  end
59
65
 
60
- it 'POST /inner_space/scope/authorize routes to custom authorizations controller' do
61
- expect(post('/inner_space/scope/authorize')).to route_to('custom_authorizations#create')
66
+ it "POST /inner_space/scope/authorize routes to custom authorizations controller" do
67
+ expect(post("/inner_space/scope/authorize")).to route_to("custom_authorizations#create")
62
68
  end
63
69
 
64
- it 'DELETE /inner_space/scope/authorize routes to custom authorizations controller' do
65
- expect(delete('/inner_space/scope/authorize')).to route_to('custom_authorizations#destroy')
70
+ it "DELETE /inner_space/scope/authorize routes to custom authorizations controller" do
71
+ expect(delete("/inner_space/scope/authorize")).to route_to("custom_authorizations#destroy")
66
72
  end
67
73
 
68
- it 'POST /inner_space/scope/token routes to tokens controller' do
69
- expect(post('/inner_space/scope/token')).to route_to('custom_authorizations#create')
74
+ it "POST /inner_space/scope/token routes to tokens controller" do
75
+ expect(post("/inner_space/scope/token")).to route_to("custom_authorizations#create")
70
76
  end
71
77
 
72
- it 'GET /inner_space/scope/applications routes to applications controller' do
73
- expect(get('/inner_space/scope/applications')).to route_to('custom_authorizations#index')
78
+ it "GET /inner_space/scope/applications routes to applications controller" do
79
+ expect(get("/inner_space/scope/applications")).to route_to("custom_authorizations#index")
74
80
  end
75
81
 
76
- it 'GET /inner_space/scope/token/info routes to the token_info controller' do
77
- expect(get('/inner_space/scope/token/info')).to route_to('custom_authorizations#show')
82
+ it "GET /inner_space/scope/token/info routes to the token_info controller" do
83
+ expect(get("/inner_space/scope/token/info")).to route_to("custom_authorizations#show")
78
84
  end
79
85
 
80
- it 'GET /space/oauth/authorize routes to custom authorizations controller' do
81
- expect(get('/space/oauth/authorize')).to route_to('custom_authorizations#new')
86
+ it "GET /space/oauth/authorize routes to custom authorizations controller" do
87
+ expect(get("/space/oauth/authorize")).to route_to("custom_authorizations#new")
82
88
  end
83
89
 
84
- it 'POST /space/oauth/authorize routes to custom authorizations controller' do
85
- expect(post('/space/oauth/authorize')).to route_to('custom_authorizations#create')
90
+ it "POST /space/oauth/authorize routes to custom authorizations controller" do
91
+ expect(post("/space/oauth/authorize")).to route_to("custom_authorizations#create")
86
92
  end
87
93
 
88
- it 'DELETE /space/oauth/authorize routes to custom authorizations controller' do
89
- expect(delete('/space/oauth/authorize')).to route_to('custom_authorizations#destroy')
94
+ it "DELETE /space/oauth/authorize routes to custom authorizations controller" do
95
+ expect(delete("/space/oauth/authorize")).to route_to("custom_authorizations#destroy")
90
96
  end
91
97
 
92
- it 'POST /space/oauth/token routes to tokens controller' do
93
- expect(post('/space/oauth/token')).to route_to('custom_authorizations#create')
98
+ it "POST /space/oauth/token routes to tokens controller" do
99
+ expect(post("/space/oauth/token")).to route_to("custom_authorizations#create")
94
100
  end
95
101
 
96
- it 'POST /space/oauth/revoke routes to tokens controller' do
97
- expect(post('/space/oauth/revoke')).to route_to('custom_authorizations#revoke')
102
+ it "POST /space/oauth/revoke routes to tokens controller" do
103
+ expect(post("/space/oauth/revoke")).to route_to("custom_authorizations#revoke")
98
104
  end
99
105
 
100
- it 'POST /space/oauth/introspect routes to tokens controller' do
101
- expect(post('/space/oauth/introspect')).to route_to('custom_authorizations#introspect')
106
+ it "POST /space/oauth/introspect routes to tokens controller" do
107
+ expect(post("/space/oauth/introspect")).to route_to("custom_authorizations#introspect")
102
108
  end
103
109
 
104
- it 'GET /space/oauth/applications routes to applications controller' do
105
- expect(get('/space/oauth/applications')).to route_to('custom_authorizations#index')
110
+ it "GET /space/oauth/applications routes to applications controller" do
111
+ expect(get("/space/oauth/applications")).to route_to("custom_authorizations#index")
106
112
  end
107
113
 
108
- it 'GET /space/oauth/token/info routes to the token_info controller' do
109
- expect(get('/space/oauth/token/info')).to route_to('custom_authorizations#show')
114
+ it "GET /space/oauth/token/info routes to the token_info controller" do
115
+ expect(get("/space/oauth/token/info")).to route_to("custom_authorizations#show")
110
116
  end
111
117
 
112
- it 'POST /outer_space/oauth/token is not be routable' do
113
- expect(post('/outer_space/oauth/token')).not_to be_routable
118
+ it "POST /outer_space/oauth/token is not be routable" do
119
+ expect(post("/outer_space/oauth/token")).not_to be_routable
114
120
  end
115
121
 
116
- it 'GET /outer_space/oauth/authorize routes to custom authorizations controller' do
117
- expect(get('/outer_space/oauth/authorize')).to be_routable
122
+ it "GET /outer_space/oauth/authorize routes to custom authorizations controller" do
123
+ expect(get("/outer_space/oauth/authorize")).to be_routable
118
124
  end
119
125
 
120
- it 'GET /outer_space/oauth/applications is not routable' do
121
- expect(get('/outer_space/oauth/applications')).not_to be_routable
126
+ it "GET /outer_space/oauth/applications is not routable" do
127
+ expect(get("/outer_space/oauth/applications")).not_to be_routable
122
128
  end
123
129
 
124
- it 'GET /outer_space/oauth/token_info is not routable' do
125
- expect(get('/outer_space/oauth/token/info')).not_to be_routable
130
+ it "GET /outer_space/oauth/token_info is not routable" do
131
+ expect(get("/outer_space/oauth/token/info")).not_to be_routable
126
132
  end
127
133
  end
@@ -1,39 +1,41 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- describe 'Default routes' do
4
- it 'GET /oauth/authorize routes to authorizations controller' do
5
- expect(get('/oauth/authorize')).to route_to('doorkeeper/authorizations#new')
3
+ require "spec_helper"
4
+
5
+ describe "Default routes" do
6
+ it "GET /oauth/authorize routes to authorizations controller" do
7
+ expect(get("/oauth/authorize")).to route_to("doorkeeper/authorizations#new")
6
8
  end
7
9
 
8
- it 'POST /oauth/authorize routes to authorizations controller' do
9
- expect(post('/oauth/authorize')).to route_to('doorkeeper/authorizations#create')
10
+ it "POST /oauth/authorize routes to authorizations controller" do
11
+ expect(post("/oauth/authorize")).to route_to("doorkeeper/authorizations#create")
10
12
  end
11
13
 
12
- it 'DELETE /oauth/authorize routes to authorizations controller' do
13
- expect(delete('/oauth/authorize')).to route_to('doorkeeper/authorizations#destroy')
14
+ it "DELETE /oauth/authorize routes to authorizations controller" do
15
+ expect(delete("/oauth/authorize")).to route_to("doorkeeper/authorizations#destroy")
14
16
  end
15
17
 
16
- it 'POST /oauth/token routes to tokens controller' do
17
- expect(post('/oauth/token')).to route_to('doorkeeper/tokens#create')
18
+ it "POST /oauth/token routes to tokens controller" do
19
+ expect(post("/oauth/token")).to route_to("doorkeeper/tokens#create")
18
20
  end
19
21
 
20
- it 'POST /oauth/revoke routes to tokens controller' do
21
- expect(post('/oauth/revoke')).to route_to('doorkeeper/tokens#revoke')
22
+ it "POST /oauth/revoke routes to tokens controller" do
23
+ expect(post("/oauth/revoke")).to route_to("doorkeeper/tokens#revoke")
22
24
  end
23
25
 
24
- it 'POST /oauth/introspect routes to tokens controller' do
25
- expect(post('/oauth/introspect')).to route_to('doorkeeper/tokens#introspect')
26
+ it "POST /oauth/introspect routes to tokens controller" do
27
+ expect(post("/oauth/introspect")).to route_to("doorkeeper/tokens#introspect")
26
28
  end
27
29
 
28
- it 'GET /oauth/applications routes to applications controller' do
29
- expect(get('/oauth/applications')).to route_to('doorkeeper/applications#index')
30
+ it "GET /oauth/applications routes to applications controller" do
31
+ expect(get("/oauth/applications")).to route_to("doorkeeper/applications#index")
30
32
  end
31
33
 
32
- it 'GET /oauth/authorized_applications routes to authorized applications controller' do
33
- expect(get('/oauth/authorized_applications')).to route_to('doorkeeper/authorized_applications#index')
34
+ it "GET /oauth/authorized_applications routes to authorized applications controller" do
35
+ expect(get("/oauth/authorized_applications")).to route_to("doorkeeper/authorized_applications#index")
34
36
  end
35
37
 
36
- it 'GET /oauth/token/info route to authorized TokenInfo controller' do
37
- expect(get('/oauth/token/info')).to route_to('doorkeeper/token_info#show')
38
+ it "GET /oauth/token/info route to authorized TokenInfo controller" do
39
+ expect(get("/oauth/token/info")).to route_to("doorkeeper/token_info#show")
38
40
  end
39
41
  end
@@ -1,45 +1,47 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- describe 'Scoped routes' do
3
+ require "spec_helper"
4
+
5
+ describe "Scoped routes" do
4
6
  before :all do
5
7
  Rails.application.routes.disable_clear_and_finalize = true
6
8
 
7
9
  Rails.application.routes.draw do
8
- use_doorkeeper scope: 'scope'
10
+ use_doorkeeper scope: "scope"
9
11
  end
10
12
  end
11
13
 
12
14
  after :all do
13
15
  Rails.application.routes.clear!
14
16
 
15
- load File.expand_path('../dummy/config/routes.rb', __dir__)
17
+ load File.expand_path("../dummy/config/routes.rb", __dir__)
16
18
  end
17
19
 
18
- it 'GET /scope/authorize routes to authorizations controller' do
19
- expect(get('/scope/authorize')).to route_to('doorkeeper/authorizations#new')
20
+ it "GET /scope/authorize routes to authorizations controller" do
21
+ expect(get("/scope/authorize")).to route_to("doorkeeper/authorizations#new")
20
22
  end
21
23
 
22
- it 'POST /scope/authorize routes to authorizations controller' do
23
- expect(post('/scope/authorize')).to route_to('doorkeeper/authorizations#create')
24
+ it "POST /scope/authorize routes to authorizations controller" do
25
+ expect(post("/scope/authorize")).to route_to("doorkeeper/authorizations#create")
24
26
  end
25
27
 
26
- it 'DELETE /scope/authorize routes to authorizations controller' do
27
- expect(delete('/scope/authorize')).to route_to('doorkeeper/authorizations#destroy')
28
+ it "DELETE /scope/authorize routes to authorizations controller" do
29
+ expect(delete("/scope/authorize")).to route_to("doorkeeper/authorizations#destroy")
28
30
  end
29
31
 
30
- it 'POST /scope/token routes to tokens controller' do
31
- expect(post('/scope/token')).to route_to('doorkeeper/tokens#create')
32
+ it "POST /scope/token routes to tokens controller" do
33
+ expect(post("/scope/token")).to route_to("doorkeeper/tokens#create")
32
34
  end
33
35
 
34
- it 'GET /scope/applications routes to applications controller' do
35
- expect(get('/scope/applications')).to route_to('doorkeeper/applications#index')
36
+ it "GET /scope/applications routes to applications controller" do
37
+ expect(get("/scope/applications")).to route_to("doorkeeper/applications#index")
36
38
  end
37
39
 
38
- it 'GET /scope/authorized_applications routes to authorized applications controller' do
39
- expect(get('/scope/authorized_applications')).to route_to('doorkeeper/authorized_applications#index')
40
+ it "GET /scope/authorized_applications routes to authorized applications controller" do
41
+ expect(get("/scope/authorized_applications")).to route_to("doorkeeper/authorized_applications#index")
40
42
  end
41
43
 
42
- it 'GET /scope/token/info route to authorized TokenInfo controller' do
43
- expect(get('/scope/token/info')).to route_to('doorkeeper/token_info#show')
44
+ it "GET /scope/token/info route to authorized TokenInfo controller" do
45
+ expect(get("/scope/token/info")).to route_to("doorkeeper/token_info#show")
44
46
  end
45
47
  end
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,13 @@
1
- require 'coveralls'
1
+ # frozen_string_literal: true
2
2
 
3
- Coveralls.wear!('rails') do
4
- add_filter('/spec/')
5
- add_filter('/lib/generators/doorkeeper/templates/')
3
+ require "coveralls"
4
+
5
+ Coveralls.wear!("rails") do
6
+ add_filter("/spec/")
7
+ add_filter("/lib/generators/doorkeeper/templates/")
6
8
  end
7
9
 
8
- ENV['RAILS_ENV'] ||= 'test'
10
+ ENV["RAILS_ENV"] ||= "test"
9
11
 
10
12
  $LOAD_PATH.unshift File.dirname(__FILE__)
11
13
 
@@ -13,22 +15,22 @@ require "#{File.dirname(__FILE__)}/support/doorkeeper_rspec.rb"
13
15
 
14
16
  DOORKEEPER_ORM = Doorkeeper::RSpec.detect_orm
15
17
 
16
- require 'dummy/config/environment'
17
- require 'rspec/rails'
18
- require 'capybara/rspec'
19
- require 'database_cleaner'
20
- require 'generator_spec/test_case'
18
+ require "dummy/config/environment"
19
+ require "rspec/rails"
20
+ require "capybara/rspec"
21
+ require "database_cleaner"
22
+ require "generator_spec/test_case"
21
23
 
22
24
  # Load JRuby SQLite3 if in that platform
23
25
  if defined? JRUBY_VERSION
24
- require 'jdbc/sqlite3'
26
+ require "jdbc/sqlite3"
25
27
  Jdbc::SQLite3.load_driver
26
28
  end
27
29
 
28
30
  Doorkeeper::RSpec.print_configuration_info
29
31
 
30
32
  # Remove after dropping support of Rails 4.2
31
- require "#{File.dirname(__FILE__)}/support/http_method_shim.rb"
33
+ require "#{File.dirname(__FILE__)}/support/http_method_shim"
32
34
 
33
35
  require "support/orm/#{DOORKEEPER_ORM}"
34
36
 
@@ -51,5 +53,5 @@ RSpec.configure do |config|
51
53
  DatabaseCleaner.clean
52
54
  end
53
55
 
54
- config.order = 'random'
56
+ config.order = "random"
55
57
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # For compatibility only
2
- require 'spec_helper'
4
+ require "spec_helper"
@@ -1,2 +1,4 @@
1
- require 'factory_bot'
1
+ # frozen_string_literal: true
2
+
3
+ require "factory_bot"
2
4
  FactoryBot.find_definitions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Doorkeeper
2
4
  class RSpec
3
5
  # Print's useful information about env: Ruby / Rails versions,
@@ -13,7 +15,7 @@ module Doorkeeper
13
15
 
14
16
  # Tries to find ORM from the Gemfile used to run test suite
15
17
  def self.detect_orm
16
- orm = (ENV['BUNDLE_GEMFILE'] || '').match(/Gemfile\.(.+)\.rb/)
18
+ orm = (ENV["BUNDLE_GEMFILE"] || "").match(/Gemfile\.(.+)\.rb/)
17
19
  (orm && orm[1] || :active_record).to_sym
18
20
  end
19
21
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AccessTokenRequestHelper
2
4
  def client_is_authorized(client, resource_owner, access_token_attributes = {})
3
5
  attributes = {
4
6
  application: client,
5
- resource_owner_id: resource_owner.id
7
+ resource_owner_id: resource_owner.id,
6
8
  }.merge(access_token_attributes)
7
9
  FactoryBot.create(:access_token, attributes)
8
10
  end
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AuthorizationRequestHelper
2
4
  def resource_owner_is_authenticated(resource_owner = nil)
3
- resource_owner ||= User.create!(name: 'Joe', password: 'sekret')
5
+ resource_owner ||= User.create!(name: "Joe", password: "sekret")
4
6
  Doorkeeper.configuration.instance_variable_set(:@authenticate_resource_owner, proc { resource_owner })
5
7
  end
6
8
 
7
9
  def resource_owner_is_not_authenticated
8
- Doorkeeper.configuration.instance_variable_set(:@authenticate_resource_owner, proc { redirect_to('/sign_in') })
10
+ Doorkeeper.configuration.instance_variable_set(:@authenticate_resource_owner, proc { redirect_to("/sign_in") })
9
11
  end
10
12
 
11
13
  def default_scopes_exist(*scopes)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ConfigHelper
2
4
  def config_is_set(setting, value = nil, &block)
3
5
  setting_ivar = "@#{setting}"
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ModelHelper
2
4
  def client_exists(client_attributes = {})
3
5
  @client = FactoryBot.create(:application, client_attributes)
4
6
  end
5
7
 
6
8
  def create_resource_owner
7
- @resource_owner = User.create!(name: 'Joe', password: 'sekret')
9
+ @resource_owner = User.create!(name: "Joe", password: "sekret")
8
10
  end
9
11
 
10
12
  def authorization_code_exists(options = {})
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RequestSpecHelper
2
4
  def i_am_logged_in
3
5
  allow(Doorkeeper.configuration).to receive(:authenticate_admin).and_return(->(*) {})
@@ -48,7 +50,7 @@ module RequestSpecHelper
48
50
  end
49
51
 
50
52
  def with_access_token_header(token)
51
- with_header 'Authorization', "Bearer #{token}"
53
+ with_header "Authorization", "Bearer #{token}"
52
54
  end
53
55
 
54
56
  def with_header(header, value)
@@ -72,8 +74,8 @@ module RequestSpecHelper
72
74
  end
73
75
 
74
76
  def sign_in
75
- visit '/'
76
- click_on 'Sign in'
77
+ visit "/"
78
+ click_on "Sign in"
77
79
  end
78
80
 
79
81
  def create_access_token(authorization_code, client, code_verifier = nil)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module UrlHelper
2
4
  def token_endpoint_url(options = {})
3
5
  parameters = {
@@ -5,9 +7,9 @@ module UrlHelper
5
7
  client_id: options[:client_id] || options[:client].try(:uid),
6
8
  client_secret: options[:client_secret] || options[:client].try(:secret),
7
9
  redirect_uri: options[:redirect_uri] || options[:client].try(:redirect_uri),
8
- grant_type: options[:grant_type] || 'authorization_code',
10
+ grant_type: options[:grant_type] || "authorization_code",
9
11
  code_verifier: options[:code_verifier],
10
- code_challenge_method: options[:code_challenge_method]
12
+ code_challenge_method: options[:code_challenge_method],
11
13
  }.reject { |_, v| v.blank? }
12
14
  "/oauth/token?#{build_query(parameters)}"
13
15
  end
@@ -20,7 +22,7 @@ module UrlHelper
20
22
  username: options[:resource_owner_username] || options[:resource_owner].try(:name),
21
23
  password: options[:resource_owner_password] || options[:resource_owner].try(:password),
22
24
  scope: options[:scope],
23
- grant_type: 'password'
25
+ grant_type: "password",
24
26
  }
25
27
  "/oauth/token?#{build_query(parameters)}"
26
28
  end
@@ -29,11 +31,11 @@ module UrlHelper
29
31
  parameters = {
30
32
  client_id: options[:client_id] || options[:client].try(:uid),
31
33
  redirect_uri: options[:redirect_uri] || options[:client].try(:redirect_uri),
32
- response_type: options[:response_type] || 'code',
34
+ response_type: options[:response_type] || "code",
33
35
  scope: options[:scope],
34
36
  state: options[:state],
35
37
  code_challenge: options[:code_challenge],
36
- code_challenge_method: options[:code_challenge_method]
38
+ code_challenge_method: options[:code_challenge_method],
37
39
  }.reject { |_, v| v.blank? }
38
40
  "/oauth/authorize?#{build_query(parameters)}"
39
41
  end
@@ -43,13 +45,13 @@ module UrlHelper
43
45
  refresh_token: options[:refresh_token],
44
46
  client_id: options[:client_id] || options[:client].try(:uid),
45
47
  client_secret: options[:client_secret] || options[:client].try(:secret),
46
- grant_type: options[:grant_type] || 'refresh_token'
48
+ grant_type: options[:grant_type] || "refresh_token",
47
49
  }
48
50
  "/oauth/token?#{build_query(parameters)}"
49
51
  end
50
52
 
51
53
  def revocation_token_endpoint_url
52
- '/oauth/revoke'
54
+ "/oauth/revoke"
53
55
  end
54
56
 
55
57
  def build_query(hash)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Rails 5 deprecates calling HTTP action methods with positional arguments
2
4
  # in favor of keyword arguments. However, the keyword argument form is only
3
5
  # supported in Rails 5+. Since we support back to 4, we need some sort of shim
@@ -17,18 +19,11 @@ module RoutingHTTPMethodShim
17
19
  end
18
20
 
19
21
  module ControllerHTTPMethodShim
20
- def process(action, http_method = 'GET', **args)
22
+ def process(action, http_method = "GET", **args)
21
23
  if (as = args.delete(:as))
22
- @request.headers['Content-Type'] = Mime[as].to_s
24
+ @request.headers["Content-Type"] = Mime[as].to_s
23
25
  end
24
26
 
25
27
  super(action, http_method, args[:params], args[:session], args[:flash])
26
28
  end
27
29
  end
28
-
29
- if ::Rails::VERSION::MAJOR < 5
30
- RSpec.configure do |config|
31
- config.include ControllerHTTPMethodShim, type: :controller
32
- config.include RoutingHTTPMethodShim, type: :request
33
- end
34
- end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # load schema to in memory sqlite
2
4
  ActiveRecord::Migration.verbose = false
3
- load Rails.root + 'db/schema.rb'
5
+ load Rails.root + "db/schema.rb"