doorkeeper-mongodb 5.2.1 → 5.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/lib/doorkeeper-mongodb.rb +1 -0
  3. data/lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb +1 -0
  4. data/lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb +1 -0
  5. data/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb +76 -0
  6. data/lib/doorkeeper-mongodb/mixins/mongoid/base_mixin.rb +0 -8
  7. data/lib/doorkeeper-mongodb/mixins/mongoid/json_serializable.rb +17 -0
  8. data/lib/doorkeeper-mongodb/version.rb +1 -1
  9. data/spec/controllers/application_metal_controller_spec.rb +4 -4
  10. data/spec/controllers/applications_controller_spec.rb +198 -202
  11. data/spec/controllers/authorizations_controller_spec.rb +32 -31
  12. data/spec/controllers/protected_resources_controller_spec.rb +10 -10
  13. data/spec/controllers/token_info_controller_spec.rb +1 -1
  14. data/spec/controllers/tokens_controller_spec.rb +105 -62
  15. data/spec/doorkeeper/redirect_uri_validator_spec.rb +183 -0
  16. data/spec/{lib → doorkeeper}/server_spec.rb +5 -4
  17. data/spec/{lib → doorkeeper}/stale_records_cleaner_spec.rb +8 -7
  18. data/spec/{version → doorkeeper}/version_spec.rb +3 -3
  19. data/spec/dummy/log/test.log +4220 -4184
  20. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{eS/eSL1QMz46gKLM0GR6S9fL6uyARPxOImcappZ9_ZtSyg.cache → Pm/PmheG0PGFqDws1qgFOxOyIL-gpMof3Ar9eSRKVLYuik.cache} +0 -0
  21. data/spec/grape/grape_integration_spec.rb +1 -1
  22. data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +1 -1
  23. data/spec/lib/config_spec.rb +23 -12
  24. data/spec/lib/doorkeeper_spec.rb +4 -4
  25. data/spec/lib/models/expirable_spec.rb +9 -9
  26. data/spec/lib/models/reusable_spec.rb +2 -2
  27. data/spec/lib/models/revocable_spec.rb +4 -7
  28. data/spec/lib/models/scopes_spec.rb +7 -7
  29. data/spec/lib/models/secret_storable_spec.rb +9 -8
  30. data/spec/lib/oauth/authorization/uri_builder_spec.rb +23 -27
  31. data/spec/lib/oauth/authorization_code_request_spec.rb +6 -6
  32. data/spec/lib/oauth/base_request_spec.rb +11 -27
  33. data/spec/lib/oauth/base_response_spec.rb +2 -2
  34. data/spec/lib/oauth/client/credentials_spec.rb +25 -25
  35. data/spec/lib/oauth/client_credentials/creator_spec.rb +89 -91
  36. data/spec/lib/oauth/client_credentials/issuer_spec.rb +84 -86
  37. data/spec/lib/oauth/client_credentials/validation_spec.rb +72 -39
  38. data/spec/lib/oauth/client_credentials_integration_spec.rb +5 -5
  39. data/spec/lib/oauth/client_credentials_request_spec.rb +7 -10
  40. data/spec/lib/oauth/client_spec.rb +8 -8
  41. data/spec/lib/oauth/code_request_spec.rb +5 -5
  42. data/spec/lib/oauth/code_response_spec.rb +4 -4
  43. data/spec/lib/oauth/error_response_spec.rb +6 -5
  44. data/spec/lib/oauth/error_spec.rb +1 -1
  45. data/spec/lib/oauth/forbidden_token_response_spec.rb +2 -2
  46. data/spec/lib/oauth/helpers/scope_checker_spec.rb +37 -37
  47. data/spec/lib/oauth/helpers/unique_token_spec.rb +2 -2
  48. data/spec/lib/oauth/helpers/uri_checker_spec.rb +54 -54
  49. data/spec/lib/oauth/invalid_request_response_spec.rb +6 -6
  50. data/spec/lib/oauth/invalid_token_response_spec.rb +4 -4
  51. data/spec/lib/oauth/password_access_token_request_spec.rb +10 -9
  52. data/spec/lib/oauth/pre_authorization_spec.rb +20 -8
  53. data/spec/lib/oauth/refresh_token_request_spec.rb +10 -10
  54. data/spec/lib/oauth/scopes_spec.rb +14 -14
  55. data/spec/lib/oauth/token_request_spec.rb +9 -9
  56. data/spec/lib/oauth/token_response_spec.rb +5 -5
  57. data/spec/lib/oauth/token_spec.rb +5 -5
  58. data/spec/lib/option_spec.rb +1 -1
  59. data/spec/lib/request/strategy_spec.rb +34 -37
  60. data/spec/lib/secret_storing/base_spec.rb +3 -2
  61. data/spec/lib/secret_storing/bcrypt_spec.rb +2 -1
  62. data/spec/lib/secret_storing/plain_spec.rb +2 -1
  63. data/spec/lib/secret_storing/sha256_hash_spec.rb +2 -1
  64. data/spec/models/doorkeeper/access_grant_spec.rb +7 -9
  65. data/spec/models/doorkeeper/access_token_spec.rb +20 -26
  66. data/spec/models/doorkeeper/application_spec.rb +83 -26
  67. data/spec/requests/applications/applications_request_spec.rb +91 -93
  68. data/spec/requests/endpoints/authorization_spec.rb +1 -1
  69. data/spec/requests/endpoints/token_spec.rb +22 -16
  70. data/spec/requests/flows/authorization_code_errors_spec.rb +12 -8
  71. data/spec/requests/flows/authorization_code_spec.rb +108 -79
  72. data/spec/requests/flows/client_credentials_spec.rb +57 -45
  73. data/spec/requests/flows/implicit_grant_spec.rb +4 -4
  74. data/spec/requests/flows/password_spec.rb +253 -213
  75. data/spec/requests/flows/refresh_token_spec.rb +53 -39
  76. data/spec/requests/flows/revoke_token_spec.rb +24 -24
  77. data/spec/requests/flows/skip_authorization_spec.rb +1 -1
  78. data/spec/requests/protected_resources/metal_spec.rb +2 -2
  79. data/spec/routing/custom_controller_routes_spec.rb +1 -1
  80. data/spec/routing/default_routes_spec.rb +1 -1
  81. data/spec/routing/scoped_routes_spec.rb +1 -1
  82. data/spec/support/helpers/request_spec_helper.rb +1 -13
  83. data/spec/support/helpers/url_helper.rb +2 -2
  84. data/spec/support/shared/controllers_shared_context.rb +5 -38
  85. data/spec/support/shared/hashing_shared_context.rb +4 -0
  86. data/spec/support/shared/models_shared_examples.rb +6 -6
  87. metadata +13 -10
