doorkeeper 1.0.0.rc2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of doorkeeper might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -1
- data/lib/doorkeeper/version.rb +1 -1
- data/spec/controllers/applications_controller_spec.rb +4 -4
- data/spec/controllers/authorizations_controller_spec.rb +9 -9
- data/spec/controllers/protected_resources_controller_spec.rb +10 -10
- data/spec/controllers/token_info_controller_spec.rb +4 -4
- data/spec/controllers/tokens_controller_spec.rb +4 -4
- data/spec/lib/config_spec.rb +21 -21
- data/spec/lib/models/expirable_spec.rb +13 -13
- data/spec/lib/models/revocable_spec.rb +5 -5
- data/spec/lib/models/scopes_spec.rb +3 -3
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +5 -5
- data/spec/lib/oauth/authorization_code_request_spec.rb +7 -7
- data/spec/lib/oauth/client/credentials_spec.rb +8 -8
- data/spec/lib/oauth/client/methods_spec.rb +8 -8
- data/spec/lib/oauth/client_credentials/creator_spec.rb +2 -2
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +10 -9
- data/spec/lib/oauth/client_credentials/validation_spec.rb +6 -6
- data/spec/lib/oauth/client_credentials_request_spec.rb +7 -7
- data/spec/lib/oauth/client_spec.rb +8 -8
- data/spec/lib/oauth/code_request_spec.rb +4 -4
- data/spec/lib/oauth/error_response_spec.rb +22 -15
- data/spec/lib/oauth/error_spec.rb +1 -1
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +13 -13
- data/spec/lib/oauth/helpers/unique_token_spec.rb +2 -2
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +13 -13
- data/spec/lib/oauth/invalid_token_response_spec.rb +9 -4
- data/spec/lib/oauth/password_access_token_request_spec.rb +7 -7
- data/spec/lib/oauth/pre_authorization_spec.rb +14 -14
- data/spec/lib/oauth/refresh_token_request_spec.rb +8 -8
- data/spec/lib/oauth/scopes_spec.rb +27 -19
- data/spec/lib/oauth/token_request_spec.rb +4 -4
- data/spec/lib/oauth/token_response_spec.rb +11 -11
- data/spec/lib/oauth/token_spec.rb +9 -9
- data/spec/lib/server_spec.rb +1 -1
- data/spec/models/doorkeeper/access_token_spec.rb +15 -15
- data/spec/models/doorkeeper/application_spec.rb +21 -21
- data/spec/requests/flows/authorization_code_spec.rb +1 -1
- data/spec/requests/flows/client_credentials_spec.rb +1 -1
- data/spec/requests/flows/refresh_token_spec.rb +6 -6
- data/spec/requests/protected_resources/private_api_spec.rb +3 -3
- data/spec/routing/custom_controller_routes_spec.rb +16 -16
- data/spec/routing/default_routes_spec.rb +7 -7
- data/spec/routing/scoped_routes_spec.rb +7 -7
- data/spec/support/helpers/authorization_request_helper.rb +3 -3
- data/spec/support/helpers/model_helper.rb +6 -6
- data/spec/support/helpers/request_spec_helper.rb +9 -9
- data/spec/support/shared/controllers_shared_context.rb +6 -6
- data/spec/support/shared/models_shared_examples.rb +6 -6
- data/spec/validators/redirect_uri_validator_spec.rb +12 -12
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6d9a384a7eea2de2b4c25ea45fa6143aa23f8e6
|
4
|
+
data.tar.gz: 6401bda0dec405b1acdf9fd0cd4db42ada6f7f97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d61715593d0cd03aa6c7f32c62fcbdb3d924f410c5635a8cc97d6510fb09b48b508417fe70f9dccbcf1d0d20be8c12c86a37085b5a448bbb0c71203f015640cb
|
7
|
+
data.tar.gz: 9f10eb154a27dbcc558672f8add080aaa79380a3fe4ec807ef28c33f51679c84f5cc7be7debe019e0f9d21d70ed88656cacbed47e2019943cc72229d01c54bb6
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 1.0.0
|
3
|
+
## 1.0.0
|
4
4
|
|
5
5
|
- bug (spec)
|
6
6
|
- [#228] token response `expires_in` value is now in seconds, relative to
|
@@ -25,6 +25,7 @@
|
|
25
25
|
- Removes jQuery dependency [fixes #300] [PR #312 is related]
|
26
26
|
- [#294] Client uid and secret will be generated only if not present.
|
27
27
|
- [#316] Test warnings addressed.
|
28
|
+
- [#338] Rspec 3 syntax.
|
28
29
|
|
29
30
|
## 0.7.4
|
30
31
|
|
data/lib/doorkeeper/version.rb
CHANGED
@@ -4,7 +4,7 @@ module Doorkeeper
|
|
4
4
|
describe ApplicationsController do
|
5
5
|
context "when admin is not authenticated" do
|
6
6
|
before do
|
7
|
-
Doorkeeper.configuration.
|
7
|
+
allow(Doorkeeper.configuration).to receive(:authenticate_admin).and_return(proc do
|
8
8
|
redirect_to main_app.root_url
|
9
9
|
end)
|
10
10
|
end
|
@@ -25,7 +25,7 @@ module Doorkeeper
|
|
25
25
|
|
26
26
|
context "when admin is authenticated" do
|
27
27
|
before do
|
28
|
-
Doorkeeper.configuration.
|
28
|
+
allow(Doorkeeper.configuration).to receive(:authenticate_admin).and_return(->(arg) { true })
|
29
29
|
end
|
30
30
|
|
31
31
|
it "creates application" do
|
@@ -43,7 +43,7 @@ module Doorkeeper
|
|
43
43
|
uid: '1A2B3C4D',
|
44
44
|
secret: '1A2B3C4D' }
|
45
45
|
|
46
|
-
application.reload.uid.
|
46
|
+
expect(application.reload.uid).not_to eq '1A2B3C4D'
|
47
47
|
end
|
48
48
|
|
49
49
|
it "updates application" do
|
@@ -51,7 +51,7 @@ module Doorkeeper
|
|
51
51
|
put :update, id: application.id, application: {
|
52
52
|
name: 'Example',
|
53
53
|
redirect_uri: 'http://example.com' }
|
54
|
-
application.reload.name.
|
54
|
+
expect(application.reload.name).to eq 'Example'
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -16,7 +16,7 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
16
16
|
let(:user) { User.create!(:name => "Joe", :password => "sekret") }
|
17
17
|
|
18
18
|
before do
|
19
|
-
controller.
|
19
|
+
allow(controller).to receive(:current_resource_owner).and_return(user)
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "POST #create" do
|
@@ -100,35 +100,35 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
|
|
100
100
|
|
101
101
|
describe "GET #new with skip_authorization true" do
|
102
102
|
before do
|
103
|
-
Doorkeeper.configuration.
|
103
|
+
allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc do
|
104
104
|
true
|
105
105
|
end)
|
106
106
|
get :new, :client_id => client.uid, :response_type => "token", :redirect_uri => client.redirect_uri
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should redirect immediately" do
|
110
|
-
response.
|
111
|
-
response.location.
|
110
|
+
expect(response).to be_redirect
|
111
|
+
expect(response.location).to match(%r[^#{client.redirect_uri}])
|
112
112
|
end
|
113
113
|
|
114
114
|
it "should issue a token" do
|
115
|
-
Doorkeeper::AccessToken.count.
|
115
|
+
expect(Doorkeeper::AccessToken.count).to be 1
|
116
116
|
end
|
117
117
|
|
118
118
|
it "includes token type in fragment" do
|
119
|
-
fragments("token_type").
|
119
|
+
expect(fragments("token_type")).to eq("bearer")
|
120
120
|
end
|
121
121
|
|
122
122
|
it "includes token expiration in fragment" do
|
123
|
-
fragments("expires_in").to_i.
|
123
|
+
expect(fragments("expires_in").to_i).to eq(2.hours.to_i)
|
124
124
|
end
|
125
125
|
|
126
126
|
it "issues the token for the current client" do
|
127
|
-
Doorkeeper::AccessToken.first.application_id.
|
127
|
+
expect(Doorkeeper::AccessToken.first.application_id).to eq(client.id)
|
128
128
|
end
|
129
129
|
|
130
130
|
it "issues the token for the current resource owner" do
|
131
|
-
Doorkeeper::AccessToken.first.resource_owner_id.
|
131
|
+
expect(Doorkeeper::AccessToken.first.resource_owner_id).to eq(user.id)
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -79,29 +79,29 @@ describe "Doorkeeper_for helper" do
|
|
79
79
|
let(:token_string) { "1A2BC3" }
|
80
80
|
|
81
81
|
it "access_token param" do
|
82
|
-
Doorkeeper::AccessToken.
|
82
|
+
expect(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string)
|
83
83
|
get :index, :access_token => token_string
|
84
84
|
end
|
85
85
|
|
86
86
|
it "bearer_token param" do
|
87
|
-
Doorkeeper::AccessToken.
|
87
|
+
expect(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string)
|
88
88
|
get :index, :bearer_token => token_string
|
89
89
|
end
|
90
90
|
|
91
91
|
it "Authorization header" do
|
92
|
-
Doorkeeper::AccessToken.
|
92
|
+
expect(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string)
|
93
93
|
request.env["HTTP_AUTHORIZATION"] = "Bearer #{token_string}"
|
94
94
|
get :index
|
95
95
|
end
|
96
96
|
|
97
97
|
it "different kind of Authorization header" do
|
98
|
-
Doorkeeper::AccessToken.
|
98
|
+
expect(Doorkeeper::AccessToken).not_to receive(:authenticate)
|
99
99
|
request.env["HTTP_AUTHORIZATION"] = "Basic #{Base64.encode64("foo:bar")}"
|
100
100
|
get :index
|
101
101
|
end
|
102
102
|
|
103
103
|
it "doesn't change Authorization header value" do
|
104
|
-
Doorkeeper::AccessToken.
|
104
|
+
expect(Doorkeeper::AccessToken).to receive(:authenticate).exactly(2).times
|
105
105
|
request.env["HTTP_AUTHORIZATION"] = "Bearer #{token_string}"
|
106
106
|
get :index
|
107
107
|
controller.send(:remove_instance_variable, :@token)
|
@@ -172,14 +172,14 @@ describe "Doorkeeper_for helper" do
|
|
172
172
|
|
173
173
|
it "allows if the token has particular scopes" do
|
174
174
|
token = double(Doorkeeper::AccessToken, :accessible? => true, :scopes => ['write', 'public'])
|
175
|
-
Doorkeeper::AccessToken.
|
175
|
+
expect(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string).and_return(token)
|
176
176
|
get :index, :access_token => token_string
|
177
177
|
expect(response).to be_success
|
178
178
|
end
|
179
179
|
|
180
180
|
it "does not allow if the token does not include given scope" do
|
181
181
|
token = double(Doorkeeper::AccessToken, :accessible? => true, :scopes => ['public'], :revoked? => false, :expired? => false)
|
182
|
-
Doorkeeper::AccessToken.
|
182
|
+
expect(Doorkeeper::AccessToken).to receive(:authenticate).with(token_string).and_return(token)
|
183
183
|
get :index, :access_token => token_string
|
184
184
|
expect(response.status).to eq 401
|
185
185
|
expect(response.header["WWW-Authenticate"]).to match(/^Bearer/)
|
@@ -195,7 +195,7 @@ describe "Doorkeeper_for helper" do
|
|
195
195
|
|
196
196
|
context "with a JSON custom render", :token => :invalid do
|
197
197
|
before do
|
198
|
-
controller.
|
198
|
+
expect(controller).to receive(:doorkeeper_unauthorized_render_options).and_return({ :json => ActiveSupport::JSON.encode({ :error => "Unauthorized" }) } )
|
199
199
|
end
|
200
200
|
|
201
201
|
it "it renders a custom JSON response", :token => :invalid do
|
@@ -212,7 +212,7 @@ describe "Doorkeeper_for helper" do
|
|
212
212
|
|
213
213
|
context "with a text custom render", :token => :invalid do
|
214
214
|
before do
|
215
|
-
controller.
|
215
|
+
expect(controller).to receive(:doorkeeper_unauthorized_render_options).and_return({ :text => "Unauthorized" } )
|
216
216
|
end
|
217
217
|
|
218
218
|
it "it renders a custom JSON response", :token => :invalid do
|
@@ -220,7 +220,7 @@ describe "Doorkeeper_for helper" do
|
|
220
220
|
expect(response.status).to eq 401
|
221
221
|
expect(response.content_type).to eq('text/html')
|
222
222
|
expect(response.header["WWW-Authenticate"]).to match(/^Bearer/)
|
223
|
-
expect(response.body
|
223
|
+
expect(response.body).to eq('Unauthorized')
|
224
224
|
end
|
225
225
|
end
|
226
226
|
end
|
@@ -7,7 +7,7 @@ describe Doorkeeper::TokenInfoController do
|
|
7
7
|
let(:doorkeeper_token) { FactoryGirl.create(:access_token) }
|
8
8
|
|
9
9
|
before(:each) do
|
10
|
-
controller.
|
10
|
+
allow(controller).to receive(:doorkeeper_token) { doorkeeper_token }
|
11
11
|
end
|
12
12
|
|
13
13
|
def do_get
|
@@ -29,7 +29,7 @@ describe Doorkeeper::TokenInfoController do
|
|
29
29
|
|
30
30
|
describe "invalid token response" do
|
31
31
|
before(:each) do
|
32
|
-
controller.
|
32
|
+
allow(controller).to receive(:doorkeeper_token).and_return(nil)
|
33
33
|
end
|
34
34
|
it "responds with 401 when doorkeeper_token is not valid" do
|
35
35
|
do_get
|
@@ -38,8 +38,8 @@ describe Doorkeeper::TokenInfoController do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "responds with 401 when doorkeeper_token is invalid, expired or revoked" do
|
41
|
-
controller.
|
42
|
-
doorkeeper_token.
|
41
|
+
allow(controller).to receive(:doorkeeper_token).and_return(doorkeeper_token)
|
42
|
+
allow(doorkeeper_token).to receive(:accessible?).and_return(false)
|
43
43
|
do_get
|
44
44
|
expect(response.status).to eq 401
|
45
45
|
expect(response.headers["WWW-Authenticate"]).to match(/^Bearer/)
|
@@ -7,12 +7,12 @@ describe Doorkeeper::TokensController do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
before do
|
10
|
-
controller.
|
10
|
+
allow(controller).to receive(:token) { token }
|
11
11
|
end
|
12
12
|
|
13
13
|
it "returns the authorization" do
|
14
14
|
pending 'verify need of these specs'
|
15
|
-
token.
|
15
|
+
expect(token).to receive(:authorization)
|
16
16
|
post :create
|
17
17
|
end
|
18
18
|
end
|
@@ -23,12 +23,12 @@ describe Doorkeeper::TokensController do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
before do
|
26
|
-
controller.
|
26
|
+
allow(controller).to receive(:token) { token }
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns the error response" do
|
30
30
|
pending 'verify need of these specs'
|
31
|
-
token.
|
31
|
+
allow(token).to receive(:error_response).and_return(double(:to_json => [], :status => :unauthorized))
|
32
32
|
post :create
|
33
33
|
expect(response.status).to eq 401
|
34
34
|
expect(response.headers["WWW-Authenticate"]).to match(/Bearer/)
|
data/spec/lib/config_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe Doorkeeper, "configuration" do
|
|
10
10
|
orm DOORKEEPER_ORM
|
11
11
|
resource_owner_authenticator &block
|
12
12
|
end
|
13
|
-
subject.authenticate_resource_owner.
|
13
|
+
expect(subject.authenticate_resource_owner).to eq(block)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -21,13 +21,13 @@ describe Doorkeeper, "configuration" do
|
|
21
21
|
orm DOORKEEPER_ORM
|
22
22
|
admin_authenticator &block
|
23
23
|
end
|
24
|
-
subject.authenticate_admin.
|
24
|
+
expect(subject.authenticate_admin).to eq(block)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "access_token_expires_in" do
|
29
29
|
it "has 2 hours by default" do
|
30
|
-
subject.access_token_expires_in.
|
30
|
+
expect(subject.access_token_expires_in).to eq(2.hours)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "can change the value" do
|
@@ -35,7 +35,7 @@ describe Doorkeeper, "configuration" do
|
|
35
35
|
orm DOORKEEPER_ORM
|
36
36
|
access_token_expires_in 4.hours
|
37
37
|
end
|
38
|
-
subject.access_token_expires_in.
|
38
|
+
expect(subject.access_token_expires_in).to eq(4.hours)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "can be set to nil" do
|
@@ -43,7 +43,7 @@ describe Doorkeeper, "configuration" do
|
|
43
43
|
orm DOORKEEPER_ORM
|
44
44
|
access_token_expires_in nil
|
45
45
|
end
|
46
|
-
subject.access_token_expires_in.
|
46
|
+
expect(subject.access_token_expires_in).to be_nil
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -53,7 +53,7 @@ describe Doorkeeper, "configuration" do
|
|
53
53
|
orm DOORKEEPER_ORM
|
54
54
|
default_scopes :public
|
55
55
|
}
|
56
|
-
subject.default_scopes.
|
56
|
+
expect(subject.default_scopes).to include('public')
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'has optional scopes' do
|
@@ -61,7 +61,7 @@ describe Doorkeeper, "configuration" do
|
|
61
61
|
orm DOORKEEPER_ORM
|
62
62
|
optional_scopes :write, :update
|
63
63
|
}
|
64
|
-
subject.optional_scopes.
|
64
|
+
expect(subject.optional_scopes).to include('write', 'update')
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'has all scopes' do
|
@@ -70,13 +70,13 @@ describe Doorkeeper, "configuration" do
|
|
70
70
|
default_scopes :normal
|
71
71
|
optional_scopes :admin
|
72
72
|
end
|
73
|
-
subject.scopes.
|
73
|
+
expect(subject.scopes).to include('normal', 'admin')
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
describe "use_refresh_token" do
|
78
78
|
it "is false by default" do
|
79
|
-
subject.refresh_token_enabled
|
79
|
+
expect(subject.refresh_token_enabled?).to be_false
|
80
80
|
end
|
81
81
|
|
82
82
|
it "can change the value" do
|
@@ -84,13 +84,13 @@ describe Doorkeeper, "configuration" do
|
|
84
84
|
orm DOORKEEPER_ORM
|
85
85
|
use_refresh_token
|
86
86
|
}
|
87
|
-
subject.refresh_token_enabled
|
87
|
+
expect(subject.refresh_token_enabled?).to be_true
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
describe 'client_credentials' do
|
92
92
|
it 'has defaults order' do
|
93
|
-
subject.client_credentials_methods.
|
93
|
+
expect(subject.client_credentials_methods).to eq([:from_basic, :from_params])
|
94
94
|
end
|
95
95
|
|
96
96
|
it "can change the value" do
|
@@ -98,13 +98,13 @@ describe Doorkeeper, "configuration" do
|
|
98
98
|
orm DOORKEEPER_ORM
|
99
99
|
client_credentials :from_digest, :from_params
|
100
100
|
}
|
101
|
-
subject.client_credentials_methods.
|
101
|
+
expect(subject.client_credentials_methods).to eq([:from_digest, :from_params])
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
105
|
describe 'access_token_credentials' do
|
106
106
|
it 'has defaults order' do
|
107
|
-
subject.access_token_methods.
|
107
|
+
expect(subject.access_token_methods).to eq([:from_bearer_authorization, :from_access_token_param, :from_bearer_param])
|
108
108
|
end
|
109
109
|
|
110
110
|
it "can change the value" do
|
@@ -112,13 +112,13 @@ describe Doorkeeper, "configuration" do
|
|
112
112
|
orm DOORKEEPER_ORM
|
113
113
|
access_token_methods :from_access_token_param, :from_bearer_param
|
114
114
|
}
|
115
|
-
subject.access_token_methods.
|
115
|
+
expect(subject.access_token_methods).to eq([:from_access_token_param, :from_bearer_param])
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
119
|
describe "enable_application_owner" do
|
120
120
|
it "is disabled by default" do
|
121
|
-
Doorkeeper.configuration.enable_application_owner
|
121
|
+
expect(Doorkeeper.configuration.enable_application_owner?).not_to be_true
|
122
122
|
end
|
123
123
|
|
124
124
|
context "when enabled without confirmation" do
|
@@ -129,10 +129,10 @@ describe Doorkeeper, "configuration" do
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
it "adds support for application owner" do
|
132
|
-
Doorkeeper::Application.new.
|
132
|
+
expect(Doorkeeper::Application.new).to respond_to :owner
|
133
133
|
end
|
134
134
|
it "Doorkeeper.configuration.confirm_application_owner? returns false" do
|
135
|
-
Doorkeeper.configuration.confirm_application_owner
|
135
|
+
expect(Doorkeeper.configuration.confirm_application_owner?).not_to be_true
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -144,10 +144,10 @@ describe Doorkeeper, "configuration" do
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
it "adds support for application owner" do
|
147
|
-
Doorkeeper::Application.new.
|
147
|
+
expect(Doorkeeper::Application.new).to respond_to :owner
|
148
148
|
end
|
149
149
|
it "Doorkeeper.configuration.confirm_application_owner? returns true" do
|
150
|
-
Doorkeeper.configuration.confirm_application_owner
|
150
|
+
expect(Doorkeeper.configuration.confirm_application_owner?).to be_true
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
@@ -155,7 +155,7 @@ describe Doorkeeper, "configuration" do
|
|
155
155
|
|
156
156
|
describe "realm" do
|
157
157
|
it "is \"Doorkeeper\" by default" do
|
158
|
-
Doorkeeper.configuration.realm.
|
158
|
+
expect(Doorkeeper.configuration.realm).to eq("Doorkeeper")
|
159
159
|
end
|
160
160
|
|
161
161
|
it "can change the value" do
|
@@ -163,7 +163,7 @@ describe Doorkeeper, "configuration" do
|
|
163
163
|
orm DOORKEEPER_ORM
|
164
164
|
realm "Example"
|
165
165
|
}
|
166
|
-
subject.realm.
|
166
|
+
expect(subject.realm).to eq("Example")
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -11,40 +11,40 @@ describe 'Expirable' do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
before do
|
14
|
-
subject.
|
14
|
+
allow(subject).to receive(:created_at).and_return(1.minute.ago)
|
15
15
|
end
|
16
16
|
|
17
17
|
describe :expired? do
|
18
18
|
it "is not expired if time has not passed" do
|
19
|
-
subject.
|
20
|
-
subject.
|
19
|
+
allow(subject).to receive(:expires_in).and_return(2.minutes)
|
20
|
+
expect(subject).not_to be_expired
|
21
21
|
end
|
22
22
|
|
23
23
|
it "is expired if time has passed" do
|
24
|
-
subject.
|
25
|
-
subject.
|
24
|
+
allow(subject).to receive(:expires_in).and_return(10.seconds)
|
25
|
+
expect(subject).to be_expired
|
26
26
|
end
|
27
27
|
|
28
28
|
it "is not expired if expires_in is not set" do
|
29
|
-
subject.
|
30
|
-
subject.
|
29
|
+
allow(subject).to receive(:expires_in).and_return(nil)
|
30
|
+
expect(subject).not_to be_expired
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe :expires_in_seconds do
|
35
35
|
it "should return the amount of time remaining until the token is expired" do
|
36
|
-
subject.
|
37
|
-
subject.expires_in_seconds.
|
36
|
+
allow(subject).to receive(:expires_in).and_return(2.minutes)
|
37
|
+
expect(subject.expires_in_seconds).to eq(60)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should return 0 when expired" do
|
41
|
-
subject.
|
42
|
-
subject.expires_in_seconds.
|
41
|
+
allow(subject).to receive(:expires_in).and_return(30.seconds)
|
42
|
+
expect(subject.expires_in_seconds).to eq(0)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should return nil when expires_in is nil" do
|
46
|
-
subject.
|
47
|
-
subject.expires_in_seconds.
|
46
|
+
allow(subject).to receive(:expires_in).and_return(nil)
|
47
|
+
expect(subject.expires_in_seconds).to be_nil
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|