doorkeeper 5.2.6 → 5.3.3

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 (125) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +2 -2
  3. data/CHANGELOG.md +24 -5
  4. data/Gemfile +2 -2
  5. data/app/controllers/doorkeeper/application_controller.rb +2 -2
  6. data/app/controllers/doorkeeper/application_metal_controller.rb +2 -2
  7. data/app/controllers/doorkeeper/authorizations_controller.rb +2 -2
  8. data/app/controllers/doorkeeper/authorized_applications_controller.rb +2 -2
  9. data/gemfiles/rails_5_0.gemfile +2 -2
  10. data/gemfiles/rails_5_1.gemfile +2 -2
  11. data/gemfiles/rails_5_2.gemfile +2 -2
  12. data/gemfiles/rails_6_0.gemfile +2 -2
  13. data/gemfiles/rails_master.gemfile +2 -2
  14. data/lib/doorkeeper/config.rb +71 -38
  15. data/lib/doorkeeper/grape/helpers.rb +1 -1
  16. data/lib/doorkeeper/helpers/controller.rb +10 -8
  17. data/lib/doorkeeper/models/access_grant_mixin.rb +7 -6
  18. data/lib/doorkeeper/models/access_token_mixin.rb +54 -16
  19. data/lib/doorkeeper/models/application_mixin.rb +3 -3
  20. data/lib/doorkeeper/models/concerns/ownership.rb +1 -1
  21. data/lib/doorkeeper/models/concerns/reusable.rb +1 -1
  22. data/lib/doorkeeper/models/concerns/revocable.rb +0 -27
  23. data/lib/doorkeeper/oauth/authorization/code.rb +4 -4
  24. data/lib/doorkeeper/oauth/authorization/token.rb +9 -6
  25. data/lib/doorkeeper/oauth/authorization_code_request.rb +13 -6
  26. data/lib/doorkeeper/oauth/base_request.rb +8 -4
  27. data/lib/doorkeeper/oauth/client.rb +7 -8
  28. data/lib/doorkeeper/oauth/client_credentials/creator.rb +16 -9
  29. data/lib/doorkeeper/oauth/client_credentials/issuer.rb +7 -7
  30. data/lib/doorkeeper/oauth/client_credentials/{validation.rb → validator.rb} +4 -4
  31. data/lib/doorkeeper/oauth/client_credentials_request.rb +1 -1
  32. data/lib/doorkeeper/oauth/code_response.rb +2 -2
  33. data/lib/doorkeeper/oauth/error.rb +1 -1
  34. data/lib/doorkeeper/oauth/error_response.rb +5 -5
  35. data/lib/doorkeeper/oauth/helpers/scope_checker.rb +7 -5
  36. data/lib/doorkeeper/oauth/helpers/unique_token.rb +8 -5
  37. data/lib/doorkeeper/oauth/helpers/uri_checker.rb +1 -1
  38. data/lib/doorkeeper/oauth/invalid_request_response.rb +3 -3
  39. data/lib/doorkeeper/oauth/invalid_token_response.rb +5 -2
  40. data/lib/doorkeeper/oauth/password_access_token_request.rb +3 -3
  41. data/lib/doorkeeper/oauth/pre_authorization.rb +7 -5
  42. data/lib/doorkeeper/oauth/refresh_token_request.rb +5 -5
  43. data/lib/doorkeeper/oauth/token.rb +2 -2
  44. data/lib/doorkeeper/oauth/token_introspection.rb +6 -6
  45. data/lib/doorkeeper/orm/active_record/access_grant.rb +4 -43
  46. data/lib/doorkeeper/orm/active_record/access_token.rb +4 -35
  47. data/lib/doorkeeper/orm/active_record/application.rb +3 -155
  48. data/lib/doorkeeper/orm/active_record/mixins/access_grant.rb +53 -0
  49. data/lib/doorkeeper/orm/active_record/mixins/access_token.rb +47 -0
  50. data/lib/doorkeeper/orm/active_record/mixins/application.rb +187 -0
  51. data/lib/doorkeeper/orm/active_record/redirect_uri_validator.rb +3 -3
  52. data/lib/doorkeeper/orm/active_record.rb +3 -3
  53. data/lib/doorkeeper/rails/helpers.rb +4 -4
  54. data/lib/doorkeeper/rails/routes.rb +5 -7
  55. data/lib/doorkeeper/rake/db.rake +3 -3
  56. data/lib/doorkeeper/request/authorization_code.rb +3 -3
  57. data/lib/doorkeeper/request/client_credentials.rb +2 -2
  58. data/lib/doorkeeper/request/password.rb +2 -2
  59. data/lib/doorkeeper/request/refresh_token.rb +3 -3
  60. data/lib/doorkeeper/request.rb +1 -1
  61. data/lib/doorkeeper/server.rb +1 -1
  62. data/lib/doorkeeper/stale_records_cleaner.rb +1 -1
  63. data/lib/doorkeeper/version.rb +2 -2
  64. data/lib/doorkeeper.rb +2 -3
  65. data/lib/generators/doorkeeper/application_owner_generator.rb +1 -1
  66. data/lib/generators/doorkeeper/confidential_applications_generator.rb +1 -1
  67. data/lib/generators/doorkeeper/migration_generator.rb +1 -1
  68. data/lib/generators/doorkeeper/pkce_generator.rb +1 -1
  69. data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +2 -2
  70. data/lib/generators/doorkeeper/templates/initializer.rb +39 -0
  71. data/spec/controllers/application_metal_controller_spec.rb +1 -1
  72. data/spec/controllers/applications_controller_spec.rb +3 -2
  73. data/spec/controllers/authorizations_controller_spec.rb +18 -18
  74. data/spec/controllers/protected_resources_controller_spec.rb +25 -17
  75. data/spec/controllers/token_info_controller_spec.rb +1 -1
  76. data/spec/controllers/tokens_controller_spec.rb +1 -1
  77. data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +3 -3
  78. data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +1 -1
  79. data/spec/dummy/db/migrate/20180210183654_add_confidential_to_applications.rb +1 -1
  80. data/spec/generators/install_generator_spec.rb +1 -1
  81. data/spec/generators/previous_refresh_token_generator_spec.rb +2 -2
  82. data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +1 -1
  83. data/spec/lib/config_spec.rb +62 -7
  84. data/spec/lib/doorkeeper_spec.rb +1 -1
  85. data/spec/lib/models/revocable_spec.rb +3 -3
  86. data/spec/lib/oauth/authorization_code_request_spec.rb +127 -125
  87. data/spec/lib/oauth/base_request_spec.rb +160 -158
  88. data/spec/lib/oauth/base_response_spec.rb +27 -29
  89. data/spec/lib/oauth/client/credentials_spec.rb +1 -1
  90. data/spec/lib/oauth/client_credentials/creator_spec.rb +42 -5
  91. data/spec/lib/oauth/client_credentials/issuer_spec.rb +12 -12
  92. data/spec/lib/oauth/client_credentials/validation_spec.rb +4 -4
  93. data/spec/lib/oauth/client_credentials_integration_spec.rb +16 -18
  94. data/spec/lib/oauth/client_credentials_request_spec.rb +78 -80
  95. data/spec/lib/oauth/client_spec.rb +26 -26
  96. data/spec/lib/oauth/code_request_spec.rb +34 -34
  97. data/spec/lib/oauth/code_response_spec.rb +21 -25
  98. data/spec/lib/oauth/error_response_spec.rb +42 -44
  99. data/spec/lib/oauth/error_spec.rb +12 -14
  100. data/spec/lib/oauth/forbidden_token_response_spec.rb +11 -13
  101. data/spec/lib/oauth/helpers/scope_checker_spec.rb +30 -18
  102. data/spec/lib/oauth/invalid_request_response_spec.rb +48 -50
  103. data/spec/lib/oauth/invalid_token_response_spec.rb +32 -34
  104. data/spec/lib/oauth/password_access_token_request_spec.rb +145 -147
  105. data/spec/lib/oauth/pre_authorization_spec.rb +159 -161
  106. data/spec/lib/oauth/refresh_token_request_spec.rb +138 -139
  107. data/spec/lib/oauth/scopes_spec.rb +104 -106
  108. data/spec/lib/oauth/token_request_spec.rb +115 -111
  109. data/spec/lib/oauth/token_response_spec.rb +71 -73
  110. data/spec/lib/oauth/token_spec.rb +121 -123
  111. data/spec/models/doorkeeper/access_grant_spec.rb +3 -5
  112. data/spec/models/doorkeeper/access_token_spec.rb +7 -7
  113. data/spec/models/doorkeeper/application_spec.rb +2 -2
  114. data/spec/requests/applications/applications_request_spec.rb +1 -1
  115. data/spec/requests/endpoints/authorization_spec.rb +5 -3
  116. data/spec/requests/flows/authorization_code_spec.rb +34 -22
  117. data/spec/requests/flows/client_credentials_spec.rb +1 -1
  118. data/spec/requests/flows/password_spec.rb +32 -12
  119. data/spec/requests/flows/refresh_token_spec.rb +19 -19
  120. data/spec/requests/flows/revoke_token_spec.rb +18 -12
  121. data/spec/spec_helper.rb +1 -4
  122. data/spec/support/shared/controllers_shared_context.rb +33 -23
  123. data/spec/validators/redirect_uri_validator_spec.rb +1 -1
  124. metadata +6 -5
  125. data/spec/support/http_method_shim.rb +0 -29