@@ -23,7 +23,7 @@ module UrlHelper
23
23
  password: options[:resource_owner_password] || options[:resource_owner].try(:password),
24
24
  scope: options[:scope],
25
25
  grant_type: "password",
26
- }
26
+ }.reject { |_, v| v.blank? }
27
27
  "/oauth/token?#{build_query(parameters)}"
28
28
  end
29
29
 
@@ -46,7 +46,7 @@ module UrlHelper
46
46
  client_id: options[:client_id] || options[:client].try(:uid),
47
47
  client_secret: options[:client_secret] || options[:client].try(:secret),
48
48
  grant_type: options[:grant_type] || "refresh_token",
49
- }
49
+ }.reject { |_, v| v.blank? }
50
50
  "/oauth/token?#{build_query(parameters)}"
51
51
  end
52
52
 
@@ -11,7 +11,7 @@ shared_context "valid token", token: :valid do
11
11
  )
12
12
  end
13
13
 
14
- before :each do
14
+ before do
15
15
  allow(
16
16
  Doorkeeper::AccessToken,
17
17
  ).to receive(:by_token).with(token_string).and_return(token)
@@ -30,46 +30,13 @@ shared_context "invalid token", token: :invalid do
30
30
  )
31
31
  end
32
32
 
33
- before :each do
33
+ before do
34
34
  allow(
35
35
  Doorkeeper::AccessToken,
36
36
  ).to receive(:by_token).with(token_string).and_return(token)
37
37
  end
38
38
  end
39
39
 
