doorkeeper-mongodb 5.3.0 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/Rakefile +18 -4
- data/lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb +45 -5
- data/lib/doorkeeper-mongodb/version.rb +1 -1
- data/spec/dummy/app/assets/config/manifest.js +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +0 -0
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +0 -0
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +0 -0
- data/spec/dummy/app/controllers/home_controller.rb +0 -0
- data/spec/dummy/app/controllers/metal_controller.rb +0 -0
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/views/home/index.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +0 -0
- data/spec/dummy/config/application.rb +0 -0
- data/spec/dummy/config/boot.rb +0 -0
- data/spec/dummy/config/database.yml +0 -0
- data/spec/dummy/config/environment.rb +0 -0
- data/spec/dummy/config/environments/development.rb +0 -0
- data/spec/dummy/config/environments/production.rb +0 -0
- data/spec/dummy/config/environments/test.rb +0 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/dummy/config/initializers/doorkeeper.rb +7 -2
- data/spec/dummy/config/initializers/secret_token.rb +0 -0
- data/spec/dummy/config/initializers/session_store.rb +0 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/spec/dummy/config/locales/doorkeeper.en.yml +0 -0
- data/spec/dummy/config/mongoid8.yml +19 -0
- data/spec/dummy/config/routes.rb +0 -0
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/db/migrate/20111122132257_create_users.rb +0 -0
- data/spec/dummy/db/migrate/20120312140401_add_password_to_users.rb +0 -0
- data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +0 -0
- data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +0 -0
- data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +0 -0
- data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +0 -0
- data/spec/dummy/db/migrate/20180210183654_add_confidential_to_applications.rb +0 -0
- data/spec/dummy/db/migrate/20230205064514_add_custom_attributes.rb +8 -0
- data/spec/dummy/db/schema.rb +3 -1
- data/spec/dummy/log/test.log +39440 -0
- data/spec/dummy/public/404.html +0 -0
- data/spec/dummy/public/422.html +0 -0
- data/spec/dummy/public/500.html +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/2L/2LdlR-88TqZc8vSU7Z58xiNpCGRZj0CIlOxSN4Vx2i4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{Pn/PnXU_mkG2fLZFm9BwiZ03BZdBTjKuInP-cRXjHS7yJo.cache → 2r/2r0L9eNOmETsg4Tm1IgBdw3J4ahcko41NpILRXu19_A.cache} +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/5y/5ywocFQgpSY36nyF_xDKPExhDRo-eqeiqfDvQee1K9k.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{Qs/QsVgO6vM5Yn9oeYTYlrqtyVnK6sdVDWDa083N7zpfHw.cache → 8r/8rW0CpDDUJZ7xvg86t6jZ6WmyvaVZ0uTPEPRjghFIKo.cache} +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{PA/PAH_jI20wRw12tngeJ-V619c30avNLDu5U9Z-9Pc5SQ.cache → Cs/CsfBL8Dls9-jhjFsNYt4DZxu5LWChDMB-xXKjsEFSsU.cache} +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{8D/8DJG7JfPvShfLLyeSom6NZ_TcQc6QH27tJ7prEWZPfI.cache → Cv/Cv9WXE_0OqtPUZBXfTWaE8uKx9oFIzqO18ZkwVaBLSg.cache} +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Mf/MfB2-0nbsmC548XBSLftafi6BZ9nAquBA-6eu7mAmdE.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/N2/N2cUP-Um_nQ5ZTCQr_H0bKIjOSIyV7Ry5sT6-DB9e4A.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{FJ/FJlQpfMtpRbrM5P8A7d2FAelFKwo6GrVs2xks8z5GKU.cache → Ot/OtNAnT3d-csAKBtJ8UBLOSwUDyfmOdCWpS08RaSCGsQ.cache} +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/P3/P33RwiTMGEu2wZySBEUmf5U7hnfBhdL49wzdUWXYNRs.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/RZ/RZAL9gIt4aD731Ikf7UZZNPSZXzhPqtDskLB7nQcWH4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/SQ/SQVJeYO2bM0qgQiOaeVBjYo3SWQZmvixa3tXUjsmuUs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{Ma/MaK3K1AoZZ4xM5fOOifhROd73hfZJpP4yGbkGdoYtEk.cache → V2/V2JApVhUSYhvWnNVIbpe58U4xheVkpi0gCStqjDN6-A.cache} +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{Lk/LklIq5hrBAPESXVUpFMwQ9L-1qTj90sPVi6U19_Xi-Q.cache → VA/VADOUaZFukufOb44ts4KoyQZumPcVJET0bi9RvC7c-o.cache} +1 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Vz/VzdPLfWn16XbpHNJdkDMamAf3QutM29cvvPkDNyy5nE.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/W9/W9QfraySVwoRt-SgGOIS0e-iP8R1qP_URwXZw1l6M5E.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Wy/Wyiw07ngOzgV6RPis_Lo2hhSRkwo2YSqKTEDAF0crhA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Z6/Z6rAtdVt3OXS26vLVCtdO3vmMlttI3ajdpbC2FHk7iQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/b6/b6QRH6ZdCc0e6bUWu4qni_kZmptaMgWciO8Jl9q6_p8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{Pm/PmheG0PGFqDws1qgFOxOyIL-gpMof3Ar9eSRKVLYuik.cache → fP/fPihom3hnc1rQQxpviTvZPRJB_IghWYWP3dDcsGrcLk.cache} +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/gD/gDU38plXvosMgFK47_PBI9xGVsmsE2tShWEZzxiek3k.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/gR/gRqL5_jaFW7eA3d2frJmOzw_vFLuvfhwMhotAlsO8J4.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/jC/jCTZ1jAldKBn4OTANBBmCKzxLrDgok1ur4meoTqlDNg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{yN/yNOFGOsnHmxXNMkuEAWuL1u3jlmdvrdeoTx6DDJ1in8.cache → jc/jcB8w1gBT7JP10DW4OOvvYpW1ZFeMyedngmMy3QbRLQ.cache} +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/jg/jgxXkkkXf1NPOPrpNdEJzhDt-2xHGzd_-mLkIHWrOr4.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/nx/nxzZnvk5YyBhTUloQSZZ5zRuaqlsLiHy_AbOzQ3d788.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/wr/wrlf8nUW2yftpcIA97qImyECR8f8o3OiOdHLdfkmw8c.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{qT/qTQIQsmS0Wbbg2JxNn9rxdI5qVOTg5SfyQdaTvr9vLo.cache → xd/xdD4KJ55W3jy5PIrwT0UnDp1toKpUfgrjJBgB4WaPIc.cache} +0 -0
- data/spec/support/doorkeeper_rspec.rb +0 -0
- data/spec/support/orm/mongoid.rb +18 -2
- data/spec/support/orm/mongoid8.rb +6 -0
- data/spec/support/render_with_matcher.rb +26 -0
- metadata +117 -241
- data/spec/controllers/application_metal_controller_spec.rb +0 -64
- data/spec/controllers/applications_controller_spec.rb +0 -270
- data/spec/controllers/authorizations_controller_spec.rb +0 -744
- data/spec/controllers/protected_resources_controller_spec.rb +0 -361
- data/spec/controllers/token_info_controller_spec.rb +0 -50
- data/spec/controllers/tokens_controller_spec.rb +0 -542
- data/spec/doorkeeper/redirect_uri_validator_spec.rb +0 -183
- data/spec/doorkeeper/server_spec.rb +0 -50
- data/spec/doorkeeper/stale_records_cleaner_spec.rb +0 -103
- data/spec/doorkeeper/version_spec.rb +0 -17
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/-o/-ofn45zIfO5vx4VD6m6NXesLf6da5usA-Sbw2SVju3o.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/0_/0_ouGcG_o_1zmVmBe-tdQYk594LBwVa1bumjrKtdfEw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/2X/2XMMcHbyTSRqh1GkV0xzyIETNtt-zgN6iniziShaKmQ.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/4Q/4QQw-pMQ98JIj3xdcFhGBQdysdGPY9rWffRqWMmyjew.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/7H/7HjRsym0tTpXFCVhWt6kteMs_-CozKVbr9s5syHm8es.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8B/8BxJyv22HPFHu1se_l2J8qW1N9NzZ16UOWOy1YMSgs4.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/9x/9xjtGv-yKjj62x9uFwBZg8pTSh9ERPAgANwNo9uwIaA.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Bt/BtXO7f0PZ8DNt3TMLYM-zY7LkbWa_KgyB0v1V98M1CQ.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/E0/E02f1Q2tutWumMulGCFNfqQNjvEP_hMAK_5E83eWepI.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/EZ/EZGpd6pUEJZxO6uT2yIS4Fpn5KX7VDgC9VB3AaemF5Q.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/L8/L8mOWakJlWKr6MU85rj0V7yGFfNyIR6vE6YXtqArPGw.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/MB/MBWRxa9S470ee8suxVKp0jYgv6K6FQOqKGV0kPGQNMs.cache +0 -1
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ph/Ph7RtH_NvG2I8XpTa8mA8SBQXZDzBPVIh4CH6g7OXJ0.cache +0 -2
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/So/So59ksdx2dw-_A3-zFZ6Palr7fROjm7_0JDZb04temw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Wt/WtXL_iDofLeTH_v0Yf3PM421r9b1V0g-VBvMPeu9KA0.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/dX/dX6FDdUIy8yBCOoaoXcjf71rX9N_bpiXGJ4Urt32NTk.cache +0 -0
- data/spec/factories.rb +0 -30
- data/spec/grape/grape_integration_spec.rb +0 -137
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +0 -26
- data/spec/lib/config_spec.rb +0 -824
- data/spec/lib/doorkeeper_spec.rb +0 -27
- data/spec/lib/models/expirable_spec.rb +0 -61
- data/spec/lib/models/reusable_spec.rb +0 -40
- data/spec/lib/models/revocable_spec.rb +0 -55
- data/spec/lib/models/scopes_spec.rb +0 -61
- data/spec/lib/models/secret_storable_spec.rb +0 -136
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +0 -35
- data/spec/lib/oauth/authorization_code_request_spec.rb +0 -180
- data/spec/lib/oauth/base_request_spec.rb +0 -210
- data/spec/lib/oauth/base_response_spec.rb +0 -45
- data/spec/lib/oauth/client/credentials_spec.rb +0 -90
- data/spec/lib/oauth/client_credentials/creator_spec.rb +0 -135
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +0 -110
- data/spec/lib/oauth/client_credentials/validation_spec.rb +0 -92
- data/spec/lib/oauth/client_credentials_integration_spec.rb +0 -27
- data/spec/lib/oauth/client_credentials_request_spec.rb +0 -105
- data/spec/lib/oauth/client_spec.rb +0 -38
- data/spec/lib/oauth/code_request_spec.rb +0 -46
- data/spec/lib/oauth/code_response_spec.rb +0 -36
- data/spec/lib/oauth/error_response_spec.rb +0 -65
- data/spec/lib/oauth/error_spec.rb +0 -21
- data/spec/lib/oauth/forbidden_token_response_spec.rb +0 -20
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +0 -110
- data/spec/lib/oauth/helpers/unique_token_spec.rb +0 -21
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +0 -262
- data/spec/lib/oauth/invalid_request_response_spec.rb +0 -73
- data/spec/lib/oauth/invalid_token_response_spec.rb +0 -53
- data/spec/lib/oauth/password_access_token_request_spec.rb +0 -202
- data/spec/lib/oauth/pre_authorization_spec.rb +0 -230
- data/spec/lib/oauth/refresh_token_request_spec.rb +0 -166
- data/spec/lib/oauth/scopes_spec.rb +0 -146
- data/spec/lib/oauth/token_request_spec.rb +0 -164
- data/spec/lib/oauth/token_response_spec.rb +0 -84
- data/spec/lib/oauth/token_spec.rb +0 -156
- data/spec/lib/option_spec.rb +0 -51
- data/spec/lib/request/strategy_spec.rb +0 -51
- data/spec/lib/secret_storing/base_spec.rb +0 -61
- data/spec/lib/secret_storing/bcrypt_spec.rb +0 -50
- data/spec/lib/secret_storing/plain_spec.rb +0 -45
- data/spec/lib/secret_storing/sha256_hash_spec.rb +0 -49
- data/spec/models/doorkeeper/access_grant_spec.rb +0 -173
- data/spec/models/doorkeeper/access_token_spec.rb +0 -644
- data/spec/models/doorkeeper/application_spec.rb +0 -499
- data/spec/requests/applications/applications_request_spec.rb +0 -257
- data/spec/requests/applications/authorized_applications_spec.rb +0 -32
- data/spec/requests/endpoints/authorization_spec.rb +0 -91
- data/spec/requests/endpoints/token_spec.rb +0 -85
- data/spec/requests/flows/authorization_code_errors_spec.rb +0 -86
- data/spec/requests/flows/authorization_code_spec.rb +0 -559
- data/spec/requests/flows/client_credentials_spec.rb +0 -219
- data/spec/requests/flows/implicit_grant_errors_spec.rb +0 -46
- data/spec/requests/flows/implicit_grant_spec.rb +0 -91
- data/spec/requests/flows/password_spec.rb +0 -356
- data/spec/requests/flows/refresh_token_spec.rb +0 -255
- data/spec/requests/flows/revoke_token_spec.rb +0 -196
- data/spec/requests/flows/skip_authorization_spec.rb +0 -66
- data/spec/requests/protected_resources/metal_spec.rb +0 -16
- data/spec/requests/protected_resources/private_api_spec.rb +0 -83
- data/spec/routing/custom_controller_routes_spec.rb +0 -133
- data/spec/routing/default_routes_spec.rb +0 -41
- data/spec/routing/scoped_routes_spec.rb +0 -47
- data/spec/spec_helper.rb +0 -54
- data/spec/spec_helper_integration.rb +0 -4
- data/spec/support/dependencies/factory_bot.rb +0 -4
- data/spec/support/helpers/access_token_request_helper.rb +0 -14
- data/spec/support/helpers/authorization_request_helper.rb +0 -43
- data/spec/support/helpers/config_helper.rb +0 -11
- data/spec/support/helpers/model_helper.rb +0 -78
- data/spec/support/helpers/request_spec_helper.rb +0 -98
- data/spec/support/helpers/url_helper.rb +0 -62
- data/spec/support/orm/active_record.rb +0 -5
- data/spec/support/shared/controllers_shared_context.rb +0 -100
- data/spec/support/shared/hashing_shared_context.rb +0 -40
- data/spec/support/shared/models_shared_examples.rb +0 -56
data/spec/lib/config_spec.rb
DELETED
@@ -1,824 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe Doorkeeper::Config do
|
6
|
-
subject(:config) { Doorkeeper.config }
|
7
|
-
|
8
|
-
describe "resource_owner_authenticator" do
|
9
|
-
it "sets the block that is accessible via authenticate_resource_owner" do
|
10
|
-
block = proc {}
|
11
|
-
Doorkeeper.configure do
|
12
|
-
orm DOORKEEPER_ORM
|
13
|
-
resource_owner_authenticator(&block)
|
14
|
-
end
|
15
|
-
|
16
|
-
expect(subject.authenticate_resource_owner).to eq(block)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "prints warning message by default" do
|
20
|
-
Doorkeeper.configure do
|
21
|
-
orm DOORKEEPER_ORM
|
22
|
-
end
|
23
|
-
|
24
|
-
expect(Rails.logger).to receive(:warn).with(
|
25
|
-
I18n.t("doorkeeper.errors.messages.resource_owner_authenticator_not_configured"),
|
26
|
-
)
|
27
|
-
subject.authenticate_resource_owner.call(nil)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "resource_owner_from_credentials" do
|
32
|
-
it "sets the block that is accessible via authenticate_resource_owner" do
|
33
|
-
block = proc {}
|
34
|
-
Doorkeeper.configure do
|
35
|
-
orm DOORKEEPER_ORM
|
36
|
-
resource_owner_from_credentials(&block)
|
37
|
-
end
|
38
|
-
|
39
|
-
expect(subject.resource_owner_from_credentials).to eq(block)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "prints warning message by default" do
|
43
|
-
Doorkeeper.configure do
|
44
|
-
orm DOORKEEPER_ORM
|
45
|
-
end
|
46
|
-
|
47
|
-
expect(Rails.logger).to receive(:warn).with(
|
48
|
-
I18n.t("doorkeeper.errors.messages.credential_flow_not_configured"),
|
49
|
-
)
|
50
|
-
subject.resource_owner_from_credentials.call(nil)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "setup_orm_adapter" do
|
55
|
-
it "adds specific error message to NameError exception" do
|
56
|
-
expect do
|
57
|
-
Doorkeeper.configure { orm "hibernate" }
|
58
|
-
end.to raise_error(NameError, /ORM adapter not found \(hibernate\)/)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "does not change other exceptions" do
|
62
|
-
allow(Doorkeeper).to receive(:setup_orm_adapter) { raise NoMethodError }
|
63
|
-
|
64
|
-
expect do
|
65
|
-
Doorkeeper.configure { orm "hibernate" }
|
66
|
-
end.to raise_error(NoMethodError)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "admin_authenticator" do
|
71
|
-
it "sets the block that is accessible via authenticate_admin" do
|
72
|
-
default_behaviour = "default behaviour"
|
73
|
-
allow(described_class).to receive(:head).and_return(default_behaviour)
|
74
|
-
|
75
|
-
Doorkeeper.configure do
|
76
|
-
orm DOORKEEPER_ORM
|
77
|
-
end
|
78
|
-
|
79
|
-
expect(subject.authenticate_admin.call({})).to eq(default_behaviour)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "could be customized with a block" do
|
83
|
-
block = proc {}
|
84
|
-
Doorkeeper.configure do
|
85
|
-
orm DOORKEEPER_ORM
|
86
|
-
admin_authenticator(&block)
|
87
|
-
end
|
88
|
-
|
89
|
-
expect(subject.authenticate_admin).to eq(block)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe "access_token_expires_in" do
|
94
|
-
it "has 2 hours by default" do
|
95
|
-
expect(subject.access_token_expires_in).to eq(2.hours)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "can change the value" do
|
99
|
-
Doorkeeper.configure do
|
100
|
-
orm DOORKEEPER_ORM
|
101
|
-
access_token_expires_in 4.hours
|
102
|
-
end
|
103
|
-
expect(subject.access_token_expires_in).to eq(4.hours)
|
104
|
-
end
|
105
|
-
|
106
|
-
it "can be set to nil" do
|
107
|
-
Doorkeeper.configure do
|
108
|
-
orm DOORKEEPER_ORM
|
109
|
-
access_token_expires_in nil
|
110
|
-
end
|
111
|
-
|
112
|
-
expect(subject.access_token_expires_in).to be_nil
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "scopes" do
|
117
|
-
it "has default scopes" do
|
118
|
-
Doorkeeper.configure do
|
119
|
-
orm DOORKEEPER_ORM
|
120
|
-
default_scopes :public
|
121
|
-
end
|
122
|
-
|
123
|
-
expect(subject.default_scopes).to include("public")
|
124
|
-
end
|
125
|
-
|
126
|
-
it "has optional scopes" do
|
127
|
-
Doorkeeper.configure do
|
128
|
-
orm DOORKEEPER_ORM
|
129
|
-
optional_scopes :write, :update
|
130
|
-
end
|
131
|
-
|
132
|
-
expect(subject.optional_scopes).to include("write", "update")
|
133
|
-
end
|
134
|
-
|
135
|
-
it "has all scopes" do
|
136
|
-
Doorkeeper.configure do
|
137
|
-
orm DOORKEEPER_ORM
|
138
|
-
default_scopes :normal
|
139
|
-
optional_scopes :admin
|
140
|
-
end
|
141
|
-
|
142
|
-
expect(subject.scopes).to include("normal", "admin")
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
describe "scopes_by_grant_type" do
|
147
|
-
it "is {} by default" do
|
148
|
-
expect(subject.scopes_by_grant_type).to eq({})
|
149
|
-
end
|
150
|
-
|
151
|
-
it "has hash value" do
|
152
|
-
hash = {}
|
153
|
-
Doorkeeper.configure do
|
154
|
-
orm DOORKEEPER_ORM
|
155
|
-
scopes_by_grant_type hash
|
156
|
-
end
|
157
|
-
|
158
|
-
expect(subject.scopes_by_grant_type).to eq(hash)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "use_refresh_token" do
|
163
|
-
it "is false by default" do
|
164
|
-
expect(subject.refresh_token_enabled?).to eq(false)
|
165
|
-
end
|
166
|
-
|
167
|
-
it "can change the value" do
|
168
|
-
Doorkeeper.configure do
|
169
|
-
orm DOORKEEPER_ORM
|
170
|
-
use_refresh_token
|
171
|
-
end
|
172
|
-
|
173
|
-
expect(subject.refresh_token_enabled?).to eq(true)
|
174
|
-
end
|
175
|
-
|
176
|
-
it "can accept a boolean parameter" do
|
177
|
-
Doorkeeper.configure do
|
178
|
-
orm DOORKEEPER_ORM
|
179
|
-
use_refresh_token false
|
180
|
-
end
|
181
|
-
|
182
|
-
expect(subject.refresh_token_enabled?).to eq(false)
|
183
|
-
end
|
184
|
-
|
185
|
-
it "can accept a block parameter" do
|
186
|
-
Doorkeeper.configure do
|
187
|
-
orm DOORKEEPER_ORM
|
188
|
-
use_refresh_token { |_context| nil }
|
189
|
-
end
|
190
|
-
|
191
|
-
expect(subject.refresh_token_enabled?).to be_a(Proc)
|
192
|
-
end
|
193
|
-
|
194
|
-
it "does not includes 'refresh_token' in authorization_response_types" do
|
195
|
-
expect(subject.token_grant_types).not_to include "refresh_token"
|
196
|
-
end
|
197
|
-
|
198
|
-
context "when enabled" do
|
199
|
-
before do
|
200
|
-
Doorkeeper.configure do
|
201
|
-
orm DOORKEEPER_ORM
|
202
|
-
use_refresh_token
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
it "includes 'refresh_token' in authorization_response_types" do
|
207
|
-
expect(subject.token_grant_types).to include "refresh_token"
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe "token_reuse_limit" do
|
213
|
-
it "is 100 by default" do
|
214
|
-
expect(subject.token_reuse_limit).to eq(100)
|
215
|
-
end
|
216
|
-
|
217
|
-
it "can change the value" do
|
218
|
-
Doorkeeper.configure do
|
219
|
-
orm DOORKEEPER_ORM
|
220
|
-
token_reuse_limit 90
|
221
|
-
end
|
222
|
-
|
223
|
-
expect(subject.token_reuse_limit).to eq(90)
|
224
|
-
end
|
225
|
-
|
226
|
-
it "sets the value to 100 if invalid value is being set" do
|
227
|
-
expect(Rails.logger).to receive(:warn).with(/will be set to default 100/)
|
228
|
-
|
229
|
-
Doorkeeper.configure do
|
230
|
-
orm DOORKEEPER_ORM
|
231
|
-
reuse_access_token
|
232
|
-
token_reuse_limit 110
|
233
|
-
end
|
234
|
-
|
235
|
-
expect(subject.token_reuse_limit).to eq(100)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
describe "enforce_configured_scopes" do
|
240
|
-
it "is false by default" do
|
241
|
-
expect(subject.enforce_configured_scopes?).to eq(false)
|
242
|
-
end
|
243
|
-
|
244
|
-
it "can change the value" do
|
245
|
-
Doorkeeper.configure do
|
246
|
-
orm DOORKEEPER_ORM
|
247
|
-
enforce_configured_scopes
|
248
|
-
end
|
249
|
-
|
250
|
-
expect(subject.enforce_configured_scopes?).to eq(true)
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
describe "client_credentials" do
|
255
|
-
it "has defaults order" do
|
256
|
-
expect(subject.client_credentials_methods)
|
257
|
-
.to eq(%i[from_basic from_params])
|
258
|
-
end
|
259
|
-
|
260
|
-
it "can change the value" do
|
261
|
-
Doorkeeper.configure do
|
262
|
-
orm DOORKEEPER_ORM
|
263
|
-
client_credentials :from_digest, :from_params
|
264
|
-
end
|
265
|
-
|
266
|
-
expect(subject.client_credentials_methods)
|
267
|
-
.to eq(%i[from_digest from_params])
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
describe "force_ssl_in_redirect_uri" do
|
272
|
-
it "is true by default in non-development environments" do
|
273
|
-
expect(subject.force_ssl_in_redirect_uri).to eq(true)
|
274
|
-
end
|
275
|
-
|
276
|
-
it "can change the value" do
|
277
|
-
Doorkeeper.configure do
|
278
|
-
orm DOORKEEPER_ORM
|
279
|
-
force_ssl_in_redirect_uri(false)
|
280
|
-
end
|
281
|
-
|
282
|
-
expect(subject.force_ssl_in_redirect_uri).to eq(false)
|
283
|
-
end
|
284
|
-
|
285
|
-
it "can be a callable object" do
|
286
|
-
block = proc { false }
|
287
|
-
Doorkeeper.configure do
|
288
|
-
orm DOORKEEPER_ORM
|
289
|
-
force_ssl_in_redirect_uri(&block)
|
290
|
-
end
|
291
|
-
|
292
|
-
expect(subject.force_ssl_in_redirect_uri).to eq(block)
|
293
|
-
expect(subject.force_ssl_in_redirect_uri.call).to eq(false)
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
describe "access_token_methods" do
|
298
|
-
it "has defaults order" do
|
299
|
-
expect(subject.access_token_methods)
|
300
|
-
.to eq(%i[from_bearer_authorization from_access_token_param from_bearer_param])
|
301
|
-
end
|
302
|
-
|
303
|
-
it "can change the value" do
|
304
|
-
Doorkeeper.configure do
|
305
|
-
orm DOORKEEPER_ORM
|
306
|
-
access_token_methods :from_access_token_param, :from_bearer_param
|
307
|
-
end
|
308
|
-
|
309
|
-
expect(subject.access_token_methods)
|
310
|
-
.to eq(%i[from_access_token_param from_bearer_param])
|
311
|
-
end
|
312
|
-
end
|
313
|
-
|
314
|
-
describe "forbid_redirect_uri" do
|
315
|
-
it "is false by default" do
|
316
|
-
expect(subject.forbid_redirect_uri.call(URI.parse("https://localhost"))).to eq(false)
|
317
|
-
end
|
318
|
-
|
319
|
-
it "can be a callable object" do
|
320
|
-
block = proc { true }
|
321
|
-
Doorkeeper.configure do
|
322
|
-
orm DOORKEEPER_ORM
|
323
|
-
forbid_redirect_uri(&block)
|
324
|
-
end
|
325
|
-
|
326
|
-
expect(subject.forbid_redirect_uri).to eq(block)
|
327
|
-
expect(subject.forbid_redirect_uri.call).to eq(true)
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
describe "enable_application_owner" do
|
332
|
-
it "is disabled by default" do
|
333
|
-
expect(Doorkeeper.config.enable_application_owner?).not_to eq(true)
|
334
|
-
end
|
335
|
-
|
336
|
-
context "when enabled without confirmation" do
|
337
|
-
before do
|
338
|
-
Doorkeeper.configure do
|
339
|
-
orm DOORKEEPER_ORM
|
340
|
-
enable_application_owner
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
it "adds support for application owner" do
|
345
|
-
expect(Doorkeeper::Application.new).to respond_to :owner
|
346
|
-
end
|
347
|
-
|
348
|
-
it "Doorkeeper.configuration.confirm_application_owner? returns false" do
|
349
|
-
expect(Doorkeeper.config.confirm_application_owner?).not_to eq(true)
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
context "when enabled with confirmation set to true" do
|
354
|
-
before do
|
355
|
-
Doorkeeper.configure do
|
356
|
-
orm DOORKEEPER_ORM
|
357
|
-
enable_application_owner confirmation: true
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
|
-
it "adds support for application owner" do
|
362
|
-
expect(Doorkeeper::Application.new).to respond_to :owner
|
363
|
-
end
|
364
|
-
|
365
|
-
it "Doorkeeper.configuration.confirm_application_owner? returns true" do
|
366
|
-
expect(Doorkeeper.config.confirm_application_owner?).to eq(true)
|
367
|
-
end
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
describe "realm" do
|
372
|
-
it "is 'Doorkeeper' by default" do
|
373
|
-
expect(Doorkeeper.config.realm).to eq("Doorkeeper")
|
374
|
-
end
|
375
|
-
|
376
|
-
it "can change the value" do
|
377
|
-
Doorkeeper.configure do
|
378
|
-
orm DOORKEEPER_ORM
|
379
|
-
realm "Example"
|
380
|
-
end
|
381
|
-
|
382
|
-
expect(subject.realm).to eq("Example")
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
describe "grant_flows" do
|
387
|
-
it "is set to all grant flows by default" do
|
388
|
-
expect(Doorkeeper.config.grant_flows)
|
389
|
-
.to eq(%w[authorization_code client_credentials])
|
390
|
-
end
|
391
|
-
|
392
|
-
it "can change the value" do
|
393
|
-
Doorkeeper.configure do
|
394
|
-
orm DOORKEEPER_ORM
|
395
|
-
grant_flows %w[authorization_code implicit]
|
396
|
-
end
|
397
|
-
|
398
|
-
expect(subject.grant_flows).to eq %w[authorization_code implicit]
|
399
|
-
end
|
400
|
-
|
401
|
-
context "when including 'authorization_code'" do
|
402
|
-
before do
|
403
|
-
Doorkeeper.configure do
|
404
|
-
orm DOORKEEPER_ORM
|
405
|
-
grant_flows ["authorization_code"]
|
406
|
-
end
|
407
|
-
end
|
408
|
-
|
409
|
-
it "includes 'code' in authorization_response_types" do
|
410
|
-
expect(subject.authorization_response_types).to include "code"
|
411
|
-
end
|
412
|
-
|
413
|
-
it "includes 'authorization_code' in token_grant_types" do
|
414
|
-
expect(subject.token_grant_types).to include "authorization_code"
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
context "when including 'implicit'" do
|
419
|
-
before do
|
420
|
-
Doorkeeper.configure do
|
421
|
-
orm DOORKEEPER_ORM
|
422
|
-
grant_flows ["implicit"]
|
423
|
-
end
|
424
|
-
end
|
425
|
-
|
426
|
-
it "includes 'token' in authorization_response_types" do
|
427
|
-
expect(subject.authorization_response_types).to include "token"
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
context "when including 'password'" do
|
432
|
-
before do
|
433
|
-
Doorkeeper.configure do
|
434
|
-
orm DOORKEEPER_ORM
|
435
|
-
grant_flows ["password"]
|
436
|
-
end
|
437
|
-
end
|
438
|
-
|
439
|
-
it "includes 'password' in token_grant_types" do
|
440
|
-
expect(subject.token_grant_types).to include "password"
|
441
|
-
end
|
442
|
-
end
|
443
|
-
|
444
|
-
context "when including 'client_credentials'" do
|
445
|
-
before do
|
446
|
-
Doorkeeper.configure do
|
447
|
-
orm DOORKEEPER_ORM
|
448
|
-
grant_flows ["client_credentials"]
|
449
|
-
end
|
450
|
-
end
|
451
|
-
|
452
|
-
it "includes 'client_credentials' in token_grant_types" do
|
453
|
-
expect(subject.token_grant_types).to include "client_credentials"
|
454
|
-
end
|
455
|
-
end
|
456
|
-
end
|
457
|
-
|
458
|
-
it "raises an exception when configuration is not set" do
|
459
|
-
old_config = Doorkeeper.config
|
460
|
-
Doorkeeper.module_eval do
|
461
|
-
@config = nil
|
462
|
-
end
|
463
|
-
|
464
|
-
expect do
|
465
|
-
Doorkeeper.config
|
466
|
-
end.to raise_error Doorkeeper::MissingConfiguration
|
467
|
-
|
468
|
-
Doorkeeper.module_eval do
|
469
|
-
@config = old_config
|
470
|
-
end
|
471
|
-
end
|
472
|
-
|
473
|
-
describe "access_token_generator" do
|
474
|
-
it "is 'Doorkeeper::OAuth::Helpers::UniqueToken' by default" do
|
475
|
-
expect(Doorkeeper.configuration.access_token_generator).to(
|
476
|
-
eq("Doorkeeper::OAuth::Helpers::UniqueToken"),
|
477
|
-
)
|
478
|
-
end
|
479
|
-
|
480
|
-
it "can change the value" do
|
481
|
-
Doorkeeper.configure do
|
482
|
-
orm DOORKEEPER_ORM
|
483
|
-
access_token_generator "Example"
|
484
|
-
end
|
485
|
-
expect(subject.access_token_generator).to eq("Example")
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
|
-
describe "default_generator_method" do
|
490
|
-
it "is :urlsafe_base64 by default" do
|
491
|
-
expect(Doorkeeper.configuration.default_generator_method)
|
492
|
-
.to eq(:urlsafe_base64)
|
493
|
-
end
|
494
|
-
|
495
|
-
it "can change the value" do
|
496
|
-
Doorkeeper.configure do
|
497
|
-
orm DOORKEEPER_ORM
|
498
|
-
default_generator_method :hex
|
499
|
-
end
|
500
|
-
|
501
|
-
expect(subject.default_generator_method).to eq(:hex)
|
502
|
-
end
|
503
|
-
end
|
504
|
-
|
505
|
-
describe "base_controller" do
|
506
|
-
context "when default value set" do
|
507
|
-
it { expect(Doorkeeper.configuration.base_controller).to be_an_instance_of(Proc) }
|
508
|
-
|
509
|
-
it "resolves to a ApplicationController::Base in default mode" do
|
510
|
-
expect(Doorkeeper.configuration.resolve_controller(:base))
|
511
|
-
.to eq(ActionController::Base)
|
512
|
-
end
|
513
|
-
|
514
|
-
it "resolves to a ApplicationController::API in api_only mode" do
|
515
|
-
Doorkeeper.configure do
|
516
|
-
orm DOORKEEPER_ORM
|
517
|
-
api_only
|
518
|
-
end
|
519
|
-
|
520
|
-
expect(Doorkeeper.configuration.resolve_controller(:base))
|
521
|
-
.to eq(ActionController::API)
|
522
|
-
end
|
523
|
-
end
|
524
|
-
|
525
|
-
context "when custom value set" do
|
526
|
-
before do
|
527
|
-
Doorkeeper.configure do
|
528
|
-
orm DOORKEEPER_ORM
|
529
|
-
base_controller "ApplicationController"
|
530
|
-
end
|
531
|
-
end
|
532
|
-
|
533
|
-
it { expect(Doorkeeper.config.base_controller).to eq("ApplicationController") }
|
534
|
-
end
|
535
|
-
end
|
536
|
-
|
537
|
-
describe "base_metal_controller" do
|
538
|
-
context "when default value set" do
|
539
|
-
it { expect(Doorkeeper.config.base_metal_controller).to eq("ActionController::API") }
|
540
|
-
end
|
541
|
-
|
542
|
-
context "when custom value set" do
|
543
|
-
before do
|
544
|
-
Doorkeeper.configure do
|
545
|
-
orm DOORKEEPER_ORM
|
546
|
-
base_metal_controller { "ApplicationController" }
|
547
|
-
end
|
548
|
-
end
|
549
|
-
|
550
|
-
it { expect(Doorkeeper.configuration.resolve_controller(:base_metal)).to eq(ApplicationController) }
|
551
|
-
end
|
552
|
-
end
|
553
|
-
|
554
|
-
if DOORKEEPER_ORM == :active_record
|
555
|
-
class FakeCustomModel; end
|
556
|
-
|
557
|
-
describe "active_record_options" do
|
558
|
-
let(:models) { [Doorkeeper::AccessGrant, Doorkeeper::AccessToken, Doorkeeper::Application] }
|
559
|
-
|
560
|
-
before do
|
561
|
-
models.each do |model|
|
562
|
-
allow(model).to receive(:establish_connection).and_return(true)
|
563
|
-
end
|
564
|
-
end
|
565
|
-
|
566
|
-
it "establishes connection for Doorkeeper models based on options" do
|
567
|
-
expect(models).to all(receive(:establish_connection))
|
568
|
-
|
569
|
-
expect(Kernel).to receive(:warn).with(
|
570
|
-
/\[DOORKEEPER\] active_record_options has been deprecated and will soon be removed/,
|
571
|
-
)
|
572
|
-
|
573
|
-
Doorkeeper.configure do
|
574
|
-
orm DOORKEEPER_ORM
|
575
|
-
active_record_options(
|
576
|
-
establish_connection: Rails.configuration.database_configuration[Rails.env],
|
577
|
-
)
|
578
|
-
end
|
579
|
-
end
|
580
|
-
end
|
581
|
-
|
582
|
-
describe "access_token_class" do
|
583
|
-
it "uses default doorkeeper value" do
|
584
|
-
expect(subject.access_token_class).to eq("Doorkeeper::AccessToken")
|
585
|
-
expect(subject.access_token_model).to be(Doorkeeper::AccessToken)
|
586
|
-
end
|
587
|
-
|
588
|
-
it "can change the value" do
|
589
|
-
Doorkeeper.configure do
|
590
|
-
orm DOORKEEPER_ORM
|
591
|
-
access_token_class "FakeCustomModel"
|
592
|
-
end
|
593
|
-
|
594
|
-
expect(subject.access_token_class).to eq("FakeCustomModel")
|
595
|
-
expect(subject.access_token_model).to be(FakeCustomModel)
|
596
|
-
end
|
597
|
-
end
|
598
|
-
|
599
|
-
describe "access_grant_class" do
|
600
|
-
it "uses default doorkeeper value" do
|
601
|
-
expect(subject.access_grant_class).to eq("Doorkeeper::AccessGrant")
|
602
|
-
expect(subject.access_grant_model).to be(Doorkeeper::AccessGrant)
|
603
|
-
end
|
604
|
-
|
605
|
-
it "can change the value" do
|
606
|
-
Doorkeeper.configure do
|
607
|
-
orm DOORKEEPER_ORM
|
608
|
-
access_grant_class "FakeCustomModel"
|
609
|
-
end
|
610
|
-
|
611
|
-
expect(subject.access_grant_class).to eq("FakeCustomModel")
|
612
|
-
expect(subject.access_grant_model).to be(FakeCustomModel)
|
613
|
-
end
|
614
|
-
end
|
615
|
-
|
616
|
-
describe "application_class" do
|
617
|
-
it "uses default doorkeeper value" do
|
618
|
-
expect(subject.application_class).to eq("Doorkeeper::Application")
|
619
|
-
expect(subject.application_model).to be(Doorkeeper::Application)
|
620
|
-
end
|
621
|
-
|
622
|
-
it "can change the value" do
|
623
|
-
Doorkeeper.configure do
|
624
|
-
orm DOORKEEPER_ORM
|
625
|
-
application_class "FakeCustomModel"
|
626
|
-
end
|
627
|
-
|
628
|
-
expect(subject.application_class).to eq("FakeCustomModel")
|
629
|
-
expect(subject.application_model).to be(FakeCustomModel)
|
630
|
-
end
|
631
|
-
end
|
632
|
-
end
|
633
|
-
|
634
|
-
describe "api_only" do
|
635
|
-
it "is false by default" do
|
636
|
-
expect(subject.api_only).to eq(false)
|
637
|
-
end
|
638
|
-
|
639
|
-
it "can change the value" do
|
640
|
-
Doorkeeper.configure do
|
641
|
-
orm DOORKEEPER_ORM
|
642
|
-
api_only
|
643
|
-
end
|
644
|
-
|
645
|
-
expect(subject.api_only).to eq(true)
|
646
|
-
end
|
647
|
-
end
|
648
|
-
|
649
|
-
describe "token_lookup_batch_size" do
|
650
|
-
it "uses default doorkeeper value" do
|
651
|
-
expect(subject.token_lookup_batch_size).to eq(10_000)
|
652
|
-
end
|
653
|
-
|
654
|
-
it "can change the value" do
|
655
|
-
Doorkeeper.configure do
|
656
|
-
orm DOORKEEPER_ORM
|
657
|
-
token_lookup_batch_size 100_000
|
658
|
-
end
|
659
|
-
|
660
|
-
expect(subject.token_lookup_batch_size).to eq(100_000)
|
661
|
-
end
|
662
|
-
end
|
663
|
-
|
664
|
-
describe "strict_content_type" do
|
665
|
-
it "is false by default" do
|
666
|
-
expect(subject.enforce_content_type).to eq(false)
|
667
|
-
end
|
668
|
-
|
669
|
-
it "can change the value" do
|
670
|
-
Doorkeeper.configure do
|
671
|
-
orm DOORKEEPER_ORM
|
672
|
-
enforce_content_type
|
673
|
-
end
|
674
|
-
|
675
|
-
expect(subject.enforce_content_type).to eq(true)
|
676
|
-
end
|
677
|
-
end
|
678
|
-
|
679
|
-
describe "handle_auth_errors" do
|
680
|
-
it "is set to render by default" do
|
681
|
-
expect(Doorkeeper.config.handle_auth_errors).to eq(:render)
|
682
|
-
end
|
683
|
-
|
684
|
-
it "can change the value" do
|
685
|
-
Doorkeeper.configure do
|
686
|
-
orm DOORKEEPER_ORM
|
687
|
-
handle_auth_errors :raise
|
688
|
-
end
|
689
|
-
expect(subject.handle_auth_errors).to eq(:raise)
|
690
|
-
end
|
691
|
-
end
|
692
|
-
|
693
|
-
describe "token_secret_strategy" do
|
694
|
-
it "is plain by default" do
|
695
|
-
expect(subject.token_secret_strategy).to eq(Doorkeeper::SecretStoring::Plain)
|
696
|
-
expect(subject.token_secret_fallback_strategy).to eq(nil)
|
697
|
-
end
|
698
|
-
|
699
|
-
context "when provided" do
|
700
|
-
before do
|
701
|
-
Doorkeeper.configure do
|
702
|
-
orm DOORKEEPER_ORM
|
703
|
-
hash_token_secrets
|
704
|
-
end
|
705
|
-
end
|
706
|
-
|
707
|
-
it "will enable hashing for applications" do
|
708
|
-
expect(subject.token_secret_strategy).to eq(Doorkeeper::SecretStoring::Sha256Hash)
|
709
|
-
expect(subject.token_secret_fallback_strategy).to eq(nil)
|
710
|
-
end
|
711
|
-
end
|
712
|
-
|
713
|
-
context "when manually provided with invalid constant" do
|
714
|
-
it "raises an exception" do
|
715
|
-
expect do
|
716
|
-
Doorkeeper.configure do
|
717
|
-
orm DOORKEEPER_ORM
|
718
|
-
hash_token_secrets using: "does not exist"
|
719
|
-
end
|
720
|
-
end.to raise_error(NameError)
|
721
|
-
end
|
722
|
-
end
|
723
|
-
|
724
|
-
context "when manually provided with invalid option" do
|
725
|
-
it "raises an exception" do
|
726
|
-
expect do
|
727
|
-
Doorkeeper.configure do
|
728
|
-
orm DOORKEEPER_ORM
|
729
|
-
hash_token_secrets using: "Doorkeeper::SecretStoring::BCrypt"
|
730
|
-
end
|
731
|
-
end.to raise_error(
|
732
|
-
ArgumentError,
|
733
|
-
/can only be used for storing application secrets/,
|
734
|
-
)
|
735
|
-
end
|
736
|
-
end
|
737
|
-
|
738
|
-
context "when provided with fallback" do
|
739
|
-
before do
|
740
|
-
Doorkeeper.configure do
|
741
|
-
orm DOORKEEPER_ORM
|
742
|
-
hash_token_secrets fallback: :plain
|
743
|
-
end
|
744
|
-
end
|
745
|
-
|
746
|
-
it "will enable hashing for applications" do
|
747
|
-
expect(subject.token_secret_strategy).to eq(Doorkeeper::SecretStoring::Sha256Hash)
|
748
|
-
expect(subject.token_secret_fallback_strategy).to eq(Doorkeeper::SecretStoring::Plain)
|
749
|
-
end
|
750
|
-
end
|
751
|
-
|
752
|
-
describe "hash_token_secrets together with reuse_access_token" do
|
753
|
-
it "will disable reuse_access_token" do
|
754
|
-
expect(Rails.logger).to receive(:warn).with(/reuse_access_token will be disabled/)
|
755
|
-
|
756
|
-
Doorkeeper.configure do
|
757
|
-
orm DOORKEEPER_ORM
|
758
|
-
reuse_access_token
|
759
|
-
hash_token_secrets
|
760
|
-
end
|
761
|
-
|
762
|
-
expect(subject.reuse_access_token).to eq(false)
|
763
|
-
end
|
764
|
-
end
|
765
|
-
end
|
766
|
-
|
767
|
-
describe "application_secret_strategy" do
|
768
|
-
it "is plain by default" do
|
769
|
-
expect(subject.application_secret_strategy).to eq(Doorkeeper::SecretStoring::Plain)
|
770
|
-
expect(subject.application_secret_fallback_strategy).to eq(nil)
|
771
|
-
end
|
772
|
-
|
773
|
-
context "when provided" do
|
774
|
-
before do
|
775
|
-
Doorkeeper.configure do
|
776
|
-
orm DOORKEEPER_ORM
|
777
|
-
hash_application_secrets
|
778
|
-
end
|
779
|
-
end
|
780
|
-
|
781
|
-
it "will enable hashing for applications" do
|
782
|
-
expect(subject.application_secret_strategy).to eq(Doorkeeper::SecretStoring::Sha256Hash)
|
783
|
-
expect(subject.application_secret_fallback_strategy).to eq(nil)
|
784
|
-
end
|
785
|
-
end
|
786
|
-
|
787
|
-
context "when manually provided with invalid constant" do
|
788
|
-
it "raises an exception" do
|
789
|
-
expect do
|
790
|
-
Doorkeeper.configure do
|
791
|
-
orm DOORKEEPER_ORM
|
792
|
-
hash_application_secrets using: "does not exist"
|
793
|
-
end
|
794
|
-
end.to raise_error(NameError)
|
795
|
-
end
|
796
|
-
end
|
797
|
-
|
798
|
-
context "when provided with fallback" do
|
799
|
-
before do
|
800
|
-
Doorkeeper.configure do
|
801
|
-
orm DOORKEEPER_ORM
|
802
|
-
hash_application_secrets fallback: :plain
|
803
|
-
end
|
804
|
-
end
|
805
|
-
|
806
|
-
it "will enable hashing for applications" do
|
807
|
-
expect(subject.application_secret_strategy).to eq(Doorkeeper::SecretStoring::Sha256Hash)
|
808
|
-
expect(subject.application_secret_fallback_strategy).to eq(Doorkeeper::SecretStoring::Plain)
|
809
|
-
end
|
810
|
-
end
|
811
|
-
end
|
812
|
-
|
813
|
-
describe "options deprecation" do
|
814
|
-
it "prints a warning message when an option is deprecated" do
|
815
|
-
expect(Kernel).to receive(:warn).with(
|
816
|
-
"[DOORKEEPER] native_redirect_uri has been deprecated and will soon be removed",
|
817
|
-
)
|
818
|
-
Doorkeeper.configure do
|
819
|
-
orm DOORKEEPER_ORM
|
820
|
-
native_redirect_uri "urn:ietf:wg:oauth:2.0:oob"
|
821
|
-
end
|
822
|
-
end
|
823
|
-
end
|
824
|
-
end
|