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
@@ -1,84 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe Doorkeeper::OAuth::TokenResponse do
|
6
|
-
subject { described_class.new(double.as_null_object) }
|
7
|
-
|
8
|
-
it "includes access token response headers" do
|
9
|
-
headers = subject.headers
|
10
|
-
expect(headers.fetch("Cache-Control")).to eq("no-store")
|
11
|
-
expect(headers.fetch("Pragma")).to eq("no-cache")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "status is ok" do
|
15
|
-
expect(subject.status).to eq(:ok)
|
16
|
-
end
|
17
|
-
|
18
|
-
describe ".body" do
|
19
|
-
subject { described_class.new(access_token).body }
|
20
|
-
|
21
|
-
let(:access_token) do
|
22
|
-
double :access_token,
|
23
|
-
plaintext_token: "some-token",
|
24
|
-
expires_in: "3600",
|
25
|
-
expires_in_seconds: "300",
|
26
|
-
scopes_string: "two scopes",
|
27
|
-
plaintext_refresh_token: "some-refresh-token",
|
28
|
-
token_type: "bearer",
|
29
|
-
created_at: 0
|
30
|
-
end
|
31
|
-
|
32
|
-
it "includes :access_token" do
|
33
|
-
expect(subject["access_token"]).to eq("some-token")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "includes :token_type" do
|
37
|
-
expect(subject["token_type"]).to eq("bearer")
|
38
|
-
end
|
39
|
-
|
40
|
-
# expires_in_seconds is returned as `expires_in` in order to match
|
41
|
-
# the OAuth spec (section 4.2.2)
|
42
|
-
it "includes :expires_in" do
|
43
|
-
expect(subject["expires_in"]).to eq("300")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "includes :scope" do
|
47
|
-
expect(subject["scope"]).to eq("two scopes")
|
48
|
-
end
|
49
|
-
|
50
|
-
it "includes :refresh_token" do
|
51
|
-
expect(subject["refresh_token"]).to eq("some-refresh-token")
|
52
|
-
end
|
53
|
-
|
54
|
-
it "includes :created_at" do
|
55
|
-
expect(subject["created_at"]).to eq(0)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe ".body filters out empty values" do
|
60
|
-
subject { described_class.new(access_token).body }
|
61
|
-
|
62
|
-
let(:access_token) do
|
63
|
-
double :access_token,
|
64
|
-
plaintext_token: "some-token",
|
65
|
-
expires_in_seconds: "",
|
66
|
-
scopes_string: "",
|
67
|
-
plaintext_refresh_token: "",
|
68
|
-
token_type: "bearer",
|
69
|
-
created_at: 0
|
70
|
-
end
|
71
|
-
|
72
|
-
it "includes :expires_in" do
|
73
|
-
expect(subject["expires_in"]).to be_nil
|
74
|
-
end
|
75
|
-
|
76
|
-
it "includes :scope" do
|
77
|
-
expect(subject["scope"]).to be_nil
|
78
|
-
end
|
79
|
-
|
80
|
-
it "includes :refresh_token" do
|
81
|
-
expect(subject["refresh_token"]).to be_nil
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,156 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
module Doorkeeper
|
6
|
-
unless defined?(AccessToken)
|
7
|
-
class AccessToken
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
RSpec.describe Doorkeeper::OAuth::Token do
|
13
|
-
describe ".from_request" do
|
14
|
-
let(:request) { double.as_null_object }
|
15
|
-
|
16
|
-
let(:method) do
|
17
|
-
->(*) { "token-value" }
|
18
|
-
end
|
19
|
-
|
20
|
-
it "accepts anything that responds to #call" do
|
21
|
-
expect(method).to receive(:call).with(request)
|
22
|
-
described_class.from_request request, method
|
23
|
-
end
|
24
|
-
|
25
|
-
it "delegates methods received as symbols to described_class class" do
|
26
|
-
expect(described_class).to receive(:from_params).with(request)
|
27
|
-
described_class.from_request request, :from_params
|
28
|
-
end
|
29
|
-
|
30
|
-
it "stops at the first credentials found" do
|
31
|
-
not_called_method = double
|
32
|
-
expect(not_called_method).not_to receive(:call)
|
33
|
-
described_class.from_request request, ->(_r) {}, method, not_called_method
|
34
|
-
end
|
35
|
-
|
36
|
-
it "returns the credential from extractor method" do
|
37
|
-
credentials = described_class.from_request request, method
|
38
|
-
expect(credentials).to eq("token-value")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe ".from_access_token_param" do
|
43
|
-
it "returns token from access_token parameter" do
|
44
|
-
request = double parameters: { access_token: "some-token" }
|
45
|
-
token = described_class.from_access_token_param(request)
|
46
|
-
expect(token).to eq("some-token")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe ".from_bearer_param" do
|
51
|
-
it "returns token from bearer_token parameter" do
|
52
|
-
request = double parameters: { bearer_token: "some-token" }
|
53
|
-
token = described_class.from_bearer_param(request)
|
54
|
-
expect(token).to eq("some-token")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe ".from_bearer_authorization" do
|
59
|
-
it "returns token from capitalized authorization bearer" do
|
60
|
-
request = double authorization: "Bearer SomeToken"
|
61
|
-
token = described_class.from_bearer_authorization(request)
|
62
|
-
expect(token).to eq("SomeToken")
|
63
|
-
end
|
64
|
-
|
65
|
-
it "returns token from lowercased authorization bearer" do
|
66
|
-
request = double authorization: "bearer SomeToken"
|
67
|
-
token = described_class.from_bearer_authorization(request)
|
68
|
-
expect(token).to eq("SomeToken")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "does not return token if authorization is not bearer" do
|
72
|
-
request = double authorization: "MAC SomeToken"
|
73
|
-
token = described_class.from_bearer_authorization(request)
|
74
|
-
expect(token).to be_blank
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe ".from_basic_authorization" do
|
79
|
-
it "returns token from capitalized authorization basic" do
|
80
|
-
request = double authorization: "Basic #{Base64.encode64 "SomeToken:"}"
|
81
|
-
token = described_class.from_basic_authorization(request)
|
82
|
-
expect(token).to eq("SomeToken")
|
83
|
-
end
|
84
|
-
|
85
|
-
it "returns token from lowercased authorization basic" do
|
86
|
-
request = double authorization: "basic #{Base64.encode64 "SomeToken:"}"
|
87
|
-
token = described_class.from_basic_authorization(request)
|
88
|
-
expect(token).to eq("SomeToken")
|
89
|
-
end
|
90
|
-
|
91
|
-
it "does not return token if authorization is not basic" do
|
92
|
-
request = double authorization: "MAC #{Base64.encode64 "SomeToken:"}"
|
93
|
-
token = described_class.from_basic_authorization(request)
|
94
|
-
expect(token).to be_blank
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe ".authenticate" do
|
99
|
-
context "when refresh tokens are disabled (default)" do
|
100
|
-
context "when refresh tokens are enabled" do
|
101
|
-
it "does not revoke previous refresh_token if token was found" do
|
102
|
-
token = ->(_r) { "token" }
|
103
|
-
expect(
|
104
|
-
Doorkeeper::AccessToken,
|
105
|
-
).to receive(:by_token).with("token").and_return(token)
|
106
|
-
expect(token).not_to receive(:revoke_previous_refresh_token!)
|
107
|
-
described_class.authenticate double, token
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
it "calls the finder if token was returned" do
|
112
|
-
token = ->(_r) { "token" }
|
113
|
-
expect(Doorkeeper::AccessToken).to receive(:by_token).with("token")
|
114
|
-
described_class.authenticate double, token
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
context "when token hashing is enabled" do
|
119
|
-
include_context "with token hashing enabled"
|
120
|
-
|
121
|
-
let(:hashed_token) { hashed_or_plain_token_func.call("token") }
|
122
|
-
let(:token) { ->(_r) { "token" } }
|
123
|
-
|
124
|
-
it "searches with the hashed token" do
|
125
|
-
expect(
|
126
|
-
Doorkeeper::AccessToken,
|
127
|
-
).to receive(:find_by).with(token: hashed_token).and_return(token)
|
128
|
-
described_class.authenticate double, token
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
context "when refresh tokens are enabled" do
|
133
|
-
before do
|
134
|
-
Doorkeeper.configure do
|
135
|
-
orm DOORKEEPER_ORM
|
136
|
-
use_refresh_token
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
it "revokes previous refresh_token if token was found" do
|
141
|
-
token = ->(_r) { "token" }
|
142
|
-
expect(
|
143
|
-
Doorkeeper::AccessToken,
|
144
|
-
).to receive(:by_token).with("token").and_return(token)
|
145
|
-
expect(token).to receive(:revoke_previous_refresh_token!)
|
146
|
-
described_class.authenticate double, token
|
147
|
-
end
|
148
|
-
|
149
|
-
it "calls the finder if token was returned" do
|
150
|
-
token = ->(_r) { "token" }
|
151
|
-
expect(Doorkeeper::AccessToken).to receive(:by_token).with("token")
|
152
|
-
described_class.authenticate double, token
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
data/spec/lib/option_spec.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe Doorkeeper::Config::Option do
|
6
|
-
class Extension
|
7
|
-
def self.configure(&block)
|
8
|
-
@config = Config::Builder.new(Config.new, &block).build
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.configuration
|
12
|
-
@config || (raise Errors::MissingConfiguration)
|
13
|
-
end
|
14
|
-
|
15
|
-
class Config
|
16
|
-
class Builder < Doorkeeper::Config::AbstractBuilder
|
17
|
-
def enforce_something
|
18
|
-
@config.instance_variable_set(:@enforce_something, true)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def enforce_something?
|
23
|
-
if defined?(@enforce_something)
|
24
|
-
@enforce_something
|
25
|
-
else
|
26
|
-
false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.builder_class
|
31
|
-
Config::Builder
|
32
|
-
end
|
33
|
-
|
34
|
-
extend Doorkeeper::Config::Option
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
it "allows to define custom options in extensions" do
|
39
|
-
expect do
|
40
|
-
Extension::Config.option(:some_option, default: 1)
|
41
|
-
end.not_to raise_error
|
42
|
-
|
43
|
-
Extension.configure do
|
44
|
-
some_option 20
|
45
|
-
enforce_something
|
46
|
-
end
|
47
|
-
|
48
|
-
expect(Extension.configuration.some_option).to eq(20)
|
49
|
-
expect(Extension.configuration.enforce_something?).to be(true)
|
50
|
-
end
|
51
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe Doorkeeper::Request::Strategy do
|
6
|
-
subject(:strategy) { described_class.new(server) }
|
7
|
-
|
8
|
-
let(:server) { double }
|
9
|
-
|
10
|
-
describe "#initialize" do
|
11
|
-
it "sets the server attribute" do
|
12
|
-
expect(strategy.server).to eq server
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#request" do
|
17
|
-
it "requires an implementation" do
|
18
|
-
expect { strategy.request }.to raise_exception NotImplementedError
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "a sample Strategy subclass" do
|
23
|
-
subject(:strategy) { strategy_class.new(server) }
|
24
|
-
|
25
|
-
let(:fake_request) { double }
|
26
|
-
|
27
|
-
let(:strategy_class) do
|
28
|
-
subclass = Class.new(described_class) do
|
29
|
-
class << self
|
30
|
-
attr_accessor :fake_request
|
31
|
-
end
|
32
|
-
|
33
|
-
def request
|
34
|
-
self.class.fake_request
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
subclass.fake_request = fake_request
|
39
|
-
subclass
|
40
|
-
end
|
41
|
-
|
42
|
-
it "provides a request implementation" do
|
43
|
-
expect(strategy.request).to eq fake_request
|
44
|
-
end
|
45
|
-
|
46
|
-
it "authorizes the request" do
|
47
|
-
expect(fake_request).to receive :authorize
|
48
|
-
strategy.authorize
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe ::Doorkeeper::SecretStoring::Base do
|
6
|
-
subject { described_class }
|
7
|
-
|
8
|
-
let(:instance) { double("instance", token: "foo") }
|
9
|
-
|
10
|
-
describe "#transform_secret" do
|
11
|
-
it "raises" do
|
12
|
-
expect { subject.transform_secret("foo") }.to raise_error(NotImplementedError)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#store_secret" do
|
17
|
-
it "sends to response of #transform_secret to the instance" do
|
18
|
-
expect(described_class)
|
19
|
-
.to receive(:transform_secret).with("bar")
|
20
|
-
.and_return "bar+transform"
|
21
|
-
|
22
|
-
expect(instance).to receive(:token=).with "bar+transform"
|
23
|
-
result = subject.store_secret instance, :token, "bar"
|
24
|
-
expect(result).to eq "bar+transform"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "#restore_secret" do
|
29
|
-
it "raises" do
|
30
|
-
expect { subject.restore_secret(subject, :token) }.to raise_error(NotImplementedError)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#allows_restoring_secrets?" do
|
35
|
-
it "does not allow it" do
|
36
|
-
expect(subject.allows_restoring_secrets?).to eq false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "validate_for" do
|
41
|
-
it "allows for valid model" do
|
42
|
-
expect(subject.validate_for(:application)).to eq true
|
43
|
-
expect(subject.validate_for(:token)).to eq true
|
44
|
-
end
|
45
|
-
|
46
|
-
it "raises for invalid model" do
|
47
|
-
expect { subject.validate_for(:wat) }.to raise_error(ArgumentError, /can not be used for wat/)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "secret_matches?" do
|
52
|
-
before do
|
53
|
-
allow(subject).to receive(:transform_secret) { |input| "transformed: #{input}" }
|
54
|
-
end
|
55
|
-
|
56
|
-
it "compares input with #transform_secret" do
|
57
|
-
expect(subject.secret_matches?("input", "input")).to eq false
|
58
|
-
expect(subject.secret_matches?("a", "transformed: a")).to eq true
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
require "bcrypt"
|
5
|
-
|
6
|
-
RSpec.describe ::Doorkeeper::SecretStoring::BCrypt do
|
7
|
-
subject { described_class }
|
8
|
-
|
9
|
-
let(:instance) { double("instance", token: "foo") }
|
10
|
-
|
11
|
-
describe "#transform_secret" do
|
12
|
-
it "creates a bcrypt password" do
|
13
|
-
expect(subject.transform_secret("foo")).to be_a BCrypt::Password
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#restore_secret" do
|
18
|
-
it "raises" do
|
19
|
-
expect { subject.restore_secret(instance, :token) }.to raise_error(NotImplementedError)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#allows_restoring_secrets?" do
|
24
|
-
it "does not allow it" do
|
25
|
-
expect(subject.allows_restoring_secrets?).to eq false
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "validate_for" do
|
30
|
-
it "allows for valid model" do
|
31
|
-
expect(subject.validate_for(:application)).to eq true
|
32
|
-
end
|
33
|
-
|
34
|
-
it "raises for invalid model" do
|
35
|
-
expect { subject.validate_for(:wat) }
|
36
|
-
.to raise_error(ArgumentError, /can only be used for storing application secrets/)
|
37
|
-
expect { subject.validate_for(:token) }
|
38
|
-
.to raise_error(ArgumentError, /can only be used for storing application secrets/)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "secret_matches?" do
|
43
|
-
it "compares input with #transform_secret" do
|
44
|
-
expect(subject.secret_matches?("input", "input")).to eq false
|
45
|
-
|
46
|
-
password = BCrypt::Password.create "foobar"
|
47
|
-
expect(subject.secret_matches?("foobar", password.to_s)).to eq true
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe ::Doorkeeper::SecretStoring::Plain do
|
6
|
-
subject { described_class }
|
7
|
-
|
8
|
-
let(:instance) { double("instance", token: "foo") }
|
9
|
-
|
10
|
-
describe "#transform_secret" do
|
11
|
-
it "raises" do
|
12
|
-
expect(subject.transform_secret("foo")).to eq "foo"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#restore_secret" do
|
17
|
-
it "raises" do
|
18
|
-
expect(subject.restore_secret(instance, :token)).to eq "foo"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#allows_restoring_secrets?" do
|
23
|
-
it "does allow it" do
|
24
|
-
expect(subject.allows_restoring_secrets?).to eq true
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "validate_for" do
|
29
|
-
it "allows for valid model" do
|
30
|
-
expect(subject.validate_for(:application)).to eq true
|
31
|
-
expect(subject.validate_for(:token)).to eq true
|
32
|
-
end
|
33
|
-
|
34
|
-
it "raises for invalid model" do
|
35
|
-
expect { subject.validate_for(:wat) }.to raise_error(ArgumentError, /can not be used for wat/)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "secret_matches?" do
|
40
|
-
it "compares input with #transform_secret" do
|
41
|
-
expect(subject.secret_matches?("input", "input")).to eq true
|
42
|
-
expect(subject.secret_matches?("a", "b")).to eq false
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe ::Doorkeeper::SecretStoring::Sha256Hash do
|
6
|
-
subject { described_class }
|
7
|
-
|
8
|
-
let(:instance) { double("instance") }
|
9
|
-
|
10
|
-
let(:hash_function) do
|
11
|
-
->(input) { ::Digest::SHA256.hexdigest(input) }
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#transform_secret" do
|
15
|
-
it "raises" do
|
16
|
-
expect(subject.transform_secret("foo")).to eq hash_function.call("foo")
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#restore_secret" do
|
21
|
-
it "raises" do
|
22
|
-
expect { subject.restore_secret(instance, :token) }.to raise_error(NotImplementedError)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#allows_restoring_secrets?" do
|
27
|
-
it "does not allow it" do
|
28
|
-
expect(subject.allows_restoring_secrets?).to eq false
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "validate_for" do
|
33
|
-
it "allows for valid model" do
|
34
|
-
expect(subject.validate_for(:application)).to eq true
|
35
|
-
expect(subject.validate_for(:token)).to eq true
|
36
|
-
end
|
37
|
-
|
38
|
-
it "raises for invalid model" do
|
39
|
-
expect { subject.validate_for(:wat) }.to raise_error(ArgumentError, /can not be used for wat/)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "secret_matches?" do
|
44
|
-
it "compares input with #transform_secret" do
|
45
|
-
expect(subject.secret_matches?("input", "input")).to eq false
|
46
|
-
expect(subject.secret_matches?("a", hash_function.call("a"))).to eq true
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|