40
- shared_context "authenticated resource owner" do
41
- before do
42
- user = double(:resource, id: 1)
43
- allow(Doorkeeper.config).to receive(:authenticate_resource_owner) { proc { user } }
44
- end
45
- end
46
-
47
- shared_context "not authenticated resource owner" do
48
- before do
49
- allow(Doorkeeper.config).to receive(:authenticate_resource_owner) { proc { redirect_to "/" } }
50
- end
51
- end
52
-
53
- shared_context "valid authorization request" do
54
- let :authorization do
55
- double(:authorization, valid?: true, authorize: true, success_redirect_uri: "http://something.com/cb?code=token")
56
- end
57
-
58
- before do
59
- allow(controller).to receive(:authorization) { authorization }
60
- end
61
- end
62
-
63
- shared_context "invalid authorization request" do
64
- let :authorization do
65
- double(:authorization, valid?: false, authorize: false, redirect_on_error?: false)
66
- end
67
-
68
- before do
69
- allow(controller).to receive(:authorization) { authorization }
70
- end
71
- end
72
-
73
40
  shared_context "expired token", token: :expired do
74
41
  let :token_string do
75
42
  "1A2B3C4DEXP"
@@ -84,7 +51,7 @@ shared_context "expired token", token: :expired do
84
51
  )
85
52
  end
86
53
 
87
- before :each do
54
+ before do
88
55
  allow(
89
56
  Doorkeeper::AccessToken,
90
57
  ).to receive(:by_token).with(token_string).and_return(token)
@@ -105,7 +72,7 @@ shared_context "revoked token", token: :revoked do
105
72
  )
106
73
  end
107
74
 
108
- before :each do
75
+ before do
109
76
  allow(
110
77
  Doorkeeper::AccessToken,
111
78
  ).to receive(:by_token).with(token_string).and_return(token)
@@ -125,7 +92,7 @@ shared_context "forbidden token", token: :forbidden do
125
92
  )
126
93
  end
127
94
 
128
- before :each do
95
+ before do
129
96
  allow(
130
97
  Doorkeeper::AccessToken,
131
98
  ).to receive(:by_token).with(token_string).and_return(token)
@@ -7,6 +7,7 @@ shared_context "with token hashing enabled" do
7
7
 
8
8
  before do
9
9
  Doorkeeper.configure do
10
+ orm DOORKEEPER_ORM
10
11
  hash_token_secrets
11
12
  end
12
13
  end
@@ -19,6 +20,7 @@ shared_context "with token hashing and fallback lookup enabled" do
19
20
 
20
21
  before do
21
22
  Doorkeeper.configure do
23
+ orm DOORKEEPER_ORM
22
24
  hash_token_secrets fallback: :plain
23
25
  end
24
26
  end
@@ -28,8 +30,10 @@ shared_context "with application hashing enabled" do
28
30
  let(:hashed_or_plain_token_func) do
29
31
  Doorkeeper::SecretStoring::Sha256Hash.method(:transform_secret)
30
32
  end
33
+
31
34
  before do
32
35
  Doorkeeper.configure do
36
+ orm DOORKEEPER_ORM
33
37
  hash_application_secrets
34
38
  end
35
39
  end
@@ -1,21 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  shared_examples "an accessible token" do
4
- describe :accessible? do
4
+ describe "#accessible?" do
5
5
  it "is accessible if token is not expired" do
6
6
  allow(subject).to receive(:expired?).and_return(false)
7
- should be_accessible
7
+ expect(subject).to be_accessible
8
8
  end
9
9
 
10
10
  it "is not accessible if token is expired" do
11
11
  allow(subject).to receive(:expired?).and_return(true)
12
- should_not be_accessible
12
+ expect(subject).not_to be_accessible
13
13
  end
14
14
  end
15
15
  end
16
16
 
17
17
  shared_examples "a revocable token" do
18
- describe :accessible? do
18
+ describe "#accessible?" do
19
19
  before { subject.save! }
20
20
 
21
21
  it "is accessible if token is not revoked" do
@@ -30,11 +30,11 @@ shared_examples "a revocable token" do
30
30
  end
31
31
 
32
32
  shared_examples "a unique token" do
33
- describe :token do
33
+ describe "#token" do
34
34
  let(:owner) { FactoryBot.create(:resource_owner) }
35
35
 
36
36
  it "is generated before validation" do
