doorkeeper-mongodb 5.2.1 → 5.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/doorkeeper-mongodb.rb +1 -0
- data/lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb +1 -0
- data/lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb +1 -0
- data/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb +76 -0
- 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/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/log/test.log +4220 -4184
- data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/{eS/eSL1QMz46gKLM0GR6S9fL6uyARPxOImcappZ9_ZtSyg.cache → Pm/PmheG0PGFqDws1qgFOxOyIL-gpMof3Ar9eSRKVLYuik.cache} +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/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_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/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/support/helpers/request_spec_helper.rb +1 -13
- data/spec/support/helpers/url_helper.rb +2 -2
- 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 +13 -10
File without changes
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper::DashboardHelper do
|
5
|
+
RSpec.describe Doorkeeper::DashboardHelper do
|
6
6
|
describe "#doorkeeper_errors_for" do
|
7
7
|
let(:object) { double errors: { method: messages } }
|
8
8
|
let(:messages) { ["first message", "second message"] }
|
data/spec/lib/config_spec.rb
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper
|
6
|
-
subject { Doorkeeper.config }
|
5
|
+
RSpec.describe Doorkeeper::Config do
|
6
|
+
subject(:config) { Doorkeeper.config }
|
7
7
|
|
8
8
|
describe "resource_owner_authenticator" do
|
9
9
|
it "sets the block that is accessible via authenticate_resource_owner" do
|
@@ -70,7 +70,7 @@ describe Doorkeeper, "configuration" do
|
|
70
70
|
describe "admin_authenticator" do
|
71
71
|
it "sets the block that is accessible via authenticate_admin" do
|
72
72
|
default_behaviour = "default behaviour"
|
73
|
-
allow(
|
73
|
+
allow(described_class).to receive(:head).and_return(default_behaviour)
|
74
74
|
|
75
75
|
Doorkeeper.configure do
|
76
76
|
orm DOORKEEPER_ORM
|
@@ -79,7 +79,7 @@ describe Doorkeeper, "configuration" do
|
|
79
79
|
expect(subject.authenticate_admin.call({})).to eq(default_behaviour)
|
80
80
|
end
|
81
81
|
|
82
|
-
it "
|
82
|
+
it "could be customized with a block" do
|
83
83
|
block = proc {}
|
84
84
|
Doorkeeper.configure do
|
85
85
|
orm DOORKEEPER_ORM
|
@@ -195,7 +195,7 @@ describe Doorkeeper, "configuration" do
|
|
195
195
|
expect(subject.token_grant_types).not_to include "refresh_token"
|
196
196
|
end
|
197
197
|
|
198
|
-
context "
|
198
|
+
context "when enabled" do
|
199
199
|
before do
|
200
200
|
Doorkeeper.configure do
|
201
201
|
orm DOORKEEPER_ORM
|
@@ -216,6 +216,7 @@ describe Doorkeeper, "configuration" do
|
|
216
216
|
|
217
217
|
it "can change the value" do
|
218
218
|
Doorkeeper.configure do
|
219
|
+
orm DOORKEEPER_ORM
|
219
220
|
token_reuse_limit 90
|
220
221
|
end
|
221
222
|
|
@@ -226,6 +227,7 @@ describe Doorkeeper, "configuration" do
|
|
226
227
|
expect(Rails.logger).to receive(:warn).with(/will be set to default 100/)
|
227
228
|
|
228
229
|
Doorkeeper.configure do
|
230
|
+
orm DOORKEEPER_ORM
|
229
231
|
reuse_access_token
|
230
232
|
token_reuse_limit 110
|
231
233
|
end
|
@@ -501,7 +503,7 @@ describe Doorkeeper, "configuration" do
|
|
501
503
|
end
|
502
504
|
|
503
505
|
describe "base_controller" do
|
504
|
-
context "default" do
|
506
|
+
context "when default value set" do
|
505
507
|
it { expect(Doorkeeper.configuration.base_controller).to be_an_instance_of(Proc) }
|
506
508
|
|
507
509
|
it "resolves to a ApplicationController::Base in default mode" do
|
@@ -511,6 +513,7 @@ describe Doorkeeper, "configuration" do
|
|
511
513
|
|
512
514
|
it "resolves to a ApplicationController::API in api_only mode" do
|
513
515
|
Doorkeeper.configure do
|
516
|
+
orm DOORKEEPER_ORM
|
514
517
|
api_only
|
515
518
|
end
|
516
519
|
|
@@ -519,7 +522,7 @@ describe Doorkeeper, "configuration" do
|
|
519
522
|
end
|
520
523
|
end
|
521
524
|
|
522
|
-
context "custom" do
|
525
|
+
context "when custom value set" do
|
523
526
|
before do
|
524
527
|
Doorkeeper.configure do
|
525
528
|
orm DOORKEEPER_ORM
|
@@ -532,11 +535,11 @@ describe Doorkeeper, "configuration" do
|
|
532
535
|
end
|
533
536
|
|
534
537
|
describe "base_metal_controller" do
|
535
|
-
context "default" do
|
538
|
+
context "when default value set" do
|
536
539
|
it { expect(Doorkeeper.config.base_metal_controller).to eq("ActionController::API") }
|
537
540
|
end
|
538
541
|
|
539
|
-
context "custom" do
|
542
|
+
context "when custom value set" do
|
540
543
|
before do
|
541
544
|
Doorkeeper.configure do
|
542
545
|
orm DOORKEEPER_ORM
|
@@ -561,9 +564,7 @@ describe Doorkeeper, "configuration" do
|
|
561
564
|
end
|
562
565
|
|
563
566
|
it "establishes connection for Doorkeeper models based on options" do
|
564
|
-
models.
|
565
|
-
expect(model).to receive(:establish_connection)
|
566
|
-
end
|
567
|
+
expect(models).to all(receive(:establish_connection))
|
567
568
|
|
568
569
|
expect(Kernel).to receive(:warn).with(
|
569
570
|
/\[DOORKEEPER\] active_record_options has been deprecated and will soon be removed/,
|
@@ -679,6 +680,7 @@ describe Doorkeeper, "configuration" do
|
|
679
680
|
it "is set to render by default" do
|
680
681
|
expect(Doorkeeper.config.handle_auth_errors).to eq(:render)
|
681
682
|
end
|
683
|
+
|
682
684
|
it "can change the value" do
|
683
685
|
Doorkeeper.configure do
|
684
686
|
orm DOORKEEPER_ORM
|
@@ -697,6 +699,7 @@ describe Doorkeeper, "configuration" do
|
|
697
699
|
context "when provided" do
|
698
700
|
before do
|
699
701
|
Doorkeeper.configure do
|
702
|
+
orm DOORKEEPER_ORM
|
700
703
|
hash_token_secrets
|
701
704
|
end
|
702
705
|
end
|
@@ -711,6 +714,7 @@ describe Doorkeeper, "configuration" do
|
|
711
714
|
it "raises an exception" do
|
712
715
|
expect do
|
713
716
|
Doorkeeper.configure do
|
717
|
+
orm DOORKEEPER_ORM
|
714
718
|
hash_token_secrets using: "does not exist"
|
715
719
|
end
|
716
720
|
end.to raise_error(NameError)
|
@@ -721,6 +725,7 @@ describe Doorkeeper, "configuration" do
|
|
721
725
|
it "raises an exception" do
|
722
726
|
expect do
|
723
727
|
Doorkeeper.configure do
|
728
|
+
orm DOORKEEPER_ORM
|
724
729
|
hash_token_secrets using: "Doorkeeper::SecretStoring::BCrypt"
|
725
730
|
end
|
726
731
|
end.to raise_error(
|
@@ -733,6 +738,7 @@ describe Doorkeeper, "configuration" do
|
|
733
738
|
context "when provided with fallback" do
|
734
739
|
before do
|
735
740
|
Doorkeeper.configure do
|
741
|
+
orm DOORKEEPER_ORM
|
736
742
|
hash_token_secrets fallback: :plain
|
737
743
|
end
|
738
744
|
end
|
@@ -748,6 +754,7 @@ describe Doorkeeper, "configuration" do
|
|
748
754
|
expect(Rails.logger).to receive(:warn).with(/reuse_access_token will be disabled/)
|
749
755
|
|
750
756
|
Doorkeeper.configure do
|
757
|
+
orm DOORKEEPER_ORM
|
751
758
|
reuse_access_token
|
752
759
|
hash_token_secrets
|
753
760
|
end
|
@@ -766,6 +773,7 @@ describe Doorkeeper, "configuration" do
|
|
766
773
|
context "when provided" do
|
767
774
|
before do
|
768
775
|
Doorkeeper.configure do
|
776
|
+
orm DOORKEEPER_ORM
|
769
777
|
hash_application_secrets
|
770
778
|
end
|
771
779
|
end
|
@@ -780,6 +788,7 @@ describe Doorkeeper, "configuration" do
|
|
780
788
|
it "raises an exception" do
|
781
789
|
expect do
|
782
790
|
Doorkeeper.configure do
|
791
|
+
orm DOORKEEPER_ORM
|
783
792
|
hash_application_secrets using: "does not exist"
|
784
793
|
end
|
785
794
|
end.to raise_error(NameError)
|
@@ -789,6 +798,7 @@ describe Doorkeeper, "configuration" do
|
|
789
798
|
context "when provided with fallback" do
|
790
799
|
before do
|
791
800
|
Doorkeeper.configure do
|
801
|
+
orm DOORKEEPER_ORM
|
792
802
|
hash_application_secrets fallback: :plain
|
793
803
|
end
|
794
804
|
end
|
@@ -806,6 +816,7 @@ describe Doorkeeper, "configuration" do
|
|
806
816
|
"[DOORKEEPER] native_redirect_uri has been deprecated and will soon be removed",
|
807
817
|
)
|
808
818
|
Doorkeeper.configure do
|
819
|
+
orm DOORKEEPER_ORM
|
809
820
|
native_redirect_uri "urn:ietf:wg:oauth:2.0:oob"
|
810
821
|
end
|
811
822
|
end
|
data/spec/lib/doorkeeper_spec.rb
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper do
|
5
|
+
RSpec.describe Doorkeeper do
|
6
6
|
describe "#authenticate" do
|
7
7
|
let(:request) { double }
|
8
8
|
|
9
9
|
it "calls OAuth::Token#authenticate" do
|
10
|
-
token_strategies =
|
10
|
+
token_strategies = described_class.config.access_token_methods
|
11
11
|
|
12
12
|
expect(Doorkeeper::OAuth::Token).to receive(:authenticate)
|
13
13
|
.with(request, *token_strategies)
|
14
14
|
|
15
|
-
|
15
|
+
described_class.authenticate(request)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "accepts custom token strategies" do
|
@@ -21,7 +21,7 @@ describe Doorkeeper do
|
|
21
21
|
expect(Doorkeeper::OAuth::Token).to receive(:authenticate)
|
22
22
|
.with(request, *token_strategies)
|
23
23
|
|
24
|
-
|
24
|
+
described_class.authenticate(request, token_strategies)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
RSpec.describe Doorkeeper::Models::Expirable do
|
6
6
|
subject do
|
7
7
|
Class.new do
|
8
8
|
include Doorkeeper::Models::Expirable
|
@@ -13,7 +13,7 @@ describe "Expirable" do
|
|
13
13
|
allow(subject).to receive(:created_at).and_return(1.minute.ago)
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe "#expired?" do
|
17
17
|
it "is not expired if time has not passed" do
|
18
18
|
allow(subject).to receive(:expires_in).and_return(2.minutes)
|
19
19
|
expect(subject).not_to be_expired
|
@@ -30,30 +30,30 @@ describe "Expirable" do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
describe
|
34
|
-
it "
|
33
|
+
describe "#expires_in_seconds" do
|
34
|
+
it "returns the amount of time remaining until the token is expired" do
|
35
35
|
allow(subject).to receive(:expires_in).and_return(2.minutes)
|
36
36
|
expect(subject.expires_in_seconds).to eq(60)
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
39
|
+
it "returns 0 when expired" do
|
40
40
|
allow(subject).to receive(:expires_in).and_return(30.seconds)
|
41
41
|
expect(subject.expires_in_seconds).to eq(0)
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "returns nil when expires_in is nil" do
|
45
45
|
allow(subject).to receive(:expires_in).and_return(nil)
|
46
46
|
expect(subject.expires_in_seconds).to be_nil
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
51
|
-
it "
|
50
|
+
describe "#expires_at" do
|
51
|
+
it "returns the expiration time of the token" do
|
52
52
|
allow(subject).to receive(:expires_in).and_return(2.minutes)
|
53
53
|
expect(subject.expires_at).to be_a(Time)
|
54
54
|
end
|
55
55
|
|
56
|
-
it "
|
56
|
+
it "returns nil when expires_in is nil" do
|
57
57
|
allow(subject).to receive(:expires_in).and_return(nil)
|
58
58
|
expect(subject.expires_at).to be_nil
|
59
59
|
end
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
RSpec.describe Doorkeeper::Models::Reusable do
|
6
6
|
subject do
|
7
7
|
Class.new do
|
8
8
|
include Doorkeeper::Models::Reusable
|
9
9
|
end.new
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe "#reusable?" do
|
13
13
|
it "is reusable if its expires_in is nil" do
|
14
14
|
allow(subject).to receive(:expired?).and_return(false)
|
15
15
|
allow(subject).to receive(:expires_in).and_return(nil)
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
RSpec.describe Doorkeeper::Models::Revocable do
|
6
6
|
subject do
|
7
7
|
Class.new do
|
8
8
|
include Doorkeeper::Models::Revocable
|
9
9
|
end.new
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe "#revoke" do
|
13
13
|
it "updates :revoked_at attribute with current time" do
|
14
14
|
utc = double utc: double
|
15
15
|
clock = double now: utc
|
@@ -18,7 +18,7 @@ describe "Revocable" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
21
|
+
describe "#revoked?" do
|
22
22
|
it "is revoked if :revoked_at has passed" do
|
23
23
|
allow(subject).to receive(:revoked_at).and_return(Time.now.utc - 1000)
|
24
24
|
expect(subject).to be_revoked
|
@@ -35,7 +35,7 @@ describe "Revocable" do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
38
|
+
describe "#revoke_previous_refresh_token!" do
|
39
39
|
it "revokes the previous token if exists and resets the `previous_refresh_token` attribute" do
|
40
40
|
previous_token = FactoryBot.create(
|
41
41
|
:access_token,
|
@@ -46,9 +46,6 @@ describe "Revocable" do
|
|
46
46
|
previous_refresh_token: previous_token.refresh_token,
|
47
47
|
)
|
48
48
|
|
49
|
-
expect_any_instance_of(
|
50
|
-
Doorkeeper::AccessToken,
|
51
|
-
).to receive(:revoke).and_call_original
|
52
49
|
current_token.revoke_previous_refresh_token!
|
53
50
|
|
54
51
|
expect(current_token.previous_refresh_token).to be_empty
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
RSpec.describe Doorkeeper::Models::Scopes do
|
6
6
|
subject do
|
7
7
|
Class.new(Struct.new(:scopes)) do
|
8
8
|
include Doorkeeper::Models::Scopes
|
@@ -13,7 +13,7 @@ describe "Doorkeeper::Models::Scopes" do
|
|
13
13
|
subject[:scopes] = "public admin"
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe "#scopes" do
|
17
17
|
it "is a `Scopes` class" do
|
18
18
|
expect(subject.scopes).to be_a(Doorkeeper::OAuth::Scopes)
|
19
19
|
end
|
@@ -23,7 +23,7 @@ describe "Doorkeeper::Models::Scopes" do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
26
|
+
describe "#scopes=" do
|
27
27
|
it "accepts String" do
|
28
28
|
subject.scopes = "private admin"
|
29
29
|
expect(subject.scopes_string).to eq("private admin")
|
@@ -43,18 +43,18 @@ describe "Doorkeeper::Models::Scopes" do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe
|
46
|
+
describe "#scopes_string" do
|
47
47
|
it "is a `Scopes` class" do
|
48
48
|
expect(subject.scopes_string).to eq("public admin")
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe
|
53
|
-
it "
|
52
|
+
describe "#includes_scope?" do
|
53
|
+
it "returns true if at least one scope is included" do
|
54
54
|
expect(subject.includes_scope?("public", "private")).to be true
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
57
|
+
it "returns false if no scopes are included" do
|
58
58
|
expect(subject.includes_scope?("teacher", "student")).to be false
|
59
59
|
end
|
60
60
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe
|
5
|
+
RSpec.describe Doorkeeper::Models::SecretStorable do
|
6
6
|
let(:clazz) do
|
7
7
|
Class.new do
|
8
8
|
include Doorkeeper::Models::SecretStorable
|
@@ -22,7 +22,7 @@ describe "SecretStorable" do
|
|
22
22
|
end
|
23
23
|
let(:strategy) { clazz.secret_strategy }
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe ".find_by_plaintext_token" do
|
26
26
|
subject { clazz.send(:find_by_plaintext_token, "attr", "input") }
|
27
27
|
|
28
28
|
it "forwards to the secret_strategy" do
|
@@ -54,8 +54,9 @@ describe "SecretStorable" do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
describe
|
57
|
+
describe ".find_by_fallback_token" do
|
58
58
|
subject { clazz.send(:find_by_fallback_token, "attr", "input") }
|
59
|
+
|
59
60
|
let(:fallback) { double(::Doorkeeper::SecretStoring::Plain) }
|
60
61
|
|
61
62
|
it "returns nil if none defined" do
|
@@ -63,12 +64,12 @@ describe "SecretStorable" do
|
|
63
64
|
expect(subject).to eq nil
|
64
65
|
end
|
65
66
|
|
66
|
-
context "
|
67
|
+
context "when a fallback strategy is defined" do
|
67
68
|
before do
|
68
69
|
allow(clazz).to receive(:fallback_secret_strategy).and_return(fallback)
|
69
70
|
end
|
70
71
|
|
71
|
-
context "
|
72
|
+
context "when resource is defined" do
|
72
73
|
let(:resource) { double("Token model") }
|
73
74
|
|
74
75
|
it "calls the strategy for lookup" do
|
@@ -98,7 +99,7 @@ describe "SecretStorable" do
|
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
101
|
-
context "
|
102
|
+
context "when resource is not defined" do
|
102
103
|
before do
|
103
104
|
allow(clazz).to receive(:fallback_secret_strategy).and_return(fallback)
|
104
105
|
end
|
@@ -121,13 +122,13 @@ describe "SecretStorable" do
|
|
121
122
|
end
|
122
123
|
end
|
123
124
|
|
124
|
-
describe
|
125
|
+
describe ".secret_strategy" do
|
125
126
|
it "defaults to plain strategy" do
|
126
127
|
expect(strategy).to eq Doorkeeper::SecretStoring::Plain
|
127
128
|
end
|
128
129
|
end
|
129
130
|
|
130
|
-
describe
|
131
|
+
describe ".fallback_secret_strategy" do
|
131
132
|
it "defaults to nil" do
|
132
133
|
expect(clazz.fallback_secret_strategy).to eq nil
|
133
134
|
end
|