@@ -27,8 +27,8 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
27
27
  end)
28
28
  end
29
29
 
30
- allow(Doorkeeper.configuration).to receive(:grant_flows).and_return(["implicit"])
31
- allow(Doorkeeper.configuration).to receive(:authenticate_resource_owner).and_return(->(_) { authenticator_method })
30
+ allow(Doorkeeper.config).to receive(:grant_flows).and_return(["implicit"])
31
+ allow(Doorkeeper.config).to receive(:authenticate_resource_owner).and_return(->(_) { authenticator_method })
32
32
  allow(controller).to receive(:authenticator_method).and_return(user)
33
33
  expect(controller).to receive(:authenticator_method).at_most(:once)
34
34
  end
@@ -69,7 +69,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
69
69
 
70
70
  describe "POST #create in API mode" do
71
71
  before do
72
- allow(Doorkeeper.configuration).to receive(:api_only).and_return(true)
72
+ allow(Doorkeeper.config).to receive(:api_only).and_return(true)
73
73
  post :create, params: { client_id: client.uid, response_type: "token", redirect_uri: client.redirect_uri }
74
74
  end
75
75
 
@@ -127,7 +127,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
127
127
 
128
128
  it "includes error description" do
129
129
  expect(response_json_body["error_description"]).to eq(
130
- translated_invalid_request_error_message(:missing_param, :client_id)
130
+ translated_invalid_request_error_message(:missing_param, :client_id),
131
131
  )