37
- expect { subject.valid? }.to change { subject.token }.from(nil)
37
+ expect { subject.valid? }.to change(subject, :token).from(nil)
38
38
  end
39
39
 
40
40
  it "is not valid if token exists" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doorkeeper-mongodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 5.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-01 00:00:00.000000000 Z
12
+ date: 2020-05-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: doorkeeper
@@ -146,6 +146,7 @@ files:
146
146
  - lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb
147
147
  - lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb
148
148
  - lib/doorkeeper-mongodb/mixins/mongoid/base_mixin.rb
149
+ - lib/doorkeeper-mongodb/mixins/mongoid/json_serializable.rb
149
150
  - lib/doorkeeper-mongodb/mixins/mongoid/stale_records_cleaner_mixin.rb
150
151
  - lib/doorkeeper-mongodb/shared/scopes.rb
151
152
  - lib/doorkeeper-mongodb/version.rb
@@ -177,6 +178,10 @@ files:
177
178
  - spec/controllers/protected_resources_controller_spec.rb
178
179
  - spec/controllers/token_info_controller_spec.rb
179
180
  - spec/controllers/tokens_controller_spec.rb
181
+ - spec/doorkeeper/redirect_uri_validator_spec.rb
182
+ - spec/doorkeeper/server_spec.rb
183
+ - spec/doorkeeper/stale_records_cleaner_spec.rb
184
+ - spec/doorkeeper/version_spec.rb
180
185
  - spec/dummy/Rakefile
181
186
  - spec/dummy/app/assets/config/manifest.js
182
187
  - spec/dummy/app/controllers/application_controller.rb
@@ -241,13 +246,13 @@ files:
241
246
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ma/MaK3K1AoZZ4xM5fOOifhROd73hfZJpP4yGbkGdoYtEk.cache
242
247
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/PA/PAH_jI20wRw12tngeJ-V619c30avNLDu5U9Z-9Pc5SQ.cache
243
248
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ph/Ph7RtH_NvG2I8XpTa8mA8SBQXZDzBPVIh4CH6g7OXJ0.cache
249
+ - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Pm/PmheG0PGFqDws1qgFOxOyIL-gpMof3Ar9eSRKVLYuik.cache
244
250
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Pn/PnXU_mkG2fLZFm9BwiZ03BZdBTjKuInP-cRXjHS7yJo.cache
245
251
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Qs/QsVgO6vM5Yn9oeYTYlrqtyVnK6sdVDWDa083N7zpfHw.cache
246
252
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/So/So59ksdx2dw-_A3-zFZ6Palr7fROjm7_0JDZb04temw.cache
247
253
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Wt/WtXL_iDofLeTH_v0Yf3PM421r9b1V0g-VBvMPeu9KA0.cache
248
254
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/b6/b6QRH6ZdCc0e6bUWu4qni_kZmptaMgWciO8Jl9q6_p8.cache
249
255
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/dX/dX6FDdUIy8yBCOoaoXcjf71rX9N_bpiXGJ4Urt32NTk.cache
250
- - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/eS/eSL1QMz46gKLM0GR6S9fL6uyARPxOImcappZ9_ZtSyg.cache
251
256
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/jC/jCTZ1jAldKBn4OTANBBmCKzxLrDgok1ur4meoTqlDNg.cache
252
257
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/qT/qTQIQsmS0Wbbg2JxNn9rxdI5qVOTg5SfyQdaTvr9vLo.cache
253
258
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/yN/yNOFGOsnHmxXNMkuEAWuL1u3jlmdvrdeoTx6DDJ1in8.cache
@@ -295,8 +300,6 @@ files:
295
300
  - spec/lib/secret_storing/bcrypt_spec.rb
296
301
  - spec/lib/secret_storing/plain_spec.rb
297
302
  - spec/lib/secret_storing/sha256_hash_spec.rb
298
- - spec/lib/server_spec.rb
299
- - spec/lib/stale_records_cleaner_spec.rb
300
303
  - spec/models/doorkeeper/access_grant_spec.rb
301
304
  - spec/models/doorkeeper/access_token_spec.rb
302
305
  - spec/models/doorkeeper/application_spec.rb
@@ -337,7 +340,6 @@ files:
337
340
  - spec/support/shared/controllers_shared_context.rb
