doorkeeper-mongodb 5.2.3 → 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 +3 -3
- data/Rakefile +18 -4
- data/lib/doorkeeper/orm/mongoid8/access_grant.rb +26 -0
- data/lib/doorkeeper/orm/mongoid8/access_token.rb +38 -0
- data/lib/doorkeeper/orm/mongoid8/application.rb +43 -0
- data/lib/doorkeeper/orm/mongoid8/stale_records_cleaner.rb +11 -0
- data/lib/doorkeeper/orm/mongoid8.rb +50 -0
- data/lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb +45 -5
- data/lib/doorkeeper-mongodb/version.rb +2 -2
- data/lib/doorkeeper-mongodb.rb +1 -0
- 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 +123 -242
- 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,183 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe Doorkeeper::RedirectUriValidator do
|
6
|
-
subject(:client) do
|
7
|
-
FactoryBot.create(:application)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "is valid when the uri is a uri" do
|
11
|
-
client.redirect_uri = "https://example.com/callback"
|
12
|
-
expect(client).to be_valid
|
13
|
-
end
|
14
|
-
|
15
|
-
# Most mobile and desktop operating systems allow apps to register a custom URL
|
16
|
-
# scheme that will launch the app when a URL with that scheme is visited from
|
17
|
-
# the system browser.
|
18
|
-
#
|
19
|
-
# @see https://www.oauth.com/oauth2-servers/redirect-uris/redirect-uris-native-apps/
|
20
|
-
it "is valid when the uri is custom native URI" do
|
21
|
-
client.redirect_uri = "myapp:/callback"
|
22
|
-
expect(client).to be_valid
|
23
|
-
end
|
24
|
-
|
25
|
-
it "is valid when the uri has a query parameter" do
|
26
|
-
client.redirect_uri = "https://example.com/abcd?xyz=123"
|
27
|
-
expect(client).to be_valid
|
28
|
-
end
|
29
|
-
|
30
|
-
it "accepts nonstandard oob redirect uri" do
|
31
|
-
client.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
|
32
|
-
expect(client).to be_valid
|
33
|
-
end
|
34
|
-
|
35
|
-
it "accepts nonstandard oob:auto redirect uri" do
|
36
|
-
client.redirect_uri = "urn:ietf:wg:oauth:2.0:oob:auto"
|
37
|
-
expect(client).to be_valid
|
38
|
-
end
|
39
|
-
|
40
|
-
it "is invalid when the uri is not a uri" do
|
41
|
-
client.redirect_uri = "]"
|
42
|
-
expect(client).not_to be_valid
|
43
|
-
expect(client.errors[:redirect_uri].first).to eq(I18n.t("activerecord.errors.models.doorkeeper/application.attributes.redirect_uri.invalid_uri"))
|
44
|
-
end
|
45
|
-
|
46
|
-
it "is invalid when the uri is relative" do
|
47
|
-
client.redirect_uri = "/abcd"
|
48
|
-
expect(client).not_to be_valid
|
49
|
-
expect(client.errors[:redirect_uri].first).to eq(I18n.t("activerecord.errors.models.doorkeeper/application.attributes.redirect_uri.relative_uri"))
|
50
|
-
end
|
51
|
-
|
52
|
-
it "is invalid when the uri has a fragment" do
|
53
|
-
client.redirect_uri = "https://example.com/abcd#xyz"
|
54
|
-
expect(client).not_to be_valid
|
55
|
-
expect(client.errors[:redirect_uri].first).to eq(I18n.t("activerecord.errors.models.doorkeeper/application.attributes.redirect_uri.fragment_present"))
|
56
|
-
end
|
57
|
-
|
58
|
-
it "is invalid when scheme resolves to localhost (needs an explict scheme)" do
|
59
|
-
client.redirect_uri = "localhost:80"
|
60
|
-
expect(client).to be_invalid
|
61
|
-
expect(client.errors[:redirect_uri].first).to eq(I18n.t("activerecord.errors.models.doorkeeper/application.attributes.redirect_uri.unspecified_scheme"))
|
62
|
-
end
|
63
|
-
|
64
|
-
it "is invalid if an ip address" do
|
65
|
-
client.redirect_uri = "127.0.0.1:8080"
|
66
|
-
expect(client).to be_invalid
|
67
|
-
end
|
68
|
-
|
69
|
-
it "accepts an ip address based URI if a scheme is specified" do
|
70
|
-
client.redirect_uri = "https://127.0.0.1:8080"
|
71
|
-
expect(client).to be_valid
|
72
|
-
end
|
73
|
-
|
74
|
-
context "when force secured uri configured" do
|
75
|
-
it "accepts a valid uri" do
|
76
|
-
client.redirect_uri = "https://example.com/callback"
|
77
|
-
expect(client).to be_valid
|
78
|
-
end
|
79
|
-
|
80
|
-
it "accepts custom scheme redirect uri (as per rfc8252 section 7.1)" do
|
81
|
-
client.redirect_uri = "com.example.app:/oauth/callback"
|
82
|
-
expect(client).to be_valid
|
83
|
-
end
|
84
|
-
|
85
|
-
it "accepts custom scheme redirect uri (as per rfc8252 section 7.1) #2" do
|
86
|
-
client.redirect_uri = "com.example.app:/test"
|
87
|
-
expect(client).to be_valid
|
88
|
-
end
|
89
|
-
|
90
|
-
it "accepts custom scheme redirect uri (common misconfiguration we have decided to allow)" do
|
91
|
-
client.redirect_uri = "com.example.app://oauth/callback"
|
92
|
-
expect(client).to be_valid
|
93
|
-
end
|
94
|
-
|
95
|
-
it "accepts custom scheme redirect uri (common misconfiguration we have decided to allow) #2" do
|
96
|
-
client.redirect_uri = "com.example.app://test"
|
97
|
-
expect(client).to be_valid
|
98
|
-
end
|
99
|
-
|
100
|
-
it "accepts a non secured protocol when disabled" do
|
101
|
-
client.redirect_uri = "http://example.com/callback"
|
102
|
-
allow(Doorkeeper.configuration).to receive(
|
103
|
-
:force_ssl_in_redirect_uri,
|
104
|
-
).and_return(false)
|
105
|
-
expect(client).to be_valid
|
106
|
-
end
|
107
|
-
|
108
|
-
it "accepts a non secured protocol when conditional option defined" do
|
109
|
-
Doorkeeper.configure do
|
110
|
-
orm DOORKEEPER_ORM
|
111
|
-
force_ssl_in_redirect_uri { |uri| uri.host != "localhost" }
|
112
|
-
end
|
113
|
-
|
114
|
-
application = FactoryBot.build(:application, redirect_uri: "http://localhost/callback")
|
115
|
-
expect(application).to be_valid
|
116
|
-
|
117
|
-
application = FactoryBot.build(:application, redirect_uri: "https://test.com/callback")
|
118
|
-
expect(application).to be_valid
|
119
|
-
|
120
|
-
application = FactoryBot.build(:application, redirect_uri: "http://localhost2/callback")
|
121
|
-
expect(application).not_to be_valid
|
122
|
-
|
123
|
-
application = FactoryBot.build(:application, redirect_uri: "https://test.com/callback")
|
124
|
-
expect(application).to be_valid
|
125
|
-
end
|
126
|
-
|
127
|
-
it "forbids redirect uri if required" do
|
128
|
-
client.redirect_uri = "javascript://document.cookie"
|
129
|
-
|
130
|
-
Doorkeeper.configure do
|
131
|
-
orm DOORKEEPER_ORM
|
132
|
-
forbid_redirect_uri { |uri| uri.scheme == "javascript" }
|
133
|
-
end
|
134
|
-
|
135
|
-
expect(client).to be_invalid
|
136
|
-
expect(client.errors[:redirect_uri].first).to eq("is forbidden by the server.")
|
137
|
-
|
138
|
-
client.redirect_uri = "https://localhost/callback"
|
139
|
-
expect(client).to be_valid
|
140
|
-
end
|
141
|
-
|
142
|
-
it "invalidates the uri when the uri does not use a secure protocol" do
|
143
|
-
client.redirect_uri = "http://example.com/callback"
|
144
|
-
expect(client).not_to be_valid
|
145
|
-
error = client.errors[:redirect_uri].first
|
146
|
-
expect(error).to eq(I18n.t("activerecord.errors.models.doorkeeper/application.attributes.redirect_uri.secured_uri"))
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context "with multiple redirect uri" do
|
151
|
-
it "invalidates the second uri when the first uri is native uri" do
|
152
|
-
client.redirect_uri = "urn:ietf:wg:oauth:2.0:oob\nexample.com/callback"
|
153
|
-
expect(client).to be_invalid
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
context "with blank redirect URI" do
|
158
|
-
it "forbids blank redirect uri by default" do
|
159
|
-
client.redirect_uri = ""
|
160
|
-
|
161
|
-
expect(client).to be_invalid
|
162
|
-
expect(client.errors[:redirect_uri]).not_to be_blank
|
163
|
-
end
|
164
|
-
|
165
|
-
it "forbids blank redirect uri by custom condition" do
|
166
|
-
Doorkeeper.configure do
|
167
|
-
orm DOORKEEPER_ORM
|
168
|
-
allow_blank_redirect_uri do |_grant_flows, application|
|
169
|
-
application.name == "admin app"
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
client.name = "test app"
|
174
|
-
client.redirect_uri = ""
|
175
|
-
|
176
|
-
expect(client).to be_invalid
|
177
|
-
expect(client.errors[:redirect_uri]).not_to be_blank
|
178
|
-
|
179
|
-
client.name = "admin app"
|
180
|
-
expect(client).to be_valid
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe Doorkeeper::Server do
|
6
|
-
subject do
|
7
|
-
described_class.new(context)
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:fake_class) { double :fake_class }
|
11
|
-
let(:context) { double :context }
|
12
|
-
|
13
|
-
describe ".authorization_request" do
|
14
|
-
it "raises error when strategy does not match phase" do
|
15
|
-
expect do
|
16
|
-
subject.token_request(:code)
|
17
|
-
end.to raise_error(Doorkeeper::Errors::InvalidTokenStrategy)
|
18
|
-
end
|
19
|
-
|
20
|
-
context "when only Authorization Code strategy is enabled" do
|
21
|
-
before do
|
22
|
-
allow(Doorkeeper.configuration)
|
23
|
-
.to receive(:grant_flows)
|
24
|
-
.and_return(["authorization_code"])
|
25
|
-
end
|
26
|
-
|
27
|
-
it "raises error when using the disabled Client Credentials strategy" do
|
28
|
-
expect do
|
29
|
-
subject.token_request(:client_credentials)
|
30
|
-
end.to raise_error(Doorkeeper::Errors::InvalidTokenStrategy)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
it "builds the request with selected strategy" do
|
35
|
-
stub_const "Doorkeeper::Request::Code", fake_class
|
36
|
-
expect(fake_class).to receive(:new).with(subject)
|
37
|
-
subject.authorization_request :code
|
38
|
-
end
|
39
|
-
|
40
|
-
it "builds the request with composite strategy name" do
|
41
|
-
allow(Doorkeeper.configuration)
|
42
|
-
.to receive(:authorization_response_types)
|
43
|
-
.and_return(["id_token token"])
|
44
|
-
|
45
|
-
stub_const "Doorkeeper::Request::IdTokenToken", fake_class
|
46
|
-
expect(fake_class).to receive(:new).with(subject)
|
47
|
-
subject.authorization_request "id_token token"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,103 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe Doorkeeper::StaleRecordsCleaner do
|
6
|
-
let(:cleaner) { described_class.new(model) }
|
7
|
-
let(:models_by_name) do
|
8
|
-
{
|
9
|
-
access_token: Doorkeeper::AccessToken,
|
10
|
-
access_grant: Doorkeeper::AccessGrant,
|
11
|
-
}
|
12
|
-
end
|
13
|
-
let(:resource_owner) { FactoryBot.create(:resource_owner) }
|
14
|
-
|
15
|
-
context "when ORM has no cleaner class" do
|
16
|
-
it "raises an error" do
|
17
|
-
allow(Doorkeeper.configuration).to receive(:orm).and_return("hibernate")
|
18
|
-
|
19
|
-
expect do
|
20
|
-
described_class.for(Doorkeeper::AccessToken)
|
21
|
-
end.to raise_error(Doorkeeper::Errors::NoOrmCleaner, /has no cleaner/)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
%i[access_token access_grant].each do |model_name|
|
26
|
-
context "(#{model_name})" do
|
27
|
-
let(:model) { models_by_name.fetch(model_name) }
|
28
|
-
|
29
|
-
describe "#clean_revoked" do
|
30
|
-
subject { cleaner.clean_revoked }
|
31
|
-
|
32
|
-
context "with revoked record" do
|
33
|
-
before do
|
34
|
-
FactoryBot.create model_name,
|
35
|
-
revoked_at: Time.current - 1.minute,
|
36
|
-
resource_owner_id: resource_owner.id,
|
37
|
-
resource_owner_type: resource_owner.class.name
|
38
|
-
end
|
39
|
-
|
40
|
-
it "removes the record" do
|
41
|
-
expect { subject }.to change(model, :count).to(0)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "with record revoked in the future" do
|
46
|
-
before do
|
47
|
-
FactoryBot.create model_name, revoked_at: Time.current + 1.minute,
|
48
|
-
resource_owner_id: resource_owner.id,
|
49
|
-
resource_owner_type: resource_owner.class.name
|
50
|
-
end
|
51
|
-
|
52
|
-
it "keeps the record" do
|
53
|
-
expect { subject }.not_to(change(model, :count))
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context "with unrevoked record" do
|
58
|
-
before do
|
59
|
-
FactoryBot.create model_name, revoked_at: nil,
|
60
|
-
resource_owner_id: resource_owner.id,
|
61
|
-
resource_owner_type: resource_owner.class.name
|
62
|
-
end
|
63
|
-
|
64
|
-
it "keeps the record" do
|
65
|
-
expect { subject }.not_to(change(model, :count))
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "#clean_expired" do
|
71
|
-
subject { cleaner.clean_expired(ttl) }
|
72
|
-
|
73
|
-
let(:ttl) { 500 }
|
74
|
-
let(:expiry_border) { ttl.seconds.ago }
|
75
|
-
|
76
|
-
context "with record that is expired" do
|
77
|
-
before do
|
78
|
-
FactoryBot.create model_name,
|
79
|
-
created_at: expiry_border - 1.minute,
|
80
|
-
resource_owner_id: resource_owner.id,
|
81
|
-
resource_owner_type: resource_owner.class.name
|
82
|
-
end
|
83
|
-
|
84
|
-
it "removes the record" do
|
85
|
-
expect { subject }.to change(model, :count).to(0)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "with record that is not expired" do
|
90
|
-
before do
|
91
|
-
FactoryBot.create model_name, created_at: expiry_border + 1.minute,
|
92
|
-
resource_owner_id: resource_owner.id,
|
93
|
-
resource_owner_type: resource_owner.class.name
|
94
|
-
end
|
95
|
-
|
96
|
-
it "keeps the record" do
|
97
|
-
expect { subject }.not_to(change(model, :count))
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe Doorkeeper::VERSION do
|
6
|
-
describe "#gem_version" do
|
7
|
-
it "returns Gem::Version instance" do
|
8
|
-
expect(Doorkeeper.gem_version).to be_an_instance_of(Gem::Version)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "VERSION" do
|
13
|
-
it "returns gem version string" do
|
14
|
-
expect(Doorkeeper::VERSION::STRING).to match(/^\d+\.\d+\.\d+(\.\w+)?$/)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,2 +0,0 @@
|
|
1
|
-
[o:Set:
|
2
|
-
@hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"0processors:type=text/css&file_type=text/css;TTI"wfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/admin/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"vfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css;TTI"/file-digest://app/assets/config/doorkeeper;TTI"=file-digest://app/assets/config/doorkeeper/bootstrap.min;TTI"afile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper;TTI"ofile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/bootstrap.min;TTI"dfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper;TTI"rfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper/bootstrap.min;TTI"gfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/admin;TTF
|
Binary file
|
@@ -1,2 +0,0 @@
|
|
1
|
-
[o:Set:
|
2
|
-
@hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"qfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/application.css;TTI"/file-digest://app/assets/config/doorkeeper;TTI"=file-digest://app/assets/config/doorkeeper/bootstrap.min;TTI"afile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper;TTI"ofile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/bootstrap.min;TTI"dfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper;TTI"rfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper/bootstrap.min;TTI"vfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css;TTI"gfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/admin;TTI"wfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/admin/application.css;TTF
|
@@ -1 +0,0 @@
|
|
1
|
-
I"�/projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css?type=text/css&pipeline=self&id=daba14d4424206b4335cdce8ada537ed4438c0f4fb3f02689b7dc8e6b461a51d:ET
|
@@ -1 +0,0 @@
|
|
1
|
-
I"�/projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/admin/application.css?type=text/css&id=d4a0bf1f81a686ae6d7fa42743d4162f2ffb7d9898054f58424a8312c7e3e5d3:ET
|
@@ -1 +0,0 @@
|
|
1
|
-
I"�app/assets/config/manifest.js?type=application/javascript&pipeline=self&id=5951e2f070f6725a38147f83916eb3f6f00c7616e749373c64f5b1ab789491e1:ET
|
@@ -1 +0,0 @@
|
|
1
|
-
I"}app/assets/config/manifest.js?type=application/javascript&id=71713d21305e52ed6e7b660af6997862962a2d6edec4b816f5fbfd7548c16112:ET
|
@@ -1 +0,0 @@
|
|
1
|
-
I"�/projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/application.css?type=text/css&pipeline=self&id=f0a3a8f45d77d4938fc188b84e8157aeea893b0de0238a2e517ab176000d9ca5:ET
|
Binary file
|
@@ -1,2 +0,0 @@
|
|
1
|
-
[o:Set:
|
2
|
-
@hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"wfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/admin/application.css;TTI"/file-digest://app/assets/config/doorkeeper;TTI"=file-digest://app/assets/config/doorkeeper/bootstrap.min;TTI"afile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper;TTI"ofile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/bootstrap.min;TTI"dfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper;TTI"rfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper/bootstrap.min;TTI"vfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css;TTI"gfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/admin;TTF
|
@@ -1 +0,0 @@
|
|
1
|
-
I"�/projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/admin/application.css?type=text/css&pipeline=self&id=4fda007b8fe3afbc49a12bbe630949b5ffc72a1f78212278f2fd2837096177f9:ET
|
@@ -1 +0,0 @@
|
|
1
|
-
I"�/projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/application.css?type=text/css&id=122fcb19594867ae9f0d5987f2389a80bda9ed6dbd689b3c44d8f6d21a164fe1:ET
|
@@ -1,2 +0,0 @@
|
|
1
|
-
[o:Set:
|
2
|
-
@hash}I"environment-version:ETTI"environment-paths;TTI"rails-env;TTI"0processors:type=text/css&file_type=text/css;TTI"qfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/application.css;TTI">processors:type=text/css&file_type=text/css&pipeline=self;TTI"vfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css;TTI"/file-digest://app/assets/config/doorkeeper;TTI"=file-digest://app/assets/config/doorkeeper/bootstrap.min;TTI"afile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper;TTI"ofile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/bootstrap.min;TTI"dfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper;TTI"rfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/vendor/assets/stylesheets/doorkeeper/bootstrap.min;TTI"gfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/admin;TTI"wfile-digest:///projects/gems/doorkeeper-mongodb/doorkeeper/app/assets/stylesheets/doorkeeper/admin/application.css;TTF
|
Binary file
|
Binary file
|
Binary file
|
data/spec/factories.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
FactoryBot.define do
|
4
|
-
factory :access_grant, class: "Doorkeeper::AccessGrant" do
|
5
|
-
sequence(:resource_owner_id) { |n| n }
|
6
|
-
application
|
7
|
-
redirect_uri { "https://app.com/callback" }
|
8
|
-
expires_in { 100 }
|
9
|
-
scopes { "public write" }
|
10
|
-
end
|
11
|
-
|
12
|
-
factory :access_token, class: "Doorkeeper::AccessToken" do
|
13
|
-
sequence(:resource_owner_id) { |n| n }
|
14
|
-
application
|
15
|
-
expires_in { 2.hours }
|
16
|
-
|
17
|
-
factory :clientless_access_token do
|
18
|
-
application { nil }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
factory :application, class: "Doorkeeper::Application" do
|
23
|
-
sequence(:name) { |n| "Application #{n}" }
|
24
|
-
redirect_uri { "https://app.com/callback" }
|
25
|
-
end
|
26
|
-
|
27
|
-
# do not name this factory :user, otherwise it will conflict with factories
|
28
|
-
# from applications that use doorkeeper factories in their own tests
|
29
|
-
factory :doorkeeper_testing_user, class: :user, aliases: [:resource_owner]
|
30
|
-
end
|
@@ -1,137 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
require "grape"
|
5
|
-
require "rack/test"
|
6
|
-
require "doorkeeper/grape/helpers"
|
7
|
-
|
8
|
-
# Test Grape API application
|
9
|
-
module GrapeApp
|
10
|
-
class API < Grape::API
|
11
|
-
version "v1", using: :path
|
12
|
-
format :json
|
13
|
-
prefix :api
|
14
|
-
|
15
|
-
helpers Doorkeeper::Grape::Helpers
|
16
|
-
|
17
|
-
resource :protected do
|
18
|
-
before do
|
19
|
-
doorkeeper_authorize!
|
20
|
-
end
|
21
|
-
|
22
|
-
desc "Protected resource, requires token."
|
23
|
-
|
24
|
-
get :status do
|
25
|
-
{ token: doorkeeper_token.token }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
resource :protected_with_endpoint_scopes do
|
30
|
-
before do
|
31
|
-
doorkeeper_authorize!
|
32
|
-
end
|
33
|
-
|
34
|
-
desc "Protected resource, requires token with scopes (defined in endpoint)."
|
35
|
-
|
36
|
-
get :status, scopes: [:admin] do
|
37
|
-
{ response: "OK" }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
resource :protected_with_helper_scopes do
|
42
|
-
before do
|
43
|
-
doorkeeper_authorize! :admin
|
44
|
-
end
|
45
|
-
|
46
|
-
desc "Protected resource, requires token with scopes (defined in helper)."
|
47
|
-
|
48
|
-
get :status do
|
49
|
-
{ response: "OK" }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
resource :public do
|
54
|
-
desc "Public resource, no token required."
|
55
|
-
|
56
|
-
get :status do
|
57
|
-
{ response: "OK" }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
RSpec.describe "Grape integration" do
|
64
|
-
include Rack::Test::Methods
|
65
|
-
|
66
|
-
def app
|
67
|
-
GrapeApp::API
|
68
|
-
end
|
69
|
-
|
70
|
-
def json_body
|
71
|
-
JSON.parse(last_response.body)
|
72
|
-
end
|
73
|
-
|
74
|
-
let(:client) { FactoryBot.create(:application) }
|
75
|
-
let(:resource) { FactoryBot.create(:doorkeeper_testing_user, name: "Joe", password: "sekret") }
|
76
|
-
let(:access_token) { client_is_authorized(client, resource) }
|
77
|
-
|
78
|
-
context "with valid Access Token" do
|
79
|
-
it "successfully requests protected resource" do
|
80
|
-
get "api/v1/protected/status.json?access_token=#{access_token.token}"
|
81
|
-
|
82
|
-
expect(last_response).to be_successful
|
83
|
-
|
84
|
-
expect(json_body["token"]).to eq(access_token.token)
|
85
|
-
end
|
86
|
-
|
87
|
-
it "successfully requests protected resource with token that has required scopes (Grape endpoint)" do
|
88
|
-
access_token = client_is_authorized(client, resource, scopes: "admin")
|
89
|
-
|
90
|
-
get "api/v1/protected_with_endpoint_scopes/status.json?access_token=#{access_token.token}"
|
91
|
-
|
92
|
-
expect(last_response).to be_successful
|
93
|
-
expect(json_body).to have_key("response")
|
94
|
-
end
|
95
|
-
|
96
|
-
it "successfully requests protected resource with token that has required scopes (Doorkeeper helper)" do
|
97
|
-
access_token = client_is_authorized(client, resource, scopes: "admin")
|
98
|
-
|
99
|
-
get "api/v1/protected_with_helper_scopes/status.json?access_token=#{access_token.token}"
|
100
|
-
|
101
|
-
expect(last_response).to be_successful
|
102
|
-
expect(json_body).to have_key("response")
|
103
|
-
end
|
104
|
-
|
105
|
-
it "successfully requests public resource" do
|
106
|
-
get "api/v1/public/status.json"
|
107
|
-
|
108
|
-
expect(last_response).to be_successful
|
109
|
-
expect(json_body).to have_key("response")
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context "with invalid Access Token" do
|
114
|
-
it "fails without access token" do
|
115
|
-
get "api/v1/protected/status.json"
|
116
|
-
|
117
|
-
expect(last_response).not_to be_successful
|
118
|
-
expect(json_body).to have_key("error")
|
119
|
-
end
|
120
|
-
|
121
|
-
it "fails for access token without scopes" do
|
122
|
-
get "api/v1/protected_with_endpoint_scopes/status.json?access_token=#{access_token.token}"
|
123
|
-
|
124
|
-
expect(last_response).not_to be_successful
|
125
|
-
expect(json_body).to have_key("error")
|
126
|
-
end
|
127
|
-
|
128
|
-
it "fails for access token with invalid scopes" do
|
129
|
-
access_token = client_is_authorized(client, resource, scopes: "read write")
|
130
|
-
|
131
|
-
get "api/v1/protected_with_endpoint_scopes/status.json?access_token=#{access_token.token}"
|
132
|
-
|
133
|
-
expect(last_response).not_to be_successful
|
134
|
-
expect(json_body).to have_key("error")
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
RSpec.describe Doorkeeper::DashboardHelper do
|
6
|
-
describe "#doorkeeper_errors_for" do
|
7
|
-
let(:object) { double errors: { method: messages } }
|
8
|
-
let(:messages) { ["first message", "second message"] }
|
9
|
-
|
10
|
-
context "when object has errors" do
|
11
|
-
it "returns error messages" do
|
12
|
-
messages.each do |message|
|
13
|
-
expect(helper.doorkeeper_errors_for(object, :method)).to include(
|
14
|
-
message.capitalize,
|
15
|
-
)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "when object has no errors" do
|
21
|
-
it "returns nil" do
|
22
|
-
expect(helper.doorkeeper_errors_for(object, :amonter_method)).to be_nil
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|