doorkeeper 5.0.0 → 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.
- checksums.yaml +5 -5
- data/.hound.yml +2 -1
- data/.rubocop.yml +37 -4
- data/.travis.yml +16 -21
- data/Appraisals +29 -7
- data/Dangerfile +67 -0
- data/Gemfile +19 -5
- data/NEWS.md +107 -10
- data/README.md +75 -470
- data/Rakefile +10 -8
- data/app/controllers/doorkeeper/application_controller.rb +3 -2
- data/app/controllers/doorkeeper/application_metal_controller.rb +4 -13
- data/app/controllers/doorkeeper/applications_controller.rb +21 -7
- data/app/controllers/doorkeeper/authorizations_controller.rb +3 -3
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +2 -0
- data/app/controllers/doorkeeper/token_info_controller.rb +4 -2
- data/app/controllers/doorkeeper/tokens_controller.rb +13 -11
- data/app/helpers/doorkeeper/dashboard_helper.rb +3 -1
- data/app/validators/redirect_uri_validator.rb +7 -2
- data/app/views/doorkeeper/applications/_form.html.erb +6 -0
- data/app/views/doorkeeper/applications/show.html.erb +1 -1
- data/app/views/layouts/doorkeeper/admin.html.erb +5 -3
- data/bin/console +16 -0
- data/config/locales/en.yml +1 -0
- data/doorkeeper.gemspec +28 -24
- data/gemfiles/rails_5_0.gemfile +9 -4
- data/gemfiles/rails_5_1.gemfile +9 -4
- data/gemfiles/rails_5_2.gemfile +10 -5
- data/gemfiles/rails_6_0.gemfile +17 -0
- data/gemfiles/rails_master.gemfile +9 -9
- data/lib/doorkeeper/config/option.rb +64 -0
- data/lib/doorkeeper/config.rb +197 -76
- data/lib/doorkeeper/engine.rb +3 -1
- data/lib/doorkeeper/errors.rb +17 -0
- data/lib/doorkeeper/grape/authorization_decorator.rb +6 -4
- data/lib/doorkeeper/grape/helpers.rb +5 -3
- data/lib/doorkeeper/helpers/controller.rb +5 -2
- data/lib/doorkeeper/models/access_grant_mixin.rb +25 -6
- data/lib/doorkeeper/models/access_token_mixin.rb +68 -22
- data/lib/doorkeeper/models/application_mixin.rb +45 -1
- data/lib/doorkeeper/models/concerns/accessible.rb +2 -0
- data/lib/doorkeeper/models/concerns/expirable.rb +6 -2
- data/lib/doorkeeper/models/concerns/orderable.rb +2 -0
- data/lib/doorkeeper/models/concerns/ownership.rb +3 -6
- data/lib/doorkeeper/models/concerns/reusable.rb +19 -0
- data/lib/doorkeeper/models/concerns/revocable.rb +4 -1
- data/lib/doorkeeper/models/concerns/scopes.rb +7 -1
- data/lib/doorkeeper/models/concerns/secret_storable.rb +108 -0
- data/lib/doorkeeper/oauth/authorization/code.rb +4 -2
- data/lib/doorkeeper/oauth/authorization/context.rb +2 -0
- data/lib/doorkeeper/oauth/authorization/token.rb +14 -7
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +3 -1
- data/lib/doorkeeper/oauth/authorization_code_request.rb +8 -4
- data/lib/doorkeeper/oauth/base_request.rb +2 -0
- data/lib/doorkeeper/oauth/base_response.rb +2 -0
- data/lib/doorkeeper/oauth/client/credentials.rb +2 -0
- data/lib/doorkeeper/oauth/client.rb +3 -1
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +2 -0
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +2 -0
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +7 -4
- data/lib/doorkeeper/oauth/client_credentials_request.rb +3 -1
- data/lib/doorkeeper/oauth/code_request.rb +2 -0
- data/lib/doorkeeper/oauth/code_response.rb +4 -2
- data/lib/doorkeeper/oauth/error.rb +2 -0
- data/lib/doorkeeper/oauth/error_response.rb +20 -6
- data/lib/doorkeeper/oauth/forbidden_token_response.rb +10 -3
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +25 -8
- data/lib/doorkeeper/oauth/helpers/unique_token.rb +15 -1
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +42 -3
- data/lib/doorkeeper/oauth/invalid_token_response.rb +22 -0
- data/lib/doorkeeper/oauth/password_access_token_request.rb +9 -2
- data/lib/doorkeeper/oauth/pre_authorization.rb +13 -5
- data/lib/doorkeeper/oauth/refresh_token_request.rb +15 -4
- data/lib/doorkeeper/oauth/scopes.rb +7 -3
- data/lib/doorkeeper/oauth/token.rb +4 -2
- data/lib/doorkeeper/oauth/token_introspection.rb +76 -8
- data/lib/doorkeeper/oauth/token_request.rb +2 -0
- data/lib/doorkeeper/oauth/token_response.rb +11 -9
- data/lib/doorkeeper/oauth.rb +5 -5
- data/lib/doorkeeper/orm/active_record/access_grant.rb +27 -13
- data/lib/doorkeeper/orm/active_record/access_token.rb +6 -13
- data/lib/doorkeeper/orm/active_record/application.rb +26 -7
- data/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb +10 -3
- data/lib/doorkeeper/orm/active_record.rb +8 -6
- data/lib/doorkeeper/rails/helpers.rb +5 -1
- data/lib/doorkeeper/rails/routes/mapper.rb +2 -0
- data/lib/doorkeeper/rails/routes/mapping.rb +9 -7
- data/lib/doorkeeper/rails/routes.rb +19 -12
- data/lib/doorkeeper/rake/db.rake +17 -17
- data/lib/doorkeeper/rake.rb +1 -1
- data/lib/doorkeeper/request/authorization_code.rb +2 -0
- data/lib/doorkeeper/request/client_credentials.rb +2 -0
- data/lib/doorkeeper/request/code.rb +2 -0
- data/lib/doorkeeper/request/password.rb +2 -0
- data/lib/doorkeeper/request/refresh_token.rb +2 -0
- data/lib/doorkeeper/request/strategy.rb +2 -0
- data/lib/doorkeeper/request/token.rb +2 -0
- data/lib/doorkeeper/request.rb +3 -1
- data/lib/doorkeeper/secret_storing/base.rb +64 -0
- data/lib/doorkeeper/secret_storing/bcrypt.rb +60 -0
- data/lib/doorkeeper/secret_storing/plain.rb +33 -0
- data/lib/doorkeeper/secret_storing/sha256_hash.rb +26 -0
- data/lib/doorkeeper/server.rb +2 -0
- data/lib/doorkeeper/stale_records_cleaner.rb +20 -0
- data/lib/doorkeeper/validations.rb +2 -0
- data/lib/doorkeeper/version.rb +4 -2
- data/lib/doorkeeper.rb +69 -59
- data/lib/generators/doorkeeper/application_owner_generator.rb +10 -9
- data/lib/generators/doorkeeper/confidential_applications_generator.rb +10 -9
- data/lib/generators/doorkeeper/install_generator.rb +11 -9
- data/lib/generators/doorkeeper/migration_generator.rb +9 -9
- data/lib/generators/doorkeeper/pkce_generator.rb +10 -9
- data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +10 -9
- data/lib/generators/doorkeeper/templates/initializer.rb +138 -13
- data/lib/generators/doorkeeper/templates/migration.rb.erb +17 -10
- data/lib/generators/doorkeeper/views_generator.rb +6 -4
- data/spec/controllers/application_metal_controller_spec.rb +24 -10
- data/spec/controllers/applications_controller_spec.rb +76 -78
- data/spec/controllers/authorizations_controller_spec.rb +189 -142
- data/spec/controllers/protected_resources_controller_spec.rb +111 -67
- data/spec/controllers/token_info_controller_spec.rb +14 -12
- data/spec/controllers/tokens_controller_spec.rb +170 -112
- data/spec/dummy/Rakefile +3 -1
- data/spec/dummy/app/controllers/application_controller.rb +3 -1
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +3 -1
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +4 -2
- data/spec/dummy/app/controllers/home_controller.rb +6 -5
- data/spec/dummy/app/controllers/metal_controller.rb +2 -0
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +4 -2
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/config/application.rb +26 -2
- data/spec/dummy/config/boot.rb +2 -4
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/development.rb +2 -0
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/environments/test.rb +4 -2
- data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/spec/dummy/config/initializers/doorkeeper.rb +7 -3
- data/spec/dummy/config/initializers/secret_token.rb +3 -1
- data/spec/dummy/config/initializers/session_store.rb +3 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/spec/dummy/config.ru +3 -1
- data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +20 -13
- data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +1 -1
- data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +2 -0
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/dummy/script/rails +7 -4
- data/spec/factories.rb +11 -9
- data/spec/generators/application_owner_generator_spec.rb +13 -26
- data/spec/generators/confidential_applications_generator_spec.rb +12 -28
- data/spec/generators/install_generator_spec.rb +19 -14
- data/spec/generators/migration_generator_spec.rb +13 -26
- data/spec/generators/pkce_generator_spec.rb +11 -26
- data/spec/generators/previous_refresh_token_generator_spec.rb +16 -29
- data/spec/generators/templates/routes.rb +2 -1
- data/spec/generators/views_generator_spec.rb +14 -12
- data/spec/grape/grape_integration_spec.rb +35 -33
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +9 -7
- data/spec/lib/config_spec.rb +290 -104
- data/spec/lib/doorkeeper_spec.rb +8 -6
- data/spec/lib/models/expirable_spec.rb +22 -8
- data/spec/lib/models/reusable_spec.rb +40 -0
- data/spec/lib/models/revocable_spec.rb +8 -6
- data/spec/lib/models/scopes_spec.rb +27 -13
- data/spec/lib/models/secret_storable_spec.rb +135 -0
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +17 -15
- data/spec/lib/oauth/authorization_code_request_spec.rb +43 -17
- data/spec/lib/oauth/base_request_spec.rb +24 -12
- data/spec/lib/oauth/base_response_spec.rb +3 -1
- data/spec/lib/oauth/client/credentials_spec.rb +26 -24
- data/spec/lib/oauth/client_credentials/creator_spec.rb +56 -10
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +27 -20
- data/spec/lib/oauth/client_credentials/validation_spec.rb +21 -15
- data/spec/lib/oauth/client_credentials_integration_spec.rb +8 -6
- data/spec/lib/oauth/client_credentials_request_spec.rb +27 -21
- data/spec/lib/oauth/client_spec.rb +15 -13
- data/spec/lib/oauth/code_request_spec.rb +10 -8
- data/spec/lib/oauth/code_response_spec.rb +9 -7
- data/spec/lib/oauth/error_response_spec.rb +19 -11
- data/spec/lib/oauth/error_spec.rb +4 -2
- data/spec/lib/oauth/forbidden_token_response_spec.rb +7 -5
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +68 -31
- data/spec/lib/oauth/helpers/unique_token_spec.rb +8 -6
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +124 -93
- data/spec/lib/oauth/invalid_token_response_spec.rb +3 -1
- data/spec/lib/oauth/password_access_token_request_spec.rb +95 -34
- data/spec/lib/oauth/pre_authorization_spec.rb +80 -54
- data/spec/lib/oauth/refresh_token_request_spec.rb +46 -39
- data/spec/lib/oauth/scopes_spec.rb +63 -61
- data/spec/lib/oauth/token_request_spec.rb +80 -25
- data/spec/lib/oauth/token_response_spec.rb +40 -38
- data/spec/lib/oauth/token_spec.rb +64 -45
- data/spec/lib/request/strategy_spec.rb +3 -1
- data/spec/lib/secret_storing/base_spec.rb +60 -0
- data/spec/lib/secret_storing/bcrypt_spec.rb +49 -0
- data/spec/lib/secret_storing/plain_spec.rb +44 -0
- data/spec/lib/secret_storing/sha256_hash_spec.rb +48 -0
- data/spec/lib/server_spec.rb +20 -18
- data/spec/lib/{orm/active_record/stale_records_cleaner_spec.rb → stale_records_cleaner_spec.rb} +28 -18
- data/spec/models/doorkeeper/access_grant_spec.rb +80 -15
- data/spec/models/doorkeeper/access_token_spec.rb +212 -83
- data/spec/models/doorkeeper/application_spec.rb +146 -49
- data/spec/requests/applications/applications_request_spec.rb +100 -68
- data/spec/requests/applications/authorized_applications_spec.rb +20 -18
- data/spec/requests/endpoints/authorization_spec.rb +27 -25
- data/spec/requests/endpoints/token_spec.rb +38 -36
- data/spec/requests/flows/authorization_code_errors_spec.rb +27 -25
- data/spec/requests/flows/authorization_code_spec.rb +260 -158
- data/spec/requests/flows/client_credentials_spec.rb +54 -52
- data/spec/requests/flows/implicit_grant_errors_spec.rb +11 -9
- data/spec/requests/flows/implicit_grant_spec.rb +27 -25
- data/spec/requests/flows/password_spec.rb +64 -56
- data/spec/requests/flows/refresh_token_spec.rb +91 -32
- data/spec/requests/flows/revoke_token_spec.rb +49 -63
- data/spec/requests/flows/skip_authorization_spec.rb +23 -21
- data/spec/requests/protected_resources/metal_spec.rb +7 -5
- data/spec/requests/protected_resources/private_api_spec.rb +37 -35
- data/spec/routing/custom_controller_routes_spec.rb +71 -65
- data/spec/routing/default_routes_spec.rb +22 -20
- data/spec/routing/scoped_routes_spec.rb +20 -18
- data/spec/spec_helper.rb +15 -13
- data/spec/spec_helper_integration.rb +3 -1
- data/spec/support/dependencies/factory_bot.rb +3 -1
- data/spec/support/doorkeeper_rspec.rb +5 -2
- data/spec/support/helpers/access_token_request_helper.rb +3 -1
- data/spec/support/helpers/authorization_request_helper.rb +4 -2
- data/spec/support/helpers/config_helper.rb +2 -0
- data/spec/support/helpers/model_helper.rb +11 -5
- data/spec/support/helpers/request_spec_helper.rb +5 -3
- data/spec/support/helpers/url_helper.rb +20 -18
- data/spec/support/http_method_shim.rb +4 -9
- data/spec/support/orm/active_record.rb +3 -1
- data/spec/support/shared/controllers_shared_context.rb +68 -10
- data/spec/support/shared/hashing_shared_context.rb +36 -0
- data/spec/support/shared/models_shared_examples.rb +12 -10
- data/spec/validators/redirect_uri_validator_spec.rb +76 -47
- data/spec/version/version_spec.rb +7 -5
- metadata +70 -21
- data/gemfiles/rails_4_2.gemfile +0 -13
- data/spec/dummy/config/initializers/new_framework_defaults.rb +0 -10
data/spec/lib/config_spec.rb
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require "spec_helper"
|
|
4
|
+
|
|
5
|
+
describe Doorkeeper, "configuration" do
|
|
4
6
|
subject { Doorkeeper.configuration }
|
|
5
7
|
|
|
6
|
-
describe
|
|
7
|
-
it
|
|
8
|
+
describe "resource_owner_authenticator" do
|
|
9
|
+
it "sets the block that is accessible via authenticate_resource_owner" do
|
|
8
10
|
block = proc {}
|
|
9
11
|
Doorkeeper.configure do
|
|
10
12
|
orm DOORKEEPER_ORM
|
|
@@ -14,20 +16,20 @@ describe Doorkeeper, 'configuration' do
|
|
|
14
16
|
expect(subject.authenticate_resource_owner).to eq(block)
|
|
15
17
|
end
|
|
16
18
|
|
|
17
|
-
it
|
|
19
|
+
it "prints warning message by default" do
|
|
18
20
|
Doorkeeper.configure do
|
|
19
21
|
orm DOORKEEPER_ORM
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
expect(Rails.logger).to receive(:warn).with(
|
|
23
|
-
I18n.t(
|
|
25
|
+
I18n.t("doorkeeper.errors.messages.resource_owner_authenticator_not_configured")
|
|
24
26
|
)
|
|
25
27
|
subject.authenticate_resource_owner.call(nil)
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
|
|
29
|
-
describe
|
|
30
|
-
it
|
|
31
|
+
describe "resource_owner_from_credentials" do
|
|
32
|
+
it "sets the block that is accessible via authenticate_resource_owner" do
|
|
31
33
|
block = proc {}
|
|
32
34
|
Doorkeeper.configure do
|
|
33
35
|
orm DOORKEEPER_ORM
|
|
@@ -37,37 +39,37 @@ describe Doorkeeper, 'configuration' do
|
|
|
37
39
|
expect(subject.resource_owner_from_credentials).to eq(block)
|
|
38
40
|
end
|
|
39
41
|
|
|
40
|
-
it
|
|
42
|
+
it "prints warning message by default" do
|
|
41
43
|
Doorkeeper.configure do
|
|
42
44
|
orm DOORKEEPER_ORM
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
expect(Rails.logger).to receive(:warn).with(
|
|
46
|
-
I18n.t(
|
|
48
|
+
I18n.t("doorkeeper.errors.messages.credential_flow_not_configured")
|
|
47
49
|
)
|
|
48
50
|
subject.resource_owner_from_credentials.call(nil)
|
|
49
51
|
end
|
|
50
52
|
end
|
|
51
53
|
|
|
52
|
-
describe
|
|
53
|
-
it
|
|
54
|
+
describe "setup_orm_adapter" do
|
|
55
|
+
it "adds specific error message to NameError exception" do
|
|
54
56
|
expect do
|
|
55
|
-
Doorkeeper.configure { orm
|
|
57
|
+
Doorkeeper.configure { orm "hibernate" }
|
|
56
58
|
end.to raise_error(NameError, /ORM adapter not found \(hibernate\)/)
|
|
57
59
|
end
|
|
58
60
|
|
|
59
|
-
it
|
|
60
|
-
|
|
61
|
+
it "does not change other exceptions" do
|
|
62
|
+
allow(Doorkeeper).to receive(:setup_orm_adapter) { raise NoMethodError }
|
|
61
63
|
|
|
62
64
|
expect do
|
|
63
|
-
Doorkeeper.configure { orm
|
|
64
|
-
end.to raise_error(NoMethodError
|
|
65
|
+
Doorkeeper.configure { orm "hibernate" }
|
|
66
|
+
end.to raise_error(NoMethodError)
|
|
65
67
|
end
|
|
66
68
|
end
|
|
67
69
|
|
|
68
|
-
describe
|
|
69
|
-
it
|
|
70
|
-
default_behaviour =
|
|
70
|
+
describe "admin_authenticator" do
|
|
71
|
+
it "sets the block that is accessible via authenticate_admin" do
|
|
72
|
+
default_behaviour = "default behaviour"
|
|
71
73
|
allow(Doorkeeper::Config).to receive(:head).and_return(default_behaviour)
|
|
72
74
|
|
|
73
75
|
Doorkeeper.configure do
|
|
@@ -77,7 +79,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
77
79
|
expect(subject.authenticate_admin.call({})).to eq(default_behaviour)
|
|
78
80
|
end
|
|
79
81
|
|
|
80
|
-
it
|
|
82
|
+
it "sets the block that is accessible via authenticate_admin" do
|
|
81
83
|
block = proc {}
|
|
82
84
|
Doorkeeper.configure do
|
|
83
85
|
orm DOORKEEPER_ORM
|
|
@@ -88,12 +90,12 @@ describe Doorkeeper, 'configuration' do
|
|
|
88
90
|
end
|
|
89
91
|
end
|
|
90
92
|
|
|
91
|
-
describe
|
|
92
|
-
it
|
|
93
|
+
describe "access_token_expires_in" do
|
|
94
|
+
it "has 2 hours by default" do
|
|
93
95
|
expect(subject.access_token_expires_in).to eq(2.hours)
|
|
94
96
|
end
|
|
95
97
|
|
|
96
|
-
it
|
|
98
|
+
it "can change the value" do
|
|
97
99
|
Doorkeeper.configure do
|
|
98
100
|
orm DOORKEEPER_ORM
|
|
99
101
|
access_token_expires_in 4.hours
|
|
@@ -101,7 +103,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
101
103
|
expect(subject.access_token_expires_in).to eq(4.hours)
|
|
102
104
|
end
|
|
103
105
|
|
|
104
|
-
it
|
|
106
|
+
it "can be set to nil" do
|
|
105
107
|
Doorkeeper.configure do
|
|
106
108
|
orm DOORKEEPER_ORM
|
|
107
109
|
access_token_expires_in nil
|
|
@@ -111,42 +113,58 @@ describe Doorkeeper, 'configuration' do
|
|
|
111
113
|
end
|
|
112
114
|
end
|
|
113
115
|
|
|
114
|
-
describe
|
|
115
|
-
it
|
|
116
|
+
describe "scopes" do
|
|
117
|
+
it "has default scopes" do
|
|
116
118
|
Doorkeeper.configure do
|
|
117
119
|
orm DOORKEEPER_ORM
|
|
118
120
|
default_scopes :public
|
|
119
121
|
end
|
|
120
122
|
|
|
121
|
-
expect(subject.default_scopes).to include(
|
|
123
|
+
expect(subject.default_scopes).to include("public")
|
|
122
124
|
end
|
|
123
125
|
|
|
124
|
-
it
|
|
126
|
+
it "has optional scopes" do
|
|
125
127
|
Doorkeeper.configure do
|
|
126
128
|
orm DOORKEEPER_ORM
|
|
127
129
|
optional_scopes :write, :update
|
|
128
130
|
end
|
|
129
131
|
|
|
130
|
-
expect(subject.optional_scopes).to include(
|
|
132
|
+
expect(subject.optional_scopes).to include("write", "update")
|
|
131
133
|
end
|
|
132
134
|
|
|
133
|
-
it
|
|
135
|
+
it "has all scopes" do
|
|
134
136
|
Doorkeeper.configure do
|
|
135
137
|
orm DOORKEEPER_ORM
|
|
136
138
|
default_scopes :normal
|
|
137
139
|
optional_scopes :admin
|
|
138
140
|
end
|
|
139
141
|
|
|
140
|
-
expect(subject.scopes).to include(
|
|
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)
|
|
141
159
|
end
|
|
142
160
|
end
|
|
143
161
|
|
|
144
|
-
describe
|
|
145
|
-
it
|
|
162
|
+
describe "use_refresh_token" do
|
|
163
|
+
it "is false by default" do
|
|
146
164
|
expect(subject.refresh_token_enabled?).to eq(false)
|
|
147
165
|
end
|
|
148
166
|
|
|
149
|
-
it
|
|
167
|
+
it "can change the value" do
|
|
150
168
|
Doorkeeper.configure do
|
|
151
169
|
orm DOORKEEPER_ORM
|
|
152
170
|
use_refresh_token
|
|
@@ -155,7 +173,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
155
173
|
expect(subject.refresh_token_enabled?).to eq(true)
|
|
156
174
|
end
|
|
157
175
|
|
|
158
|
-
it
|
|
176
|
+
it "can accept a boolean parameter" do
|
|
159
177
|
Doorkeeper.configure do
|
|
160
178
|
orm DOORKEEPER_ORM
|
|
161
179
|
use_refresh_token false
|
|
@@ -164,7 +182,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
164
182
|
expect(subject.refresh_token_enabled?).to eq(false)
|
|
165
183
|
end
|
|
166
184
|
|
|
167
|
-
it
|
|
185
|
+
it "can accept a block parameter" do
|
|
168
186
|
Doorkeeper.configure do
|
|
169
187
|
orm DOORKEEPER_ORM
|
|
170
188
|
use_refresh_token { |_context| nil }
|
|
@@ -174,29 +192,54 @@ describe Doorkeeper, 'configuration' do
|
|
|
174
192
|
end
|
|
175
193
|
|
|
176
194
|
it "does not includes 'refresh_token' in authorization_response_types" do
|
|
177
|
-
expect(subject.token_grant_types).not_to include
|
|
195
|
+
expect(subject.token_grant_types).not_to include "refresh_token"
|
|
178
196
|
end
|
|
179
197
|
|
|
180
198
|
context "is enabled" do
|
|
181
199
|
before do
|
|
182
|
-
Doorkeeper.configure
|
|
200
|
+
Doorkeeper.configure do
|
|
183
201
|
orm DOORKEEPER_ORM
|
|
184
202
|
use_refresh_token
|
|
185
|
-
|
|
203
|
+
end
|
|
186
204
|
end
|
|
187
205
|
|
|
188
206
|
it "includes 'refresh_token' in authorization_response_types" do
|
|
189
|
-
expect(subject.token_grant_types).to include
|
|
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
|
+
token_reuse_limit 90
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
expect(subject.token_reuse_limit).to eq(90)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it "sets the value to 100 if invalid value is being set" do
|
|
226
|
+
expect(Rails.logger).to receive(:warn).with(/will be set to default 100/)
|
|
227
|
+
|
|
228
|
+
Doorkeeper.configure do
|
|
229
|
+
reuse_access_token
|
|
230
|
+
token_reuse_limit 110
|
|
190
231
|
end
|
|
232
|
+
|
|
233
|
+
expect(subject.token_reuse_limit).to eq(100)
|
|
191
234
|
end
|
|
192
235
|
end
|
|
193
236
|
|
|
194
|
-
describe
|
|
195
|
-
it
|
|
237
|
+
describe "enforce_configured_scopes" do
|
|
238
|
+
it "is false by default" do
|
|
196
239
|
expect(subject.enforce_configured_scopes?).to eq(false)
|
|
197
240
|
end
|
|
198
241
|
|
|
199
|
-
it
|
|
242
|
+
it "can change the value" do
|
|
200
243
|
Doorkeeper.configure do
|
|
201
244
|
orm DOORKEEPER_ORM
|
|
202
245
|
enforce_configured_scopes
|
|
@@ -206,27 +249,29 @@ describe Doorkeeper, 'configuration' do
|
|
|
206
249
|
end
|
|
207
250
|
end
|
|
208
251
|
|
|
209
|
-
describe
|
|
210
|
-
it
|
|
211
|
-
expect(subject.client_credentials_methods)
|
|
252
|
+
describe "client_credentials" do
|
|
253
|
+
it "has defaults order" do
|
|
254
|
+
expect(subject.client_credentials_methods)
|
|
255
|
+
.to eq(%i[from_basic from_params])
|
|
212
256
|
end
|
|
213
257
|
|
|
214
|
-
it
|
|
258
|
+
it "can change the value" do
|
|
215
259
|
Doorkeeper.configure do
|
|
216
260
|
orm DOORKEEPER_ORM
|
|
217
261
|
client_credentials :from_digest, :from_params
|
|
218
262
|
end
|
|
219
263
|
|
|
220
|
-
expect(subject.client_credentials_methods)
|
|
264
|
+
expect(subject.client_credentials_methods)
|
|
265
|
+
.to eq(%i[from_digest from_params])
|
|
221
266
|
end
|
|
222
267
|
end
|
|
223
268
|
|
|
224
|
-
describe
|
|
225
|
-
it
|
|
269
|
+
describe "force_ssl_in_redirect_uri" do
|
|
270
|
+
it "is true by default in non-development environments" do
|
|
226
271
|
expect(subject.force_ssl_in_redirect_uri).to eq(true)
|
|
227
272
|
end
|
|
228
273
|
|
|
229
|
-
it
|
|
274
|
+
it "can change the value" do
|
|
230
275
|
Doorkeeper.configure do
|
|
231
276
|
orm DOORKEEPER_ORM
|
|
232
277
|
force_ssl_in_redirect_uri(false)
|
|
@@ -235,7 +280,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
235
280
|
expect(subject.force_ssl_in_redirect_uri).to eq(false)
|
|
236
281
|
end
|
|
237
282
|
|
|
238
|
-
it
|
|
283
|
+
it "can be a callable object" do
|
|
239
284
|
block = proc { false }
|
|
240
285
|
Doorkeeper.configure do
|
|
241
286
|
orm DOORKEEPER_ORM
|
|
@@ -247,27 +292,29 @@ describe Doorkeeper, 'configuration' do
|
|
|
247
292
|
end
|
|
248
293
|
end
|
|
249
294
|
|
|
250
|
-
describe
|
|
251
|
-
it
|
|
252
|
-
expect(subject.access_token_methods)
|
|
295
|
+
describe "access_token_methods" do
|
|
296
|
+
it "has defaults order" do
|
|
297
|
+
expect(subject.access_token_methods)
|
|
298
|
+
.to eq(%i[from_bearer_authorization from_access_token_param from_bearer_param])
|
|
253
299
|
end
|
|
254
300
|
|
|
255
|
-
it
|
|
301
|
+
it "can change the value" do
|
|
256
302
|
Doorkeeper.configure do
|
|
257
303
|
orm DOORKEEPER_ORM
|
|
258
304
|
access_token_methods :from_access_token_param, :from_bearer_param
|
|
259
305
|
end
|
|
260
306
|
|
|
261
|
-
expect(subject.access_token_methods)
|
|
307
|
+
expect(subject.access_token_methods)
|
|
308
|
+
.to eq(%i[from_access_token_param from_bearer_param])
|
|
262
309
|
end
|
|
263
310
|
end
|
|
264
311
|
|
|
265
|
-
describe
|
|
266
|
-
it
|
|
267
|
-
expect(subject.forbid_redirect_uri.call(URI.parse(
|
|
312
|
+
describe "forbid_redirect_uri" do
|
|
313
|
+
it "is false by default" do
|
|
314
|
+
expect(subject.forbid_redirect_uri.call(URI.parse("https://localhost"))).to eq(false)
|
|
268
315
|
end
|
|
269
316
|
|
|
270
|
-
it
|
|
317
|
+
it "can be a callable object" do
|
|
271
318
|
block = proc { true }
|
|
272
319
|
Doorkeeper.configure do
|
|
273
320
|
orm DOORKEEPER_ORM
|
|
@@ -279,12 +326,12 @@ describe Doorkeeper, 'configuration' do
|
|
|
279
326
|
end
|
|
280
327
|
end
|
|
281
328
|
|
|
282
|
-
describe
|
|
283
|
-
it
|
|
329
|
+
describe "enable_application_owner" do
|
|
330
|
+
it "is disabled by default" do
|
|
284
331
|
expect(Doorkeeper.configuration.enable_application_owner?).not_to eq(true)
|
|
285
332
|
end
|
|
286
333
|
|
|
287
|
-
context
|
|
334
|
+
context "when enabled without confirmation" do
|
|
288
335
|
before do
|
|
289
336
|
Doorkeeper.configure do
|
|
290
337
|
orm DOORKEEPER_ORM
|
|
@@ -292,16 +339,16 @@ describe Doorkeeper, 'configuration' do
|
|
|
292
339
|
end
|
|
293
340
|
end
|
|
294
341
|
|
|
295
|
-
it
|
|
342
|
+
it "adds support for application owner" do
|
|
296
343
|
expect(Doorkeeper::Application.new).to respond_to :owner
|
|
297
344
|
end
|
|
298
345
|
|
|
299
|
-
it
|
|
346
|
+
it "Doorkeeper.configuration.confirm_application_owner? returns false" do
|
|
300
347
|
expect(Doorkeeper.configuration.confirm_application_owner?).not_to eq(true)
|
|
301
348
|
end
|
|
302
349
|
end
|
|
303
350
|
|
|
304
|
-
context
|
|
351
|
+
context "when enabled with confirmation set to true" do
|
|
305
352
|
before do
|
|
306
353
|
Doorkeeper.configure do
|
|
307
354
|
orm DOORKEEPER_ORM
|
|
@@ -309,35 +356,35 @@ describe Doorkeeper, 'configuration' do
|
|
|
309
356
|
end
|
|
310
357
|
end
|
|
311
358
|
|
|
312
|
-
it
|
|
359
|
+
it "adds support for application owner" do
|
|
313
360
|
expect(Doorkeeper::Application.new).to respond_to :owner
|
|
314
361
|
end
|
|
315
362
|
|
|
316
|
-
it
|
|
363
|
+
it "Doorkeeper.configuration.confirm_application_owner? returns true" do
|
|
317
364
|
expect(Doorkeeper.configuration.confirm_application_owner?).to eq(true)
|
|
318
365
|
end
|
|
319
366
|
end
|
|
320
367
|
end
|
|
321
368
|
|
|
322
|
-
describe
|
|
323
|
-
it
|
|
324
|
-
expect(Doorkeeper.configuration.realm).to eq(
|
|
369
|
+
describe "realm" do
|
|
370
|
+
it "is 'Doorkeeper' by default" do
|
|
371
|
+
expect(Doorkeeper.configuration.realm).to eq("Doorkeeper")
|
|
325
372
|
end
|
|
326
373
|
|
|
327
|
-
it
|
|
374
|
+
it "can change the value" do
|
|
328
375
|
Doorkeeper.configure do
|
|
329
376
|
orm DOORKEEPER_ORM
|
|
330
|
-
realm
|
|
377
|
+
realm "Example"
|
|
331
378
|
end
|
|
332
379
|
|
|
333
|
-
expect(subject.realm).to eq(
|
|
380
|
+
expect(subject.realm).to eq("Example")
|
|
334
381
|
end
|
|
335
382
|
end
|
|
336
383
|
|
|
337
384
|
describe "grant_flows" do
|
|
338
385
|
it "is set to all grant flows by default" do
|
|
339
|
-
expect(Doorkeeper.configuration.grant_flows)
|
|
340
|
-
to eq(%w[authorization_code client_credentials])
|
|
386
|
+
expect(Doorkeeper.configuration.grant_flows)
|
|
387
|
+
.to eq(%w[authorization_code client_credentials])
|
|
341
388
|
end
|
|
342
389
|
|
|
343
390
|
it "can change the value" do
|
|
@@ -353,16 +400,16 @@ describe Doorkeeper, 'configuration' do
|
|
|
353
400
|
before do
|
|
354
401
|
Doorkeeper.configure do
|
|
355
402
|
orm DOORKEEPER_ORM
|
|
356
|
-
grant_flows [
|
|
403
|
+
grant_flows ["authorization_code"]
|
|
357
404
|
end
|
|
358
405
|
end
|
|
359
406
|
|
|
360
407
|
it "includes 'code' in authorization_response_types" do
|
|
361
|
-
expect(subject.authorization_response_types).to include
|
|
408
|
+
expect(subject.authorization_response_types).to include "code"
|
|
362
409
|
end
|
|
363
410
|
|
|
364
411
|
it "includes 'authorization_code' in token_grant_types" do
|
|
365
|
-
expect(subject.token_grant_types).to include
|
|
412
|
+
expect(subject.token_grant_types).to include "authorization_code"
|
|
366
413
|
end
|
|
367
414
|
end
|
|
368
415
|
|
|
@@ -370,12 +417,12 @@ describe Doorkeeper, 'configuration' do
|
|
|
370
417
|
before do
|
|
371
418
|
Doorkeeper.configure do
|
|
372
419
|
orm DOORKEEPER_ORM
|
|
373
|
-
grant_flows [
|
|
420
|
+
grant_flows ["implicit"]
|
|
374
421
|
end
|
|
375
422
|
end
|
|
376
423
|
|
|
377
424
|
it "includes 'token' in authorization_response_types" do
|
|
378
|
-
expect(subject.authorization_response_types).to include
|
|
425
|
+
expect(subject.authorization_response_types).to include "token"
|
|
379
426
|
end
|
|
380
427
|
end
|
|
381
428
|
|
|
@@ -383,12 +430,12 @@ describe Doorkeeper, 'configuration' do
|
|
|
383
430
|
before do
|
|
384
431
|
Doorkeeper.configure do
|
|
385
432
|
orm DOORKEEPER_ORM
|
|
386
|
-
grant_flows [
|
|
433
|
+
grant_flows ["password"]
|
|
387
434
|
end
|
|
388
435
|
end
|
|
389
436
|
|
|
390
437
|
it "includes 'password' in token_grant_types" do
|
|
391
|
-
expect(subject.token_grant_types).to include
|
|
438
|
+
expect(subject.token_grant_types).to include "password"
|
|
392
439
|
end
|
|
393
440
|
end
|
|
394
441
|
|
|
@@ -396,17 +443,17 @@ describe Doorkeeper, 'configuration' do
|
|
|
396
443
|
before do
|
|
397
444
|
Doorkeeper.configure do
|
|
398
445
|
orm DOORKEEPER_ORM
|
|
399
|
-
grant_flows [
|
|
446
|
+
grant_flows ["client_credentials"]
|
|
400
447
|
end
|
|
401
448
|
end
|
|
402
449
|
|
|
403
450
|
it "includes 'client_credentials' in token_grant_types" do
|
|
404
|
-
expect(subject.token_grant_types).to include
|
|
451
|
+
expect(subject.token_grant_types).to include "client_credentials"
|
|
405
452
|
end
|
|
406
453
|
end
|
|
407
454
|
end
|
|
408
455
|
|
|
409
|
-
it
|
|
456
|
+
it "raises an exception when configuration is not set" do
|
|
410
457
|
old_config = Doorkeeper.configuration
|
|
411
458
|
Doorkeeper.module_eval do
|
|
412
459
|
@config = nil
|
|
@@ -421,41 +468,57 @@ describe Doorkeeper, 'configuration' do
|
|
|
421
468
|
end
|
|
422
469
|
end
|
|
423
470
|
|
|
424
|
-
describe
|
|
425
|
-
it
|
|
471
|
+
describe "access_token_generator" do
|
|
472
|
+
it "is 'Doorkeeper::OAuth::Helpers::UniqueToken' by default" do
|
|
426
473
|
expect(Doorkeeper.configuration.access_token_generator).to(
|
|
427
|
-
eq(
|
|
474
|
+
eq("Doorkeeper::OAuth::Helpers::UniqueToken")
|
|
428
475
|
)
|
|
429
476
|
end
|
|
430
477
|
|
|
431
|
-
it
|
|
478
|
+
it "can change the value" do
|
|
479
|
+
Doorkeeper.configure do
|
|
480
|
+
orm DOORKEEPER_ORM
|
|
481
|
+
access_token_generator "Example"
|
|
482
|
+
end
|
|
483
|
+
expect(subject.access_token_generator).to eq("Example")
|
|
484
|
+
end
|
|
485
|
+
end
|
|
486
|
+
|
|
487
|
+
describe "default_generator_method" do
|
|
488
|
+
it "is :urlsafe_base64 by default" do
|
|
489
|
+
expect(Doorkeeper.configuration.default_generator_method)
|
|
490
|
+
.to eq(:urlsafe_base64)
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
it "can change the value" do
|
|
432
494
|
Doorkeeper.configure do
|
|
433
495
|
orm DOORKEEPER_ORM
|
|
434
|
-
|
|
496
|
+
default_generator_method :hex
|
|
435
497
|
end
|
|
436
|
-
|
|
498
|
+
|
|
499
|
+
expect(subject.default_generator_method).to eq(:hex)
|
|
437
500
|
end
|
|
438
501
|
end
|
|
439
502
|
|
|
440
|
-
describe
|
|
441
|
-
context
|
|
442
|
-
it { expect(Doorkeeper.configuration.base_controller).to eq(
|
|
503
|
+
describe "base_controller" do
|
|
504
|
+
context "default" do
|
|
505
|
+
it { expect(Doorkeeper.configuration.base_controller).to eq("ActionController::Base") }
|
|
443
506
|
end
|
|
444
507
|
|
|
445
|
-
context
|
|
508
|
+
context "custom" do
|
|
446
509
|
before do
|
|
447
510
|
Doorkeeper.configure do
|
|
448
511
|
orm DOORKEEPER_ORM
|
|
449
|
-
base_controller
|
|
512
|
+
base_controller "ApplicationController"
|
|
450
513
|
end
|
|
451
514
|
end
|
|
452
515
|
|
|
453
|
-
it { expect(Doorkeeper.configuration.base_controller).to eq(
|
|
516
|
+
it { expect(Doorkeeper.configuration.base_controller).to eq("ApplicationController") }
|
|
454
517
|
end
|
|
455
518
|
end
|
|
456
519
|
|
|
457
520
|
if DOORKEEPER_ORM == :active_record
|
|
458
|
-
describe
|
|
521
|
+
describe "active_record_options" do
|
|
459
522
|
let(:models) { [Doorkeeper::AccessGrant, Doorkeeper::AccessToken, Doorkeeper::Application] }
|
|
460
523
|
|
|
461
524
|
before do
|
|
@@ -464,7 +527,7 @@ describe Doorkeeper, 'configuration' do
|
|
|
464
527
|
end
|
|
465
528
|
end
|
|
466
529
|
|
|
467
|
-
it
|
|
530
|
+
it "establishes connection for Doorkeeper models based on options" do
|
|
468
531
|
models.each do |model|
|
|
469
532
|
expect(model).to receive(:establish_connection)
|
|
470
533
|
end
|
|
@@ -494,8 +557,8 @@ describe Doorkeeper, 'configuration' do
|
|
|
494
557
|
end
|
|
495
558
|
end
|
|
496
559
|
|
|
497
|
-
describe
|
|
498
|
-
it
|
|
560
|
+
describe "strict_content_type" do
|
|
561
|
+
it "is false by default" do
|
|
499
562
|
expect(subject.enforce_content_type).to eq(false)
|
|
500
563
|
end
|
|
501
564
|
|
|
@@ -508,4 +571,127 @@ describe Doorkeeper, 'configuration' do
|
|
|
508
571
|
expect(subject.enforce_content_type).to eq(true)
|
|
509
572
|
end
|
|
510
573
|
end
|
|
574
|
+
|
|
575
|
+
describe "handle_auth_errors" do
|
|
576
|
+
it "is set to render by default" do
|
|
577
|
+
expect(Doorkeeper.configuration.handle_auth_errors).to eq(:render)
|
|
578
|
+
end
|
|
579
|
+
it "can change the value" do
|
|
580
|
+
Doorkeeper.configure do
|
|
581
|
+
orm DOORKEEPER_ORM
|
|
582
|
+
handle_auth_errors :raise
|
|
583
|
+
end
|
|
584
|
+
expect(subject.handle_auth_errors).to eq(:raise)
|
|
585
|
+
end
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
describe "token_secret_strategy" do
|
|
589
|
+
it "is plain by default" do
|
|
590
|
+
expect(subject.token_secret_strategy).to eq(Doorkeeper::SecretStoring::Plain)
|
|
591
|
+
expect(subject.token_secret_fallback_strategy).to eq(nil)
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
context "when provided" do
|
|
595
|
+
before do
|
|
596
|
+
Doorkeeper.configure do
|
|
597
|
+
hash_token_secrets
|
|
598
|
+
end
|
|
599
|
+
end
|
|
600
|
+
|
|
601
|
+
it "will enable hashing for applications" do
|
|
602
|
+
expect(subject.token_secret_strategy).to eq(Doorkeeper::SecretStoring::Sha256Hash)
|
|
603
|
+
expect(subject.token_secret_fallback_strategy).to eq(nil)
|
|
604
|
+
end
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
context "when manually provided with invalid constant" do
|
|
608
|
+
it "raises an exception" do
|
|
609
|
+
expect do
|
|
610
|
+
Doorkeeper.configure do
|
|
611
|
+
hash_token_secrets using: "does not exist"
|
|
612
|
+
end
|
|
613
|
+
end.to raise_error(NameError)
|
|
614
|
+
end
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
context "when manually provided with invalid option" do
|
|
618
|
+
it "raises an exception" do
|
|
619
|
+
expect do
|
|
620
|
+
Doorkeeper.configure do
|
|
621
|
+
hash_token_secrets using: "Doorkeeper::SecretStoring::BCrypt"
|
|
622
|
+
end
|
|
623
|
+
end.to raise_error(ArgumentError,
|
|
624
|
+
/can only be used for storing application secrets/)
|
|
625
|
+
end
|
|
626
|
+
end
|
|
627
|
+
|
|
628
|
+
context "when provided with fallback" do
|
|
629
|
+
before do
|
|
630
|
+
Doorkeeper.configure do
|
|
631
|
+
hash_token_secrets fallback: :plain
|
|
632
|
+
end
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
it "will enable hashing for applications" do
|
|
636
|
+
expect(subject.token_secret_strategy).to eq(Doorkeeper::SecretStoring::Sha256Hash)
|
|
637
|
+
expect(subject.token_secret_fallback_strategy).to eq(Doorkeeper::SecretStoring::Plain)
|
|
638
|
+
end
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
describe "hash_token_secrets together with reuse_access_token" do
|
|
642
|
+
it "will disable reuse_access_token" do
|
|
643
|
+
expect(Rails.logger).to receive(:warn).with(/reuse_access_token will be disabled/)
|
|
644
|
+
|
|
645
|
+
Doorkeeper.configure do
|
|
646
|
+
reuse_access_token
|
|
647
|
+
hash_token_secrets
|
|
648
|
+
end
|
|
649
|
+
|
|
650
|
+
expect(subject.reuse_access_token).to eq(false)
|
|
651
|
+
end
|
|
652
|
+
end
|
|
653
|
+
end
|
|
654
|
+
|
|
655
|
+
describe "application_secret_strategy" do
|
|
656
|
+
it "is plain by default" do
|
|
657
|
+
expect(subject.application_secret_strategy).to eq(Doorkeeper::SecretStoring::Plain)
|
|
658
|
+
expect(subject.application_secret_fallback_strategy).to eq(nil)
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
context "when provided" do
|
|
662
|
+
before do
|
|
663
|
+
Doorkeeper.configure do
|
|
664
|
+
hash_application_secrets
|
|
665
|
+
end
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
it "will enable hashing for applications" do
|
|
669
|
+
expect(subject.application_secret_strategy).to eq(Doorkeeper::SecretStoring::Sha256Hash)
|
|
670
|
+
expect(subject.application_secret_fallback_strategy).to eq(nil)
|
|
671
|
+
end
|
|
672
|
+
end
|
|
673
|
+
|
|
674
|
+
context "when manually provided with invalid constant" do
|
|
675
|
+
it "raises an exception" do
|
|
676
|
+
expect do
|
|
677
|
+
Doorkeeper.configure do
|
|
678
|
+
hash_application_secrets using: "does not exist"
|
|
679
|
+
end
|
|
680
|
+
end.to raise_error(NameError)
|
|
681
|
+
end
|
|
682
|
+
end
|
|
683
|
+
|
|
684
|
+
context "when provided with fallback" do
|
|
685
|
+
before do
|
|
686
|
+
Doorkeeper.configure do
|
|
687
|
+
hash_application_secrets fallback: :plain
|
|
688
|
+
end
|
|
689
|
+
end
|
|
690
|
+
|
|
691
|
+
it "will enable hashing for applications" do
|
|
692
|
+
expect(subject.application_secret_strategy).to eq(Doorkeeper::SecretStoring::Sha256Hash)
|
|
693
|
+
expect(subject.application_secret_fallback_strategy).to eq(Doorkeeper::SecretStoring::Plain)
|
|
694
|
+
end
|
|
695
|
+
end
|
|
696
|
+
end
|
|
511
697
|
end
|