338
341
  - spec/support/shared/hashing_shared_context.rb
339
342
  - spec/support/shared/models_shared_examples.rb
340
- - spec/version/version_spec.rb
341
343
  homepage: http://github.com/doorkeeper-gem/doorkeeper-mongodb
342
344
  licenses:
343
345
  - MIT
@@ -365,7 +367,6 @@ test_files:
365
367
  - spec/routing/default_routes_spec.rb
366
368
  - spec/routing/custom_controller_routes_spec.rb
367
369
  - spec/routing/scoped_routes_spec.rb
368
- - spec/lib/server_spec.rb
369
370
  - spec/lib/oauth/code_response_spec.rb
370
371
  - spec/lib/oauth/token_spec.rb
371
372
  - spec/lib/oauth/code_request_spec.rb
@@ -399,7 +400,6 @@ test_files:
399
400
  - spec/lib/secret_storing/plain_spec.rb
400
401
  - spec/lib/secret_storing/sha256_hash_spec.rb
401
402
  - spec/lib/config_spec.rb
402
- - spec/lib/stale_records_cleaner_spec.rb
403
403
  - spec/lib/models/secret_storable_spec.rb
404
404
  - spec/lib/models/revocable_spec.rb
405
405
  - spec/lib/models/expirable_spec.rb
@@ -408,7 +408,6 @@ test_files:
408
408
  - spec/lib/doorkeeper_spec.rb
409
409
  - spec/lib/option_spec.rb
410
410
  - spec/lib/request/strategy_spec.rb
411
- - spec/version/version_spec.rb
412
411
  - spec/spec_helper_integration.rb
413
412
  - spec/helpers/doorkeeper/dashboard_helper_spec.rb
414
413
  - spec/controllers/tokens_controller_spec.rb
@@ -440,6 +439,7 @@ test_files:
440
439
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/9x/9xjtGv-yKjj62x9uFwBZg8pTSh9ERPAgANwNo9uwIaA.cache
441
440
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/-o/-ofn45zIfO5vx4VD6m6NXesLf6da5usA-Sbw2SVju3o.cache
442
441
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Bt/BtXO7f0PZ8DNt3TMLYM-zY7LkbWa_KgyB0v1V98M1CQ.cache
442
+ - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Pm/PmheG0PGFqDws1qgFOxOyIL-gpMof3Ar9eSRKVLYuik.cache
443
443
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/E0/E02f1Q2tutWumMulGCFNfqQNjvEP_hMAK_5E83eWepI.cache
444
444
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Lk/LklIq5hrBAPESXVUpFMwQ9L-1qTj90sPVi6U19_Xi-Q.cache
445
445
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/MB/MBWRxa9S470ee8suxVKp0jYgv6K6FQOqKGV0kPGQNMs.cache
@@ -448,7 +448,6 @@ test_files:
448
448
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/7H/7HjRsym0tTpXFCVhWt6kteMs_-CozKVbr9s5syHm8es.cache
449
449
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/FJ/FJlQpfMtpRbrM5P8A7d2FAelFKwo6GrVs2xks8z5GKU.cache
450
450
  - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/qT/qTQIQsmS0Wbbg2JxNn9rxdI5qVOTg5SfyQdaTvr9vLo.cache
451
- - spec/dummy/tmp/cache/assets/sprockets/v4.0.0/eS/eSL1QMz46gKLM0GR6S9fL6uyARPxOImcappZ9_ZtSyg.cache
452
451
  - spec/dummy/log/test.log
453
452
  - spec/dummy/config/environment.rb
454
453
  - spec/dummy/config/mongoid4.yml
@@ -511,6 +510,10 @@ test_files:
511
510
  - spec/support/shared/models_shared_examples.rb
512
511
  - spec/support/shared/hashing_shared_context.rb
513
512
  - spec/support/shared/controllers_shared_context.rb
513
+ - spec/doorkeeper/server_spec.rb
514
+ - spec/doorkeeper/stale_records_cleaner_spec.rb
515
+ - spec/doorkeeper/version_spec.rb
516
+ - spec/doorkeeper/redirect_uri_validator_spec.rb
514
517
  - spec/factories.rb
515
518
  - spec/spec_helper.rb
516
519
  - spec/requests/flows/password_spec.rb