132
132
  end
133
133
 
@@ -177,7 +177,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
177
177
  describe "POST #create in API mode with errors" do
178
178
  context "when missing client_id" do
179
179
  before do
180
- allow(Doorkeeper.configuration).to receive(:api_only).and_return(true)
180
+ allow(Doorkeeper.config).to receive(:api_only).and_return(true)
181
181
 
182
182
  post :create, params: {
183
183
  client_id: "",
@@ -198,7 +198,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
198
198
 
199
199
  it "includes error description" do
200
200
  expect(response_json_body["error_description"]).to eq(
201
- translated_invalid_request_error_message(:missing_param, :client_id)
201
+ translated_invalid_request_error_message(:missing_param, :client_id),
202
202
  )
203
203
  end
204
204
 
@@ -209,7 +209,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
209
209
 
210
210
  context "when other error happens" do
211
211
  before do
212
- allow(Doorkeeper.configuration).to receive(:api_only).and_return(true)
212
+ allow(Doorkeeper.config).to receive(:api_only).and_return(true)
213
213
  default_scopes_exist :public
214
214
 
215
215
  post :create, params: {
@@ -251,7 +251,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
251
251
 
252
252
  describe "POST #create with application already authorized" do
253
253
  before do
254
- allow(Doorkeeper.configuration).to receive(:reuse_access_token).and_return(true)
254
+ allow(Doorkeeper.config).to receive(:reuse_access_token).and_return(true)
255
255
 
256
256
  access_token.save!
257
257
 
@@ -286,12 +286,12 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
286
286
  end
287
287
 
288
288
  it "should call :before_successful_authorization callback" do
289
- expect(Doorkeeper.configuration)
289
+ expect(Doorkeeper.config)
290
290
  .to receive_message_chain(:before_successful_authorization, :call).with(instance_of(described_class))
291
291
  end
292
292
 
293
293
  it "should call :after_successful_authorization callback" do
294
- expect(Doorkeeper.configuration)
294
+ expect(Doorkeeper.config)
295
295
  .to receive_message_chain(:after_successful_authorization, :call).with(instance_of(described_class))
296
296
  end
297
297
  end
@@ -302,18 +302,18 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
302
302
  end
303
303
 
304
304
  it "should not call :before_successful_authorization callback" do
305
- expect(Doorkeeper.configuration).not_to receive(:before_successful_authorization)
305
+ expect(Doorkeeper.config).not_to receive(:before_successful_authorization)
306
306
  end
307
307
 
308
308
  it "should not call :after_successful_authorization callback" do
309
- expect(Doorkeeper.configuration).not_to receive(:after_successful_authorization)
309
+ expect(Doorkeeper.config).not_to receive(:after_successful_authorization)
310
310
  end
311
311
  end
312
312
  end
313
313
 
314
314
  describe "GET #new token request with native url and skip_authorization true" do
315
315
  before do
316
- allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc do
316
+ allow(Doorkeeper.config).to receive(:skip_authorization).and_return(proc do
317
317
  true
318
318
  end)
319
319
 
@@ -342,8 +342,8 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
342
342
 
343
343
  describe "GET #new code request with native url and skip_authorization true" do
344
344
  before do
345
- allow(Doorkeeper.configuration).to receive(:grant_flows).and_return(%w[authorization_code])
346
- allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc do
345
+ allow(Doorkeeper.config).to receive(:grant_flows).and_return(%w[authorization_code])
346
+ allow(Doorkeeper.config).to receive(:skip_authorization).and_return(proc do
347
347
  true
348
348
  end)
349
349
 
@@ -373,7 +373,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
373
373
 
374
374
  describe "GET #new with skip_authorization true" do
375
375
  before do
376
- allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc do
376
+ allow(Doorkeeper.config).to receive(:skip_authorization).and_return(proc do
377
377
  true
378
378
  end)
379
379
 
@@ -412,7 +412,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
412
412
 
413
413
  describe "GET #new in API mode" do
414
414
  before do
415
- allow(Doorkeeper.configuration).to receive(:api_only).and_return(true)
415
+ allow(Doorkeeper.config).to receive(:api_only).and_return(true)
416
416
 
417
417
  get :new, params: {
418
418
  client_id: client.uid,
@@ -468,7 +468,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
468
468
  expect(redirect_uri.match(/token_type=(\w+)&?/)[1]).to eq "Bearer"
469
469
  expect(redirect_uri.match(/expires_in=(\d+)&?/)[1].to_i).to eq 1234
470
470
  expect(
471
- redirect_uri.match(/access_token=([a-zA-Z0-9\-_]+)&?/)[1]
471
+ redirect_uri.match(/access_token=([a-zA-Z0-9\-_]+)&?/)[1],
472
472
  ).to eq Doorkeeper::AccessToken.first.token
473
473
  end
474
474
 
@@ -28,9 +28,11 @@ describe "doorkeeper authorize filter" do
28
28
 
29
29
  let(:token_string) { "1A2BC3" }
30
30
  let(:token) do
31
- double(Doorkeeper::AccessToken,
32
- acceptable?: true, previous_refresh_token: "",
33
- revoke_previous_refresh_token!: true)
31
+ double(
32
+ Doorkeeper::AccessToken,
33
+ acceptable?: true, previous_refresh_token: "",
34
+ revoke_previous_refresh_token!: true,
35
+ )
34
36
  end
35
37
 
36
38
  it "access_token param" do
@@ -108,13 +110,15 @@ describe "doorkeeper authorize filter" do
108
110
  let(:token_string) { "1A2DUWE" }
109
111
 
110
112
  it "allows if the token has particular scopes" do
111
- token = double(Doorkeeper::AccessToken,
112
- accessible?: true, scopes: %w[write public],
113
- previous_refresh_token: "",
114
- revoke_previous_refresh_token!: true)
113
+ token = double(
114
+ Doorkeeper::AccessToken,
115
+ accessible?: true, scopes: %w[write public],
116
+ previous_refresh_token: "",
117
+ revoke_previous_refresh_token!: true,
118
+ )
115
119
  expect(token).to receive(:acceptable?).with([:write]).and_return(true)
116
120
  expect(
117
- Doorkeeper::AccessToken
121
+ Doorkeeper::AccessToken,
118
122
  ).to receive(:by_token).with(token_string).and_return(token)
119
123
 
120
124
  get :index, params: { access_token: token_string }
@@ -122,12 +126,14 @@ describe "doorkeeper authorize filter" do
122
126
  end
123
127
 
124
128
  it "does not allow if the token does not include given scope" do
125
- token = double(Doorkeeper::AccessToken,
126
- accessible?: true, scopes: ["public"], revoked?: false,
127
- expired?: false, previous_refresh_token: "",
128
- revoke_previous_refresh_token!: true)
129
+ token = double(
130
+ Doorkeeper::AccessToken,
131
+ accessible?: true, scopes: ["public"], revoked?: false,
132
+ expired?: false, previous_refresh_token: "",
133
+ revoke_previous_refresh_token!: true,
134
+ )
129
135
  expect(
130
- Doorkeeper::AccessToken
136
+ Doorkeeper::AccessToken,
131
137
  ).to receive(:by_token).with(token_string).and_return(token)
132
138
  expect(token).to receive(:acceptable?).with([:write]).and_return(false)
133
139
 
@@ -224,10 +230,12 @@ describe "doorkeeper authorize filter" do
224
230
  end
225
231
 
226
232
  let(:token) do
227
- double(Doorkeeper::AccessToken,
228
- accessible?: true, scopes: ["public"], revoked?: false,
229
- expired?: false, previous_refresh_token: "",
230
- revoke_previous_refresh_token!: true)
233
+ double(
234
+ Doorkeeper::AccessToken,
235
+ accessible?: true, scopes: ["public"], revoked?: false,
236
+ expired?: false, previous_refresh_token: "",
237
+ revoke_previous_refresh_token!: true,
238
+ )
231
239
  end
232
240
 
233
241
  let(:token_string) { "1A2DUWE" }
@@ -42,7 +42,7 @@ describe Doorkeeper::TokenInfoController do
42
42
  get :show
43
43
 
44
44
  expect(response.body).to eq(
45
- Doorkeeper::OAuth::InvalidTokenResponse.new.body.to_json
45
+ Doorkeeper::OAuth::InvalidTokenResponse.new.body.to_json,
46
46
  )
47
47
  end
48
48
  end
@@ -142,7 +142,7 @@ describe Doorkeeper::TokensController do
142
142
  allow(I18n).to receive(:translate)
143
143
  .with(
144
144
  custom_message,
145
- hash_including(scope: %i[doorkeeper errors messages])
145
+ hash_including(scope: %i[doorkeeper errors messages]),
146
146
  )
147
147
  .and_return("Authorization custom message")
148
148
 
@@ -25,14 +25,14 @@ class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
25
25
  t.text :redirect_uri, null: false
26
26
  t.datetime :created_at, null: false
27
27
  t.datetime :revoked_at
28
- t.string :scopes, null: false, default: ""
28
+ t.string :scopes, null: false, default: ""
29
29
  end
30
30
 
31
31
  add_index :oauth_access_grants, :token, unique: true
32
32
  add_foreign_key(
33
33
  :oauth_access_grants,
34
34
  :oauth_applications,
35
- column: :application_id
35
+ column: :application_id,
36
36
  )
37
37
 
38
38
  create_table :oauth_access_tokens do |t|
@@ -59,7 +59,7 @@ class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
59
59
  add_foreign_key(
60
60
  :oauth_access_tokens,
61
61
  :oauth_applications,
62
- column: :application_id
62
+ column: :application_id,
63
63
  )
64
64
 
65
65
  # Uncomment below to ensure a valid reference to the resource owner's table
@@ -7,7 +7,7 @@ class AddPreviousRefreshTokenToAccessTokens < ActiveRecord::Migration[4.2]
7
7
  :previous_refresh_token,
8
8
  :string,
9
9
  default: "",
10
- null: false
10
+ null: false,
11
11
  )
12
12
  end
13
13
  end
@@ -7,7 +7,7 @@ class AddConfidentialToApplications < ActiveRecord::Migration[5.1]
7
7
  :confidential,
8
8
  :boolean,
9
9
  null: false,
10
- default: true # maintaining backwards compatibility: require secrets
10
+ default: true, # maintaining backwards compatibility: require secrets
11
11
  )
12
12
  end
13
13
  end
@@ -16,7 +16,7 @@ describe "Doorkeeper::InstallGenerator" do
16
16
  FileUtils.mkdir(::File.expand_path("db", Pathname(destination_root)))
17
17
  FileUtils.copy_file(
18
18
  ::File.expand_path("../templates/routes.rb", __FILE__),
19
- ::File.expand_path("config/routes.rb", Pathname.new(destination_root))
19
+ ::File.expand_path("config/routes.rb", Pathname.new(destination_root)),
20
20
  )
21
21
  run_generator
22
22
  end
@@ -14,7 +14,7 @@ describe "Doorkeeper::PreviousRefreshTokenGenerator" do
14
14
  prepare_destination
15
15
 
16
16
  allow_any_instance_of(Doorkeeper::PreviousRefreshTokenGenerator).to(
17
- receive(:no_previous_refresh_token_column?).and_return(true)
17
+ receive(:no_previous_refresh_token_column?).and_return(true),
18
18
  )
19
19
  end
20
20
 
@@ -32,7 +32,7 @@ describe "Doorkeeper::PreviousRefreshTokenGenerator" do
32
32
  context "already exist" do
33
33
  it "does not create a migration" do
34
34
  allow_any_instance_of(Doorkeeper::PreviousRefreshTokenGenerator).to(
35
- receive(:no_previous_refresh_token_column?).and_call_original
35
+ receive(:no_previous_refresh_token_column?).and_call_original,
36
36
  )
37
37
 
38
38
  run_generator
@@ -11,7 +11,7 @@ describe Doorkeeper::DashboardHelper do
11
11
  it "returns error messages" do
12
12
  messages.each do |message|
13
13
  expect(helper.doorkeeper_errors_for(object, :method)).to include(
14
- message.capitalize
14
+ message.capitalize,
15
15
  )
16
16
  end
17
17
  end
@@ -22,7 +22,7 @@ describe Doorkeeper, "configuration" do
22
22
  end
23
23
 
24
24
  expect(Rails.logger).to receive(:warn).with(
25
- I18n.t("doorkeeper.errors.messages.resource_owner_authenticator_not_configured")
25
+ I18n.t("doorkeeper.errors.messages.resource_owner_authenticator_not_configured"),
26
26
  )
27
27
  subject.authenticate_resource_owner.call(nil)
28
28
  end
@@ -45,7 +45,7 @@ describe Doorkeeper, "configuration" do
45
45
  end
46
46
 
47
47
  expect(Rails.logger).to receive(:warn).with(
48
- I18n.t("doorkeeper.errors.messages.credential_flow_not_configured")
48
+ I18n.t("doorkeeper.errors.messages.credential_flow_not_configured"),
49
49
  )
50
50
  subject.resource_owner_from_credentials.call(nil)
51
51
  end
@@ -471,7 +471,7 @@ describe Doorkeeper, "configuration" do
471
471
  describe "access_token_generator" do
472
472
  it "is 'Doorkeeper::OAuth::Helpers::UniqueToken' by default" do
473
473
  expect(Doorkeeper.configuration.access_token_generator).to(
474
- eq("Doorkeeper::OAuth::Helpers::UniqueToken")
474
+ eq("Doorkeeper::OAuth::Helpers::UniqueToken"),
475
475
  )
476
476
  end
477
477
 
@@ -549,6 +549,8 @@ describe Doorkeeper, "configuration" do
549
549
  end
550
550
 
551
551
  if DOORKEEPER_ORM == :active_record
552
+ class FakeCustomModel; end
553
+
552
554
  describe "active_record_options" do
553
555
  let(:models) { [Doorkeeper::AccessGrant, Doorkeeper::AccessToken, Doorkeeper::Application] }
554
556
 
@@ -566,11 +568,62 @@ describe Doorkeeper, "configuration" do
566
568
  Doorkeeper.configure do
567
569
  orm DOORKEEPER_ORM
568
570
  active_record_options(
569
- establish_connection: Rails.configuration.database_configuration[Rails.env]
571
+ establish_connection: Rails.configuration.database_configuration[Rails.env],
570
572
  )
571
573
  end
572
574
  end
573
575
  end
576
+
577
+ describe "access_token_class" do
578
+ it "uses default doorkeeper value" do
579
+ expect(subject.access_token_class).to eq("Doorkeeper::AccessToken")
580
+ expect(subject.access_token_model).to be(Doorkeeper::AccessToken)
581
+ end
582
+
583
+ it "can change the value" do
584
+ Doorkeeper.configure do
585
+ orm DOORKEEPER_ORM
586
+ access_token_class "FakeCustomModel"
587
+ end
588
+
589
+ expect(subject.access_token_class).to eq("FakeCustomModel")
590
+ expect(subject.access_token_model).to be(FakeCustomModel)
591
+ end
592
+ end
593
+
594
+ describe "access_grant_class" do
595
+ it "uses default doorkeeper value" do
596
+ expect(subject.access_grant_class).to eq("Doorkeeper::AccessGrant")
597
+ expect(subject.access_grant_model).to be(Doorkeeper::AccessGrant)
598
+ end
599
+
600
+ it "can change the value" do
601
+ Doorkeeper.configure do
602
+ orm DOORKEEPER_ORM
603
+ access_grant_class "FakeCustomModel"
604
+ end
605
+
606
+ expect(subject.access_grant_class).to eq("FakeCustomModel")
607
+ expect(subject.access_grant_model).to be(FakeCustomModel)
608
+ end
609
+ end
610
+
611
+ describe "application_class" do
612
+ it "uses default doorkeeper value" do
613
+ expect(subject.application_class).to eq("Doorkeeper::Application")
614
+ expect(subject.application_model).to be(Doorkeeper::Application)
615
+ end
616
+
617
+ it "can change the value" do
618
+ Doorkeeper.configure do
619
+ orm DOORKEEPER_ORM
620
+ application_class "FakeCustomModel"
621
+ end
622
+
623
+ expect(subject.application_class).to eq("FakeCustomModel")
624
+ expect(subject.application_model).to be(FakeCustomModel)
625
+ end
626
+ end
574
627
  end
575
628
 
576
629
  describe "api_only" do
@@ -666,8 +719,10 @@ describe Doorkeeper, "configuration" do
666
719
  Doorkeeper.configure do
667
720
  hash_token_secrets using: "Doorkeeper::SecretStoring::BCrypt"
668
721
  end
669
- end.to raise_error(ArgumentError,
670
- /can only be used for storing application secrets/)
722
+ end.to raise_error(
723
+ ArgumentError,
724
+ /can only be used for storing application secrets/,
725
+ )
671
726
  end
672
727
  end
673
728
 
@@ -744,7 +799,7 @@ describe Doorkeeper, "configuration" do
744
799
  describe "options deprecation" do
745
800
  it "prints a warning message when an option is deprecated" do
746
801
  expect(Kernel).to receive(:warn).with(
747
- "[DOORKEEPER] native_redirect_uri has been deprecated and will soon be removed"
802
+ "[DOORKEEPER] native_redirect_uri has been deprecated and will soon be removed",
748
803
  )
749
804
  Doorkeeper.configure do
750
805
  native_redirect_uri "urn:ietf:wg:oauth:2.0:oob"
@@ -7,7 +7,7 @@ describe Doorkeeper do
7
7
  let(:request) { double }
8
8
 
9
9
  it "calls OAuth::Token#authenticate" do
10
- token_strategies = Doorkeeper.configuration.access_token_methods
10
+ token_strategies = Doorkeeper.config.access_token_methods
11
11
 
12
12
  expect(Doorkeeper::OAuth::Token).to receive(:authenticate)
13
13
  .with(request, *token_strategies)
@@ -40,15 +40,15 @@ describe "Revocable" do
40
40
  `previous_refresh_token` attribute" do
41
41
  previous_token = FactoryBot.create(
42
42
  :access_token,
43
- refresh_token: "refresh_token"
43
+ refresh_token: "refresh_token",
44
44
  )
45
45
  current_token = FactoryBot.create(
46
46
  :access_token,
47
- previous_refresh_token: previous_token.refresh_token
47
+ previous_refresh_token: previous_token.refresh_token,
48
48
  )
49
49
 
50
50
  expect_any_instance_of(
51
- Doorkeeper::AccessToken
51
+ Doorkeeper::AccessToken,
52
52
  ).to receive(:revoke).and_call_original
53
53
  current_token.revoke_previous_refresh_token!
54
54