doorkeeper-mongodb 5.2.1 → 5.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -27
- data/lib/doorkeeper/orm/concerns/mongoid/ownership.rb +1 -1
- data/lib/doorkeeper/orm/concerns/mongoid/resource_ownerable.rb +1 -1
- data/lib/doorkeeper/orm/mongoid4.rb +18 -0
- data/lib/doorkeeper/orm/mongoid5.rb +18 -0
- data/lib/doorkeeper/orm/mongoid6.rb +18 -0
- data/lib/doorkeeper/orm/mongoid7.rb +18 -0
- data/lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb +7 -6
- data/lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb +8 -5
- data/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb +82 -5
- data/lib/doorkeeper-mongodb/mixins/mongoid/base_mixin.rb +0 -8
- data/lib/doorkeeper-mongodb/mixins/mongoid/json_serializable.rb +17 -0
- data/lib/doorkeeper-mongodb/version.rb +1 -1
- data/lib/doorkeeper-mongodb.rb +1 -0
- data/spec/controllers/application_metal_controller_spec.rb +4 -4
- data/spec/controllers/applications_controller_spec.rb +198 -202
- data/spec/controllers/authorizations_controller_spec.rb +32 -31
- data/spec/controllers/protected_resources_controller_spec.rb +10 -10
- data/spec/controllers/token_info_controller_spec.rb +1 -1
- data/spec/controllers/tokens_controller_spec.rb +105 -62
- data/spec/doorkeeper/redirect_uri_validator_spec.rb +183 -0
- data/spec/{lib → doorkeeper}/server_spec.rb +5 -4
- data/spec/{lib → doorkeeper}/stale_records_cleaner_spec.rb +8 -7
- data/spec/{version → doorkeeper}/version_spec.rb +3 -3
- 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/models/user.rb +0 -1
- 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 +0 -0
- 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/mongo.yml +2 -2
- data/spec/dummy/config/routes.rb +0 -0
- data/spec/dummy/config.ru +0 -0
- 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/schema.rb +0 -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/-o/-ofn45zIfO5vx4VD6m6NXesLf6da5usA-Sbw2SVju3o.cache +0 -0
- 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 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/4Q/4QQw-pMQ98JIj3xdcFhGBQdysdGPY9rWffRqWMmyjew.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/7H/7HjRsym0tTpXFCVhWt6kteMs_-CozKVbr9s5syHm8es.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8B/8BxJyv22HPFHu1se_l2J8qW1N9NzZ16UOWOy1YMSgs4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8D/8DJG7JfPvShfLLyeSom6NZ_TcQc6QH27tJ7prEWZPfI.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/9x/9xjtGv-yKjj62x9uFwBZg8pTSh9ERPAgANwNo9uwIaA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Bt/BtXO7f0PZ8DNt3TMLYM-zY7LkbWa_KgyB0v1V98M1CQ.cache +0 -0
- 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 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/FJ/FJlQpfMtpRbrM5P8A7d2FAelFKwo6GrVs2xks8z5GKU.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/L8/L8mOWakJlWKr6MU85rj0V7yGFfNyIR6vE6YXtqArPGw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Lk/LklIq5hrBAPESXVUpFMwQ9L-1qTj90sPVi6U19_Xi-Q.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/MB/MBWRxa9S470ee8suxVKp0jYgv6K6FQOqKGV0kPGQNMs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ma/MaK3K1AoZZ4xM5fOOifhROd73hfZJpP4yGbkGdoYtEk.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/PA/PAH_jI20wRw12tngeJ-V619c30avNLDu5U9Z-9Pc5SQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ph/Ph7RtH_NvG2I8XpTa8mA8SBQXZDzBPVIh4CH6g7OXJ0.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{eS/eSL1QMz46gKLM0GR6S9fL6uyARPxOImcappZ9_ZtSyg.cache → Pm/PmheG0PGFqDws1qgFOxOyIL-gpMof3Ar9eSRKVLYuik.cache} +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Pn/PnXU_mkG2fLZFm9BwiZ03BZdBTjKuInP-cRXjHS7yJo.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Qs/QsVgO6vM5Yn9oeYTYlrqtyVnK6sdVDWDa083N7zpfHw.cache +0 -0
- 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/b6/b6QRH6ZdCc0e6bUWu4qni_kZmptaMgWciO8Jl9q6_p8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/dX/dX6FDdUIy8yBCOoaoXcjf71rX9N_bpiXGJ4Urt32NTk.cache +0 -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/qT/qTQIQsmS0Wbbg2JxNn9rxdI5qVOTg5SfyQdaTvr9vLo.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/yN/yNOFGOsnHmxXNMkuEAWuL1u3jlmdvrdeoTx6DDJ1in8.cache +0 -0
- data/spec/factories.rb +0 -0
- data/spec/grape/grape_integration_spec.rb +1 -1
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +1 -1
- data/spec/lib/config_spec.rb +23 -12
- data/spec/lib/doorkeeper_spec.rb +4 -4
- data/spec/lib/models/expirable_spec.rb +9 -9
- data/spec/lib/models/reusable_spec.rb +2 -2
- data/spec/lib/models/revocable_spec.rb +4 -7
- data/spec/lib/models/scopes_spec.rb +7 -7
- data/spec/lib/models/secret_storable_spec.rb +9 -8
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +23 -27
- data/spec/lib/oauth/authorization_code_request_spec.rb +6 -6
- data/spec/lib/oauth/base_request_spec.rb +11 -27
- data/spec/lib/oauth/base_response_spec.rb +2 -2
- data/spec/lib/oauth/client/credentials_spec.rb +25 -25
- data/spec/lib/oauth/client_credentials/creator_spec.rb +89 -91
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +84 -86
- data/spec/lib/oauth/client_credentials/validation_spec.rb +72 -39
- data/spec/lib/oauth/client_credentials_integration_spec.rb +5 -5
- data/spec/lib/oauth/client_credentials_request_spec.rb +7 -10
- data/spec/lib/oauth/client_spec.rb +8 -8
- data/spec/lib/oauth/code_request_spec.rb +5 -5
- data/spec/lib/oauth/code_response_spec.rb +4 -4
- data/spec/lib/oauth/error_response_spec.rb +6 -5
- data/spec/lib/oauth/error_spec.rb +1 -1
- data/spec/lib/oauth/forbidden_token_response_spec.rb +2 -2
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +37 -37
- data/spec/lib/oauth/helpers/unique_token_spec.rb +2 -2
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +54 -54
- data/spec/lib/oauth/invalid_request_response_spec.rb +6 -6
- data/spec/lib/oauth/invalid_token_response_spec.rb +4 -4
- data/spec/lib/oauth/password_access_token_request_spec.rb +10 -9
- data/spec/lib/oauth/pre_authorization_spec.rb +20 -8
- data/spec/lib/oauth/refresh_token_request_spec.rb +10 -10
- data/spec/lib/oauth/scopes_spec.rb +14 -14
- data/spec/lib/oauth/token_request_spec.rb +9 -9
- data/spec/lib/oauth/token_response_spec.rb +5 -5
- data/spec/lib/oauth/token_spec.rb +5 -5
- data/spec/lib/option_spec.rb +1 -1
- data/spec/lib/request/strategy_spec.rb +34 -37
- data/spec/lib/secret_storing/base_spec.rb +3 -2
- data/spec/lib/secret_storing/bcrypt_spec.rb +2 -1
- data/spec/lib/secret_storing/plain_spec.rb +2 -1
- data/spec/lib/secret_storing/sha256_hash_spec.rb +2 -1
- data/spec/models/doorkeeper/access_grant_spec.rb +7 -9
- data/spec/models/doorkeeper/access_token_spec.rb +20 -26
- data/spec/models/doorkeeper/application_spec.rb +83 -26
- data/spec/requests/applications/applications_request_spec.rb +91 -93
- data/spec/requests/applications/authorized_applications_spec.rb +0 -0
- data/spec/requests/endpoints/authorization_spec.rb +1 -1
- data/spec/requests/endpoints/token_spec.rb +22 -16
- data/spec/requests/flows/authorization_code_errors_spec.rb +12 -8
- data/spec/requests/flows/authorization_code_spec.rb +108 -79
- data/spec/requests/flows/client_credentials_spec.rb +57 -45
- data/spec/requests/flows/implicit_grant_errors_spec.rb +0 -0
- data/spec/requests/flows/implicit_grant_spec.rb +4 -4
- data/spec/requests/flows/password_spec.rb +253 -213
- data/spec/requests/flows/refresh_token_spec.rb +53 -39
- data/spec/requests/flows/revoke_token_spec.rb +24 -24
- data/spec/requests/flows/skip_authorization_spec.rb +1 -1
- data/spec/requests/protected_resources/metal_spec.rb +2 -2
- data/spec/requests/protected_resources/private_api_spec.rb +0 -0
- data/spec/routing/custom_controller_routes_spec.rb +1 -1
- data/spec/routing/default_routes_spec.rb +1 -1
- data/spec/routing/scoped_routes_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -0
- data/spec/spec_helper_integration.rb +0 -0
- data/spec/support/dependencies/factory_bot.rb +0 -0
- data/spec/support/doorkeeper_rspec.rb +0 -0
- data/spec/support/helpers/access_token_request_helper.rb +0 -0
- data/spec/support/helpers/authorization_request_helper.rb +0 -0
- data/spec/support/helpers/config_helper.rb +0 -0
- data/spec/support/helpers/model_helper.rb +0 -0
- data/spec/support/helpers/request_spec_helper.rb +1 -13
- data/spec/support/helpers/url_helper.rb +2 -2
- data/spec/support/orm/active_record.rb +0 -0
- data/spec/support/orm/mongoid4.rb +1 -1
- data/spec/support/orm/mongoid5.rb +1 -1
- data/spec/support/orm/mongoid6.rb +1 -1
- data/spec/support/orm/mongoid7.rb +1 -1
- data/spec/support/shared/controllers_shared_context.rb +5 -38
- data/spec/support/shared/hashing_shared_context.rb +4 -0
- data/spec/support/shared/models_shared_examples.rb +6 -6
- metadata +154 -167
- data/spec/dummy/log/test.log +0 -6108
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper::AuthorizationsController
|
5
|
+
RSpec.describe Doorkeeper::AuthorizationsController do
|
6
6
|
include AuthorizationRequestHelper
|
7
7
|
|
8
8
|
class ActionDispatch::TestResponse
|
@@ -14,8 +14,8 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
let(:client)
|
18
|
-
let(:user)
|
17
|
+
let(:client) { FactoryBot.create :application }
|
18
|
+
let(:user) { User.create!(name: "Joe", password: "sekret") }
|
19
19
|
|
20
20
|
let(:access_token) do
|
21
21
|
FactoryBot.build :access_token,
|
@@ -27,6 +27,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
27
27
|
|
28
28
|
before do
|
29
29
|
Doorkeeper.configure do
|
30
|
+
orm DOORKEEPER_ORM
|
30
31
|
default_scopes :default
|
31
32
|
|
32
33
|
custom_access_token_expires_in(lambda do |context|
|
@@ -37,7 +38,6 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
37
38
|
allow(Doorkeeper.config).to receive(:grant_flows).and_return(["implicit"])
|
38
39
|
allow(Doorkeeper.config).to receive(:authenticate_resource_owner).and_return(->(_) { authenticator_method })
|
39
40
|
allow(controller).to receive(:authenticator_method).and_return(user)
|
40
|
-
expect(controller).to receive(:authenticator_method).at_most(:once)
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "POST #create" do
|
@@ -47,6 +47,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
47
47
|
|
48
48
|
it "redirects after authorization" do
|
49
49
|
expect(response).to be_redirect
|
50
|
+
expect(controller).to receive(:authenticator_method).at_most(:once)
|
50
51
|
end
|
51
52
|
|
52
53
|
it "redirects to client redirect uri" do
|
@@ -311,7 +312,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
311
312
|
end
|
312
313
|
|
313
314
|
it "includes error description in redirect uri" do
|
314
|
-
expect(redirect_uri.match(/error_description=(.+)&?/)[1]).
|
315
|
+
expect(redirect_uri.match(/error_description=(.+)&?/)[1]).not_to be_nil
|
315
316
|
end
|
316
317
|
|
317
318
|
it "does not issue any access token" do
|
@@ -356,13 +357,13 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
356
357
|
}
|
357
358
|
end
|
358
359
|
|
359
|
-
it "
|
360
|
+
it "calls :before_successful_authorization callback" do
|
360
361
|
expect(Doorkeeper.config)
|
361
362
|
.to receive_message_chain(:before_successful_authorization, :call)
|
362
363
|
.with(instance_of(described_class), instance_of(Doorkeeper::OAuth::Hooks::Context))
|
363
364
|
end
|
364
365
|
|
365
|
-
it "
|
366
|
+
it "calls :after_successful_authorization callback" do
|
366
367
|
expect(Doorkeeper.config)
|
367
368
|
.to receive_message_chain(:after_successful_authorization, :call)
|
368
369
|
.with(instance_of(described_class), instance_of(Doorkeeper::OAuth::Hooks::Context))
|
@@ -374,11 +375,11 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
374
375
|
post :create, params: { client_id: client.uid, response_type: "token", redirect_uri: "bad_uri" }
|
375
376
|
end
|
376
377
|
|
377
|
-
it "
|
378
|
+
it "does not call :before_successful_authorization callback" do
|
378
379
|
expect(Doorkeeper.config).not_to receive(:before_successful_authorization)
|
379
380
|
end
|
380
381
|
|
381
|
-
it "
|
382
|
+
it "does not call :after_successful_authorization callback" do
|
382
383
|
expect(Doorkeeper.config).not_to receive(:after_successful_authorization)
|
383
384
|
end
|
384
385
|
end
|
@@ -399,16 +400,16 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
399
400
|
}
|
400
401
|
end
|
401
402
|
|
402
|
-
it "
|
403
|
+
it "redirects immediately" do
|
403
404
|
expect(response).to be_redirect
|
404
405
|
expect(response.location).to match(%r{/oauth/token/info\?access_token=})
|
405
406
|
end
|
406
407
|
|
407
|
-
it "
|
408
|
+
it "does not issue a grant" do
|
408
409
|
expect(Doorkeeper::AccessGrant.count).to be 0
|
409
410
|
end
|
410
411
|
|
411
|
-
it "
|
412
|
+
it "issues a token" do
|
412
413
|
expect(Doorkeeper::AccessToken.count).to be 1
|
413
414
|
end
|
414
415
|
end
|
@@ -429,17 +430,17 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
429
430
|
}
|
430
431
|
end
|
431
432
|
|
432
|
-
it "
|
433
|
+
it "redirects immediately" do
|
433
434
|
expect(response).to be_redirect
|
434
435
|
expect(response.location)
|
435
436
|
.to match(%r{/oauth/authorize/native\?code=#{Doorkeeper::AccessGrant.first.token}})
|
436
437
|
end
|
437
438
|
|
438
|
-
it "
|
439
|
+
it "issues a grant" do
|
439
440
|
expect(Doorkeeper::AccessGrant.count).to be 1
|
440
441
|
end
|
441
442
|
|
442
|
-
it "
|
443
|
+
it "does not issue a token" do
|
443
444
|
expect(Doorkeeper::AccessToken.count).to be 0
|
444
445
|
end
|
445
446
|
end
|
@@ -457,12 +458,12 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
457
458
|
}
|
458
459
|
end
|
459
460
|
|
460
|
-
it "
|
461
|
+
it "redirects immediately" do
|
461
462
|
expect(response).to be_redirect
|
462
463
|
expect(response.location).to match(/^#{client.redirect_uri}/)
|
463
464
|
end
|
464
465
|
|
465
|
-
it "
|
466
|
+
it "issues a token" do
|
466
467
|
expect(Doorkeeper::AccessToken.count).to be 1
|
467
468
|
end
|
468
469
|
|
@@ -494,7 +495,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
494
495
|
}
|
495
496
|
end
|
496
497
|
|
497
|
-
it "
|
498
|
+
it "renders success" do
|
498
499
|
expect(response).to be_successful
|
499
500
|
end
|
500
501
|
|
@@ -523,11 +524,11 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
523
524
|
}
|
524
525
|
end
|
525
526
|
|
526
|
-
it "
|
527
|
+
it "renders success" do
|
527
528
|
expect(response).to be_successful
|
528
529
|
end
|
529
530
|
|
530
|
-
it "
|
531
|
+
it "issues a token" do
|
531
532
|
expect(Doorkeeper::AccessToken.count).to be 1
|
532
533
|
end
|
533
534
|
|
@@ -537,7 +538,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
537
538
|
|
538
539
|
it "sets redirect_uri to correct value" do
|
539
540
|
redirect_uri = JSON.parse(response.body)["redirect_uri"]
|
540
|
-
expect(redirect_uri).
|
541
|
+
expect(redirect_uri).not_to be_nil
|
541
542
|
expect(redirect_uri.match(/token_type=(\w+)&?/)[1]).to eq "Bearer"
|
542
543
|
expect(redirect_uri.match(/expires_in=(\d+)&?/)[1].to_i).to eq 1234
|
543
544
|
expect(
|
@@ -562,7 +563,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
562
563
|
end
|
563
564
|
|
564
565
|
it "does not redirect" do
|
565
|
-
expect(response).
|
566
|
+
expect(response).not_to be_redirect
|
566
567
|
end
|
567
568
|
|
568
569
|
it "does not issue any token" do
|
@@ -583,7 +584,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
583
584
|
end
|
584
585
|
|
585
586
|
it "does not redirect" do
|
586
|
-
expect(response).
|
587
|
+
expect(response).not_to be_redirect
|
587
588
|
end
|
588
589
|
|
589
590
|
it "does not issue any token" do
|
@@ -606,7 +607,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
606
607
|
|
607
608
|
let(:response_json_body) { JSON.parse(response.body) }
|
608
609
|
|
609
|
-
it "
|
610
|
+
it "renders bad request" do
|
610
611
|
expect(response).to have_http_status(:bad_request)
|
611
612
|
end
|
612
613
|
|
@@ -638,7 +639,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
638
639
|
|
639
640
|
let(:response_json_body) { JSON.parse(response.body) }
|
640
641
|
|
641
|
-
it "
|
642
|
+
it "renders bad request" do
|
642
643
|
expect(response).to have_http_status(:bad_request)
|
643
644
|
end
|
644
645
|
|
@@ -669,13 +670,13 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
669
670
|
allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc { true })
|
670
671
|
end
|
671
672
|
|
672
|
-
it "
|
673
|
+
it "calls :before_successful_authorization callback" do
|
673
674
|
expect(Doorkeeper.configuration)
|
674
675
|
.to receive_message_chain(:before_successful_authorization, :call)
|
675
676
|
.with(instance_of(described_class), instance_of(Doorkeeper::OAuth::Hooks::Context))
|
676
677
|
end
|
677
678
|
|
678
|
-
it "
|
679
|
+
it "calls :after_successful_authorization callback" do
|
679
680
|
expect(Doorkeeper.configuration)
|
680
681
|
.to receive_message_chain(:after_successful_authorization, :call)
|
681
682
|
.with(instance_of(described_class), instance_of(Doorkeeper::OAuth::Hooks::Context))
|
@@ -687,11 +688,11 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
687
688
|
allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc { false })
|
688
689
|
end
|
689
690
|
|
690
|
-
it "
|
691
|
+
it "does not call :before_successful_authorization callback" do
|
691
692
|
expect(Doorkeeper.configuration).not_to receive(:before_successful_authorization)
|
692
693
|
end
|
693
694
|
|
694
|
-
it "
|
695
|
+
it "does not call :after_successful_authorization callback" do
|
695
696
|
expect(Doorkeeper.configuration).not_to receive(:after_successful_authorization)
|
696
697
|
end
|
697
698
|
end
|
@@ -702,11 +703,11 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
702
703
|
allow(Doorkeeper.configuration).to receive(:api_only).and_return(true)
|
703
704
|
end
|
704
705
|
|
705
|
-
it "
|
706
|
+
it "does not call :before_successful_authorization callback" do
|
706
707
|
expect(Doorkeeper.configuration).not_to receive(:before_successful_authorization)
|
707
708
|
end
|
708
709
|
|
709
|
-
it "
|
710
|
+
it "does not call :after_successful_authorization callback" do
|
710
711
|
expect(Doorkeeper.configuration).not_to receive(:after_successful_authorization)
|
711
712
|
end
|
712
713
|
end
|
@@ -16,8 +16,8 @@ module ControllerActions
|
|
16
16
|
def doorkeeper_forbidden_render_options(*); end
|
17
17
|
end
|
18
18
|
|
19
|
-
describe "doorkeeper authorize filter" do
|
20
|
-
context "accepts token code specified as" do
|
19
|
+
RSpec.describe "doorkeeper authorize filter" do
|
20
|
+
context "when accepts token code specified as" do
|
21
21
|
controller do
|
22
22
|
before_action :doorkeeper_authorize!
|
23
23
|
|
@@ -58,7 +58,7 @@ describe "doorkeeper authorize filter" do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "does not change Authorization header value" do
|
61
|
-
expect(Doorkeeper::AccessToken).to receive(:by_token).
|
61
|
+
expect(Doorkeeper::AccessToken).to receive(:by_token).twice.and_return(token)
|
62
62
|
request.env["HTTP_AUTHORIZATION"] = "Bearer #{token_string}"
|
63
63
|
get :index
|
64
64
|
controller.send(:remove_instance_variable, :@doorkeeper_token)
|
@@ -66,7 +66,7 @@ describe "doorkeeper authorize filter" do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
context "defined for all actions" do
|
69
|
+
context "when defined for all actions" do
|
70
70
|
controller do
|
71
71
|
before_action :doorkeeper_authorize!
|
72
72
|
|
@@ -100,7 +100,7 @@ describe "doorkeeper authorize filter" do
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
context "defined with scopes" do
|
103
|
+
context "when defined with scopes" do
|
104
104
|
controller do
|
105
105
|
before_action -> { doorkeeper_authorize! :write }
|
106
106
|
|
@@ -139,7 +139,7 @@ describe "doorkeeper authorize filter" do
|
|
139
139
|
|
140
140
|
get :index, params: { access_token: token_string }
|
141
141
|
expect(response.status).to eq 403
|
142
|
-
expect(response.header).
|
142
|
+
expect(response.header).not_to include("WWW-Authenticate")
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
@@ -169,7 +169,7 @@ describe "doorkeeper authorize filter" do
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
-
it "
|
172
|
+
it "renders a custom JSON response", token: :invalid do
|
173
173
|
get :index, params: { access_token: token_string }
|
174
174
|
expect(response.status).to eq 401
|
175
175
|
expect(response.content_type).to include("application/json")
|
@@ -199,7 +199,7 @@ describe "doorkeeper authorize filter" do
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
-
it "
|
202
|
+
it "renders a custom text response", token: :invalid do
|
203
203
|
get :index, params: { access_token: token_string }
|
204
204
|
expect(response.status).to eq 401
|
205
205
|
expect(response.content_type).to include("text/plain")
|
@@ -253,7 +253,7 @@ describe "doorkeeper authorize filter" do
|
|
253
253
|
|
254
254
|
it "renders a custom JSON response" do
|
255
255
|
get :index, params: { access_token: token_string }
|
256
|
-
expect(response.header).
|
256
|
+
expect(response.header).not_to include("WWW-Authenticate")
|
257
257
|
expect(response.content_type).to include("application/json")
|
258
258
|
expect(response.status).to eq 403
|
259
259
|
|
@@ -292,7 +292,7 @@ describe "doorkeeper authorize filter" do
|
|
292
292
|
|
293
293
|
it "renders a custom status code and text response" do
|
294
294
|
get :index, params: { access_token: token_string }
|
295
|
-
expect(response.header).
|
295
|
+
expect(response.header).not_to include("WWW-Authenticate")
|
296
296
|
expect(response.status).to eq 403
|
297
297
|
expect(response.body).to eq("Forbidden")
|
298
298
|
end
|