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
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper::OAuth::InvalidRequestResponse do
|
5
|
+
RSpec.describe Doorkeeper::OAuth::InvalidRequestResponse do
|
6
6
|
describe "#name" do
|
7
7
|
it { expect(subject.name).to eq(:invalid_request) }
|
8
8
|
end
|
@@ -14,7 +14,7 @@ describe Doorkeeper::OAuth::InvalidRequestResponse do
|
|
14
14
|
describe ".from_request" do
|
15
15
|
let(:response) { described_class.from_request(request) }
|
16
16
|
|
17
|
-
context "
|
17
|
+
context "when param missed" do
|
18
18
|
let(:request) { double(missing_param: "some_param") }
|
19
19
|
|
20
20
|
it "sets a description" do
|
@@ -28,7 +28,7 @@ describe Doorkeeper::OAuth::InvalidRequestResponse do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
context "server doesn't
|
31
|
+
context "when server doesn't support PKCE" do
|
32
32
|
let(:request) { double(invalid_request_reason: :not_support_pkce) }
|
33
33
|
|
34
34
|
it "sets a description" do
|
@@ -42,7 +42,7 @@ describe Doorkeeper::OAuth::InvalidRequestResponse do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
context "request is not authorized" do
|
45
|
+
context "when request is not authorized" do
|
46
46
|
let(:request) { double(invalid_request_reason: :request_not_authorized) }
|
47
47
|
|
48
48
|
it "sets a description" do
|
@@ -56,7 +56,7 @@ describe Doorkeeper::OAuth::InvalidRequestResponse do
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
context "unknown reason" do
|
59
|
+
context "when unknown reason" do
|
60
60
|
let(:request) { double(invalid_request_reason: :unknown_reason) }
|
61
61
|
|
62
62
|
it "sets a description" do
|
@@ -65,7 +65,7 @@ describe Doorkeeper::OAuth::InvalidRequestResponse do
|
|
65
65
|
)
|
66
66
|
end
|
67
67
|
|
68
|
-
it "
|
68
|
+
it "sets the reason to unknown" do
|
69
69
|
expect(response.reason).to eq(:unknown_reason)
|
70
70
|
end
|
71
71
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper::OAuth::InvalidTokenResponse do
|
5
|
+
RSpec.describe Doorkeeper::OAuth::InvalidTokenResponse do
|
6
6
|
describe "#name" do
|
7
7
|
it { expect(subject.name).to eq(:invalid_token) }
|
8
8
|
end
|
@@ -14,7 +14,7 @@ describe Doorkeeper::OAuth::InvalidTokenResponse do
|
|
14
14
|
describe ".from_access_token" do
|
15
15
|
let(:response) { described_class.from_access_token(access_token) }
|
16
16
|
|
17
|
-
context "revoked" do
|
17
|
+
context "when token revoked" do
|
18
18
|
let(:access_token) { double(revoked?: true, expired?: true) }
|
19
19
|
|
20
20
|
it "sets a description" do
|
@@ -26,7 +26,7 @@ describe Doorkeeper::OAuth::InvalidTokenResponse do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
context "expired" do
|
29
|
+
context "when token expired" do
|
30
30
|
let(:access_token) { double(revoked?: false, expired?: true) }
|
31
31
|
|
32
32
|
it "sets a description" do
|
@@ -38,7 +38,7 @@ describe Doorkeeper::OAuth::InvalidTokenResponse do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
context "unknown" do
|
41
|
+
context "when unknown" do
|
42
42
|
let(:access_token) { double(revoked?: false, expired?: false) }
|
43
43
|
|
44
44
|
it "sets a description" do
|
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper::OAuth::PasswordAccessTokenRequest do
|
5
|
+
RSpec.describe Doorkeeper::OAuth::PasswordAccessTokenRequest do
|
6
|
+
subject do
|
7
|
+
described_class.new(server, client, owner)
|
8
|
+
end
|
9
|
+
|
6
10
|
let(:server) do
|
7
11
|
double(
|
8
12
|
:server,
|
@@ -14,23 +18,20 @@ describe Doorkeeper::OAuth::PasswordAccessTokenRequest do
|
|
14
18
|
},
|
15
19
|
)
|
16
20
|
end
|
17
|
-
let(:client) { FactoryBot.create(:application) }
|
18
|
-
let(:
|
21
|
+
let(:client) { Doorkeeper::OAuth::Client.new(FactoryBot.create(:application)) }
|
22
|
+
let(:application) { client.application }
|
23
|
+
let(:owner) { FactoryBot.build_stubbed(:resource_owner) }
|
19
24
|
|
20
25
|
before do
|
21
26
|
allow(server).to receive(:option_defined?).with(:custom_access_token_expires_in).and_return(true)
|
22
27
|
end
|
23
28
|
|
24
|
-
subject do
|
25
|
-
described_class.new(server, client, owner)
|
26
|
-
end
|
27
|
-
|
28
29
|
it "issues a new token for the client" do
|
29
30
|
expect do
|
30
31
|
subject.authorize
|
31
|
-
end.to change {
|
32
|
+
end.to change { application.reload.access_tokens.count }.by(1)
|
32
33
|
|
33
|
-
expect(
|
34
|
+
expect(application.reload.access_tokens.max_by(&:created_at).expires_in).to eq(1234)
|
34
35
|
end
|
35
36
|
|
36
37
|
it "issues a new token without a client" do
|
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper::OAuth::PreAuthorization do
|
5
|
+
RSpec.describe Doorkeeper::OAuth::PreAuthorization do
|
6
|
+
subject do
|
7
|
+
described_class.new(server, attributes)
|
8
|
+
end
|
9
|
+
|
6
10
|
let(:server) do
|
7
11
|
server = Doorkeeper.configuration
|
8
12
|
allow(server).to receive(:default_scopes).and_return(Doorkeeper::OAuth::Scopes.from_string("default"))
|
@@ -23,10 +27,6 @@ describe Doorkeeper::OAuth::PreAuthorization do
|
|
23
27
|
}
|
24
28
|
end
|
25
29
|
|
26
|
-
subject do
|
27
|
-
described_class.new(server, attributes)
|
28
|
-
end
|
29
|
-
|
30
30
|
it "is authorizable when request is valid" do
|
31
31
|
expect(subject).to be_authorizable
|
32
32
|
end
|
@@ -77,7 +77,19 @@ describe Doorkeeper::OAuth::PreAuthorization do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
context "client
|
80
|
+
context "when grant flow is client credentials & redirect_uri is nil" do
|
81
|
+
before do
|
82
|
+
allow(server).to receive(:grant_flows).and_return(["client_credentials"])
|
83
|
+
allow(Doorkeeper.configuration).to receive(:allow_grant_flow_for_client?).and_return(false)
|
84
|
+
application.update_column :redirect_uri, nil
|
85
|
+
end
|
86
|
+
|
87
|
+
it "is not authorizable" do
|
88
|
+
expect(subject).not_to be_authorizable
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "when client application does not restrict valid scopes" do
|
81
93
|
it "accepts valid scopes" do
|
82
94
|
attributes[:scope] = "public"
|
83
95
|
expect(subject).to be_authorizable
|
@@ -101,7 +113,7 @@ describe Doorkeeper::OAuth::PreAuthorization do
|
|
101
113
|
end
|
102
114
|
end
|
103
115
|
|
104
|
-
context "client application restricts valid scopes" do
|
116
|
+
context "when client application restricts valid scopes" do
|
105
117
|
let(:application) do
|
106
118
|
FactoryBot.create(:application, scopes: Doorkeeper::OAuth::Scopes.from_string("public nonsense"))
|
107
119
|
end
|
@@ -118,7 +130,7 @@ describe Doorkeeper::OAuth::PreAuthorization do
|
|
118
130
|
|
119
131
|
it "rejects (application level) non-valid scopes" do
|
120
132
|
attributes[:scope] = "profile"
|
121
|
-
expect(subject).
|
133
|
+
expect(subject).not_to be_authorizable
|
122
134
|
end
|
123
135
|
|
124
136
|
it "accepts scopes which are permitted for grant_type" do
|
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper::OAuth::RefreshTokenRequest do
|
5
|
+
RSpec.describe Doorkeeper::OAuth::RefreshTokenRequest do
|
6
|
+
subject { described_class.new(server, refresh_token, credentials) }
|
7
|
+
|
6
8
|
let(:server) do
|
7
9
|
double :server, access_token_expires_in: 2.minutes
|
8
10
|
end
|
@@ -19,8 +21,6 @@ describe Doorkeeper::OAuth::RefreshTokenRequest do
|
|
19
21
|
allow(server).to receive(:option_defined?).with(:custom_access_token_expires_in).and_return(false)
|
20
22
|
end
|
21
23
|
|
22
|
-
subject { described_class.new(server, refresh_token, credentials) }
|
23
|
-
|
24
24
|
it "issues a new token for the client" do
|
25
25
|
expect { subject.authorize }.to change { client.reload.access_tokens.count }.by(1)
|
26
26
|
# #sort_by used for MongoDB ORM extensions for valid ordering
|
@@ -38,7 +38,7 @@ describe Doorkeeper::OAuth::RefreshTokenRequest do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "revokes the previous token" do
|
41
|
-
expect { subject.authorize }.to change
|
41
|
+
expect { subject.authorize }.to change(refresh_token, :revoked?).from(false).to(true)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "calls configured request callback methods" do
|
@@ -87,7 +87,7 @@ describe Doorkeeper::OAuth::RefreshTokenRequest do
|
|
87
87
|
expect(subject).to be_valid
|
88
88
|
end
|
89
89
|
|
90
|
-
context "refresh tokens expire on access token use" do
|
90
|
+
context "when refresh tokens expire on access token use" do
|
91
91
|
before do
|
92
92
|
allow(Doorkeeper::AccessToken).to receive(:refresh_token_revoked_on_use?).and_return(true)
|
93
93
|
end
|
@@ -110,17 +110,19 @@ describe Doorkeeper::OAuth::RefreshTokenRequest do
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
context "clientless access tokens" do
|
114
|
-
let!(:refresh_token) { FactoryBot.create(:clientless_access_token, use_refresh_token: true) }
|
115
|
-
|
113
|
+
context "with clientless access tokens" do
|
116
114
|
subject { described_class.new server, refresh_token, nil }
|
117
115
|
|
116
|
+
let!(:refresh_token) { FactoryBot.create(:clientless_access_token, use_refresh_token: true) }
|
117
|
+
|
118
118
|
it "issues a new token without a client" do
|
119
119
|
expect { subject.authorize }.to change { Doorkeeper::AccessToken.count }.by(1)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
123
|
context "with scopes" do
|
124
|
+
subject { described_class.new server, refresh_token, credentials, parameters }
|
125
|
+
|
124
126
|
let(:refresh_token) do
|
125
127
|
FactoryBot.create :access_token,
|
126
128
|
use_refresh_token: true,
|
@@ -128,8 +130,6 @@ describe Doorkeeper::OAuth::RefreshTokenRequest do
|
|
128
130
|
end
|
129
131
|
let(:parameters) { {} }
|
130
132
|
|
131
|
-
subject { described_class.new server, refresh_token, credentials, parameters }
|
132
|
-
|
133
133
|
it "transfers scopes from the old token to the new token" do
|
134
134
|
subject.authorize
|
135
135
|
expect(Doorkeeper::AccessToken.last.scopes).to eq(%i[public write])
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper::OAuth::Scopes do
|
5
|
+
RSpec.describe Doorkeeper::OAuth::Scopes do
|
6
6
|
describe "#add" do
|
7
7
|
it "allows you to add scopes with symbols" do
|
8
8
|
subject.add :public
|
@@ -27,28 +27,28 @@ describe Doorkeeper::OAuth::Scopes do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns true if scope with given name is present" do
|
30
|
-
expect(subject.
|
30
|
+
expect(subject).to exist("public")
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns false if scope with given name does not exist" do
|
34
|
-
expect(subject.
|
34
|
+
expect(subject).not_to exist("other")
|
35
35
|
end
|
36
36
|
|
37
37
|
it "handles symbols" do
|
38
|
-
expect(subject.
|
39
|
-
expect(subject.
|
38
|
+
expect(subject).to exist(:public)
|
39
|
+
expect(subject).not_to exist(:other)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe ".from_string" do
|
44
|
-
let(:string) { "public write" }
|
45
|
-
|
46
44
|
subject { described_class.from_string(string) }
|
47
45
|
|
46
|
+
let(:string) { "public write" }
|
47
|
+
|
48
48
|
it { expect(subject).to be_a(described_class) }
|
49
49
|
|
50
50
|
describe "#all" do
|
51
|
-
it "
|
51
|
+
it "is an array of the expected scopes" do
|
52
52
|
scopes_array = subject.all
|
53
53
|
expect(scopes_array.size).to eq(2)
|
54
54
|
expect(scopes_array).to include("public")
|
@@ -120,27 +120,27 @@ describe Doorkeeper::OAuth::Scopes do
|
|
120
120
|
subject { described_class.from_string("public admin") }
|
121
121
|
|
122
122
|
it "returns true when at least one scope is included" do
|
123
|
-
expect(subject.
|
123
|
+
expect(subject).to have_scopes(described_class.from_string("public"))
|
124
124
|
end
|
125
125
|
|
126
126
|
it "returns true when all scopes are included" do
|
127
|
-
expect(subject.
|
127
|
+
expect(subject).to have_scopes(described_class.from_string("public admin"))
|
128
128
|
end
|
129
129
|
|
130
130
|
it "is true if all scopes are included in any order" do
|
131
|
-
expect(subject.
|
131
|
+
expect(subject).to have_scopes(described_class.from_string("admin public"))
|
132
132
|
end
|
133
133
|
|
134
134
|
it "is false if no scopes are included" do
|
135
|
-
expect(subject.
|
135
|
+
expect(subject).not_to have_scopes(described_class.from_string("notexistent"))
|
136
136
|
end
|
137
137
|
|
138
138
|
it "returns false when any scope is not included" do
|
139
|
-
expect(subject.
|
139
|
+
expect(subject).not_to have_scopes(described_class.from_string("public nope"))
|
140
140
|
end
|
141
141
|
|
142
142
|
it "is false if no scopes are included even for existing ones" do
|
143
|
-
expect(subject.
|
143
|
+
expect(subject).not_to have_scopes(described_class.from_string("public admin notexistent"))
|
144
144
|
end
|
145
145
|
end
|
146
146
|
end
|
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper::OAuth::TokenRequest do
|
5
|
+
RSpec.describe Doorkeeper::OAuth::TokenRequest do
|
6
|
+
subject do
|
7
|
+
described_class.new(pre_auth, owner)
|
8
|
+
end
|
9
|
+
|
6
10
|
let :application do
|
7
11
|
FactoryBot.create(:application, scopes: "public")
|
8
12
|
end
|
@@ -29,10 +33,6 @@ describe Doorkeeper::OAuth::TokenRequest do
|
|
29
33
|
FactoryBot.create(:doorkeeper_testing_user)
|
30
34
|
end
|
31
35
|
|
32
|
-
subject do
|
33
|
-
described_class.new(pre_auth, owner)
|
34
|
-
end
|
35
|
-
|
36
36
|
it "creates an access token" do
|
37
37
|
expect do
|
38
38
|
subject.authorize
|
@@ -61,7 +61,7 @@ describe Doorkeeper::OAuth::TokenRequest do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
it "
|
64
|
+
it "uses the custom ttl" do
|
65
65
|
subject.authorize
|
66
66
|
token = Doorkeeper::AccessToken.first
|
67
67
|
expect(token.expires_in).to eq(1234)
|
@@ -79,7 +79,7 @@ describe Doorkeeper::OAuth::TokenRequest do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
it "
|
82
|
+
it "fallbacks to access_token_expires_in" do
|
83
83
|
subject.authorize
|
84
84
|
token = Doorkeeper::AccessToken.first
|
85
85
|
expect(token.expires_in).to eq(654)
|
@@ -97,7 +97,7 @@ describe Doorkeeper::OAuth::TokenRequest do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
it "
|
100
|
+
it "fallbacks to access_token_expires_in" do
|
101
101
|
subject.authorize
|
102
102
|
token = Doorkeeper::AccessToken.first
|
103
103
|
expect(token.expires_in).to be_nil
|
@@ -105,7 +105,7 @@ describe Doorkeeper::OAuth::TokenRequest do
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
context "
|
108
|
+
context "when reuse_access_token enabled" do
|
109
109
|
it "creates a new token if there are no matching tokens" do
|
110
110
|
allow(Doorkeeper.configuration).to receive(:reuse_access_token).and_return(true)
|
111
111
|
expect do
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe Doorkeeper::OAuth::TokenResponse do
|
5
|
+
RSpec.describe Doorkeeper::OAuth::TokenResponse do
|
6
6
|
subject { described_class.new(double.as_null_object) }
|
7
7
|
|
8
8
|
it "includes access token response headers" do
|
@@ -16,6 +16,8 @@ describe Doorkeeper::OAuth::TokenResponse do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe ".body" do
|
19
|
+
subject { described_class.new(access_token).body }
|
20
|
+
|
19
21
|
let(:access_token) do
|
20
22
|
double :access_token,
|
21
23
|
plaintext_token: "some-token",
|
@@ -27,8 +29,6 @@ describe Doorkeeper::OAuth::TokenResponse do
|
|
27
29
|
created_at: 0
|
28
30
|
end
|
29
31
|
|
30
|
-
subject { described_class.new(access_token).body }
|
31
|
-
|
32
32
|
it "includes :access_token" do
|
33
33
|
expect(subject["access_token"]).to eq("some-token")
|
34
34
|
end
|
@@ -57,6 +57,8 @@ describe Doorkeeper::OAuth::TokenResponse do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
describe ".body filters out empty values" do
|
60
|
+
subject { described_class.new(access_token).body }
|
61
|
+
|
60
62
|
let(:access_token) do
|
61
63
|
double :access_token,
|
62
64
|
plaintext_token: "some-token",
|
@@ -67,8 +69,6 @@ describe Doorkeeper::OAuth::TokenResponse do
|
|
67
69
|
created_at: 0
|
68
70
|
end
|
69
71
|
|
70
|
-
subject { described_class.new(access_token).body }
|
71
|
-
|
72
72
|
it "includes :expires_in" do
|
73
73
|
expect(subject["expires_in"]).to be_nil
|
74
74
|
end
|
@@ -9,7 +9,7 @@ module Doorkeeper
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
describe Doorkeeper::OAuth::Token do
|
12
|
+
RSpec.describe Doorkeeper::OAuth::Token do
|
13
13
|
describe ".from_request" do
|
14
14
|
let(:request) { double.as_null_object }
|
15
15
|
|
@@ -96,8 +96,8 @@ describe Doorkeeper::OAuth::Token do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
describe ".authenticate" do
|
99
|
-
context "refresh tokens are disabled (default)" do
|
100
|
-
context "refresh tokens are enabled" do
|
99
|
+
context "when refresh tokens are disabled (default)" do
|
100
|
+
context "when refresh tokens are enabled" do
|
101
101
|
it "does not revoke previous refresh_token if token was found" do
|
102
102
|
token = ->(_r) { "token" }
|
103
103
|
expect(
|
@@ -115,7 +115,7 @@ describe Doorkeeper::OAuth::Token do
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
context "token hashing is enabled" do
|
118
|
+
context "when token hashing is enabled" do
|
119
119
|
include_context "with token hashing enabled"
|
120
120
|
|
121
121
|
let(:hashed_token) { hashed_or_plain_token_func.call("token") }
|
@@ -129,7 +129,7 @@ describe Doorkeeper::OAuth::Token do
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
context "refresh tokens are enabled" do
|
132
|
+
context "when refresh tokens are enabled" do
|
133
133
|
before do
|
134
134
|
Doorkeeper.configure do
|
135
135
|
orm DOORKEEPER_ORM
|