doorkeeper 2.1.4 → 2.2.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 +1 -430
- data/Gemfile +1 -8
- data/NEWS.md +449 -0
- data/README.md +46 -3
- data/doorkeeper.gemspec +1 -1
- data/gemfiles/Gemfile.common.rb +0 -7
- data/gemfiles/Gemfile.mongo_mapper.rb +2 -2
- data/gemfiles/Gemfile.mongoid2.rb +1 -1
- data/gemfiles/Gemfile.mongoid4.rb +0 -1
- data/lib/doorkeeper/config.rb +7 -0
- data/lib/doorkeeper/engine.rb +4 -0
- data/lib/doorkeeper/errors.rb +6 -0
- data/lib/doorkeeper/models/access_token_mixin.rb +6 -1
- data/lib/doorkeeper/rails/helpers.rb +1 -1
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/generators/doorkeeper/templates/initializer.rb +4 -0
- data/spec/controllers/applications_controller_spec.rb +0 -1
- data/spec/controllers/token_info_controller_spec.rb +0 -4
- data/spec/controllers/tokens_controller_spec.rb +4 -3
- data/spec/dummy/config/application.rb +2 -0
- data/spec/lib/config_spec.rb +18 -2
- data/spec/lib/oauth/authorization_code_request_spec.rb +1 -1
- data/spec/lib/oauth/client/credentials_spec.rb +2 -2
- data/spec/lib/oauth/password_access_token_request_spec.rb +1 -1
- data/spec/lib/oauth/pre_authorization_spec.rb +9 -10
- data/spec/lib/oauth/refresh_token_request_spec.rb +0 -1
- data/spec/lib/oauth/token_request_spec.rb +3 -3
- data/spec/lib/server_spec.rb +3 -1
- data/spec/models/doorkeeper/access_token_spec.rb +48 -0
- data/spec/requests/applications/applications_request_spec.rb +1 -1
- data/spec/requests/endpoints/authorization_spec.rb +2 -1
- data/spec/requests/endpoints/token_spec.rb +9 -9
- data/spec/requests/flows/authorization_code_errors_spec.rb +4 -4
- data/spec/requests/flows/authorization_code_spec.rb +10 -2
- data/spec/requests/flows/implicit_grant_spec.rb +14 -5
- data/spec/requests/flows/password_spec.rb +14 -20
- data/spec/requests/flows/refresh_token_spec.rb +7 -7
- data/spec/requests/flows/revoke_token_spec.rb +9 -31
- data/spec/requests/protected_resources/metal_spec.rb +3 -3
- data/spec/requests/protected_resources/private_api_spec.rb +11 -0
- data/spec/routing/custom_controller_routes_spec.rb +1 -2
- data/spec/routing/default_routes_spec.rb +1 -2
- data/spec/routing/scoped_routes_spec.rb +0 -1
- data/spec/spec_helper_integration.rb +3 -1
- data/spec/support/helpers/access_token_request_helper.rb +1 -1
- data/spec/support/helpers/authorization_request_helper.rb +1 -1
- data/spec/support/helpers/config_helper.rb +1 -1
- data/spec/support/helpers/model_helper.rb +1 -1
- data/spec/support/helpers/request_spec_helper.rb +1 -1
- data/spec/support/helpers/url_helper.rb +1 -1
- metadata +5 -4
@@ -59,7 +59,8 @@ feature 'Authorization endpoint' do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
scenario 'raises exception on forged requests' do
|
62
|
-
|
62
|
+
skip 'TODO: need to add request helpers to this feature spec'
|
63
|
+
allow_any_instance_of(ActionController::Base).to receive(:handle_unverified_request)
|
63
64
|
allowing_forgery_protection do
|
64
65
|
post "/oauth/authorize",
|
65
66
|
client_id: @client.uid,
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'spec_helper_integration'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
describe 'Token endpoint' do
|
4
|
+
before do
|
5
5
|
client_exists
|
6
6
|
authorization_code_exists application: @client, scopes: 'public'
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
it 'respond with correct headers' do
|
10
10
|
post token_endpoint_url(code: @authorization.token, client: @client)
|
11
11
|
should_have_header 'Pragma', 'no-cache'
|
12
12
|
should_have_header 'Cache-Control', 'no-store'
|
13
13
|
should_have_header 'Content-Type', 'application/json; charset=utf-8'
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
it 'accepts client credentials with basic auth header' do
|
17
17
|
post token_endpoint_url(
|
18
18
|
code: @authorization.token,
|
19
19
|
redirect_uri: @client.redirect_uri
|
@@ -22,14 +22,14 @@ feature 'Token endpoint' do
|
|
22
22
|
should_have_json 'access_token', Doorkeeper::AccessToken.first.token
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
it 'returns null for expires_in when a permanent token is set' do
|
26
26
|
config_is_set(:access_token_expires_in, nil)
|
27
27
|
post token_endpoint_url(code: @authorization.token, client: @client)
|
28
28
|
should_have_json 'access_token', Doorkeeper::AccessToken.first.token
|
29
29
|
should_not_have_json 'expires_in'
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
it 'returns unsupported_grant_type for invalid grant_type param' do
|
33
33
|
post token_endpoint_url(code: @authorization.token, client: @client, grant_type: 'nothing')
|
34
34
|
|
35
35
|
should_not_have_json 'access_token'
|
@@ -37,7 +37,7 @@ feature 'Token endpoint' do
|
|
37
37
|
should_have_json 'error_description', translated_error_message('unsupported_grant_type')
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
it 'returns unsupported_grant_type for disabled grant flows' do
|
41
41
|
config_is_set(:grant_flows, ['implicit'])
|
42
42
|
post token_endpoint_url(code: @authorization.token, client: @client, grant_type: 'authorization_code')
|
43
43
|
|
@@ -46,7 +46,7 @@ feature 'Token endpoint' do
|
|
46
46
|
should_have_json 'error_description', translated_error_message('unsupported_grant_type')
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
it 'returns unsupported_grant_type when refresh_token is not in use' do
|
50
50
|
post token_endpoint_url(code: @authorization.token, client: @client, grant_type: 'refresh_token')
|
51
51
|
|
52
52
|
should_not_have_json 'access_token'
|
@@ -54,7 +54,7 @@ feature 'Token endpoint' do
|
|
54
54
|
should_have_json 'error_description', translated_error_message('unsupported_grant_type')
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
it 'returns invalid_request if grant_type is missing' do
|
58
58
|
post token_endpoint_url(code: @authorization.token, client: @client, grant_type: '')
|
59
59
|
|
60
60
|
should_not_have_json 'access_token'
|
@@ -34,13 +34,13 @@ feature 'Authorization Code Flow Errors' do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
describe 'Authorization Code Flow Errors', 'after authorization' do
|
38
|
+
before do
|
39
39
|
client_exists
|
40
40
|
authorization_code_exists application: @client
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
it 'returns :invalid_grant error when posting an already revoked grant code' do
|
44
44
|
# First successful request
|
45
45
|
post token_endpoint_url(code: @authorization.token, client: @client)
|
46
46
|
|
@@ -54,7 +54,7 @@ feature 'Authorization Code Flow Errors', 'after authorization' do
|
|
54
54
|
should_have_json 'error_description', translated_error_message('invalid_grant')
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
it 'returns :invalid_grant error for invalid grant code' do
|
58
58
|
post token_endpoint_url(code: 'invalid', client: @client)
|
59
59
|
|
60
60
|
access_token_should_not_exist
|
@@ -41,6 +41,8 @@ feature 'Authorization Code Flow' do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
scenario 'resource owner requests an access token with authorization code' do
|
44
|
+
skip 'TODO: need to add request helpers to this feature spec'
|
45
|
+
|
44
46
|
visit authorization_endpoint_url(client: @client)
|
45
47
|
click_on 'Authorize'
|
46
48
|
|
@@ -52,13 +54,13 @@ feature 'Authorization Code Flow' do
|
|
52
54
|
should_not_have_json 'error'
|
53
55
|
|
54
56
|
should_have_json 'access_token', Doorkeeper::AccessToken.first.token
|
55
|
-
should_have_json 'token_type',
|
57
|
+
should_have_json 'token_type', 'bearer'
|
56
58
|
should_have_json_within 'expires_in', Doorkeeper::AccessToken.first.expires_in, 1
|
57
59
|
end
|
58
60
|
|
59
61
|
context 'with scopes' do
|
60
62
|
background do
|
61
|
-
default_scopes_exist
|
63
|
+
default_scopes_exist :public
|
62
64
|
optional_scopes_exist :write
|
63
65
|
end
|
64
66
|
|
@@ -82,6 +84,8 @@ feature 'Authorization Code Flow' do
|
|
82
84
|
end
|
83
85
|
|
84
86
|
scenario 'new access token matches required scopes' do
|
87
|
+
skip 'TODO: need to add request helpers to this feature spec'
|
88
|
+
|
85
89
|
visit authorization_endpoint_url(client: @client, scope: 'public write')
|
86
90
|
click_on 'Authorize'
|
87
91
|
|
@@ -93,6 +97,8 @@ feature 'Authorization Code Flow' do
|
|
93
97
|
end
|
94
98
|
|
95
99
|
scenario 'returns new token if scopes have changed' do
|
100
|
+
skip 'TODO: need to add request helpers to this feature spec'
|
101
|
+
|
96
102
|
client_is_authorized(@client, @resource_owner, scopes: 'public write')
|
97
103
|
visit authorization_endpoint_url(client: @client, scope: 'public')
|
98
104
|
click_on 'Authorize'
|
@@ -106,6 +112,8 @@ feature 'Authorization Code Flow' do
|
|
106
112
|
end
|
107
113
|
|
108
114
|
scenario 'resource owner authorizes the client with extra scopes' do
|
115
|
+
skip 'TODO: need to add request helpers to this feature spec'
|
116
|
+
|
109
117
|
client_is_authorized(@client, @resource_owner, scopes: 'public')
|
110
118
|
visit authorization_endpoint_url(client: @client, scope: 'public write')
|
111
119
|
click_on 'Authorize'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper_integration'
|
2
2
|
|
3
|
-
feature 'Implicit Grant Flow' do
|
3
|
+
feature 'Implicit Grant Flow (feature spec)' do
|
4
4
|
background do
|
5
5
|
config_is_set(:authenticate_resource_owner) { User.first || redirect_to('/sign_in') }
|
6
6
|
config_is_set(:grant_flows, ["implicit"])
|
@@ -17,10 +17,19 @@ feature 'Implicit Grant Flow' do
|
|
17
17
|
|
18
18
|
i_should_be_on_client_callback @client
|
19
19
|
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'Implicit Grant Flow (request spec)' do
|
23
|
+
before do
|
24
|
+
config_is_set(:authenticate_resource_owner) { User.first || redirect_to('/sign_in') }
|
25
|
+
config_is_set(:grant_flows, ["implicit"])
|
26
|
+
client_exists
|
27
|
+
create_resource_owner
|
28
|
+
end
|
20
29
|
|
21
30
|
context 'token reuse' do
|
22
|
-
|
23
|
-
Doorkeeper.configuration.
|
31
|
+
it 'should return a new token each request' do
|
32
|
+
allow(Doorkeeper.configuration).to receive(:reuse_access_token).and_return(false)
|
24
33
|
|
25
34
|
token = client_is_authorized(@client, @resource_owner)
|
26
35
|
|
@@ -34,8 +43,8 @@ feature 'Implicit Grant Flow' do
|
|
34
43
|
expect(response.location).not_to include(token.token)
|
35
44
|
end
|
36
45
|
|
37
|
-
|
38
|
-
Doorkeeper.configuration.
|
46
|
+
it 'should return the same token if it is still accessible' do
|
47
|
+
allow(Doorkeeper.configuration).to receive(:reuse_access_token).and_return(true)
|
39
48
|
|
40
49
|
token = client_is_authorized(@client, @resource_owner)
|
41
50
|
|
@@ -1,19 +1,13 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
# TODO: this flow should be configurable (letting Doorkeeper users decide if
|
4
|
-
# they want to make it available)
|
5
|
-
|
6
1
|
require 'spec_helper_integration'
|
7
2
|
|
8
|
-
|
9
|
-
|
3
|
+
describe 'Resource Owner Password Credentials Flow not set up' do
|
4
|
+
before do
|
10
5
|
client_exists
|
11
6
|
create_resource_owner
|
12
7
|
end
|
13
8
|
|
14
9
|
context 'with valid user credentials' do
|
15
|
-
|
16
|
-
skip 'Check a way to supress warnings here (or handle config better)'
|
10
|
+
it 'doesn\'t issue new token' do
|
17
11
|
expect do
|
18
12
|
post password_token_endpoint_url(client: @client, resource_owner: @resource_owner)
|
19
13
|
end.to_not change { Doorkeeper::AccessToken.count }
|
@@ -21,8 +15,8 @@ feature 'Resource Owner Password Credentials Flow inproperly set up' do
|
|
21
15
|
end
|
22
16
|
end
|
23
17
|
|
24
|
-
|
25
|
-
|
18
|
+
describe 'Resource Owner Password Credentials Flow' do
|
19
|
+
before do
|
26
20
|
config_is_set(:grant_flows, ["password"])
|
27
21
|
config_is_set(:resource_owner_from_credentials) { User.authenticate! params[:username], params[:password] }
|
28
22
|
client_exists
|
@@ -30,7 +24,7 @@ feature 'Resource Owner Password Credentials Flow' do
|
|
30
24
|
end
|
31
25
|
|
32
26
|
context 'with valid user credentials' do
|
33
|
-
|
27
|
+
it 'should issue new token' do
|
34
28
|
expect do
|
35
29
|
post password_token_endpoint_url(client: @client, resource_owner: @resource_owner)
|
36
30
|
end.to change { Doorkeeper::AccessToken.count }.by(1)
|
@@ -40,7 +34,7 @@ feature 'Resource Owner Password Credentials Flow' do
|
|
40
34
|
should_have_json 'access_token', token.token
|
41
35
|
end
|
42
36
|
|
43
|
-
|
37
|
+
it 'should issue new token without client credentials' do
|
44
38
|
expect do
|
45
39
|
post password_token_endpoint_url(resource_owner: @resource_owner)
|
46
40
|
end.to change { Doorkeeper::AccessToken.count }.by(1)
|
@@ -50,7 +44,7 @@ feature 'Resource Owner Password Credentials Flow' do
|
|
50
44
|
should_have_json 'access_token', token.token
|
51
45
|
end
|
52
46
|
|
53
|
-
|
47
|
+
it 'should issue a refresh token if enabled' do
|
54
48
|
config_is_set(:refresh_token_enabled, true)
|
55
49
|
|
56
50
|
post password_token_endpoint_url(client: @client, resource_owner: @resource_owner)
|
@@ -60,20 +54,20 @@ feature 'Resource Owner Password Credentials Flow' do
|
|
60
54
|
should_have_json 'refresh_token', token.refresh_token
|
61
55
|
end
|
62
56
|
|
63
|
-
|
64
|
-
Doorkeeper.configuration.
|
57
|
+
it 'should return the same token if it is still accessible' do
|
58
|
+
allow(Doorkeeper.configuration).to receive(:reuse_access_token).and_return(true)
|
65
59
|
|
66
60
|
client_is_authorized(@client, @resource_owner)
|
67
61
|
|
68
62
|
post password_token_endpoint_url(client: @client, resource_owner: @resource_owner)
|
69
63
|
|
70
|
-
Doorkeeper::AccessToken.count.
|
64
|
+
expect(Doorkeeper::AccessToken.count).to be(1)
|
71
65
|
should_have_json 'access_token', Doorkeeper::AccessToken.first.token
|
72
66
|
end
|
73
67
|
end
|
74
68
|
|
75
69
|
context 'with invalid user credentials' do
|
76
|
-
|
70
|
+
it 'should not issue new token with bad password' do
|
77
71
|
expect do
|
78
72
|
post password_token_endpoint_url(client: @client,
|
79
73
|
resource_owner_username: @resource_owner.name,
|
@@ -81,7 +75,7 @@ feature 'Resource Owner Password Credentials Flow' do
|
|
81
75
|
end.to_not change { Doorkeeper::AccessToken.count }
|
82
76
|
end
|
83
77
|
|
84
|
-
|
78
|
+
it 'should not issue new token without credentials' do
|
85
79
|
expect do
|
86
80
|
post password_token_endpoint_url(client: @client)
|
87
81
|
end.to_not change { Doorkeeper::AccessToken.count }
|
@@ -89,7 +83,7 @@ feature 'Resource Owner Password Credentials Flow' do
|
|
89
83
|
end
|
90
84
|
|
91
85
|
context 'with invalid client credentials' do
|
92
|
-
|
86
|
+
it 'should not issue new token with bad client credentials' do
|
93
87
|
expect do
|
94
88
|
post password_token_endpoint_url(client_id: @client.uid,
|
95
89
|
client_secret: 'bad_secret',
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper_integration'
|
2
2
|
|
3
|
-
|
3
|
+
describe 'Refresh Token Flow' do
|
4
4
|
before do
|
5
5
|
Doorkeeper.configure do
|
6
6
|
orm DOORKEEPER_ORM
|
@@ -14,7 +14,7 @@ feature 'Refresh Token Flow' do
|
|
14
14
|
authorization_code_exists application: @client
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
it 'client gets the refresh token and refreshses it' do
|
18
18
|
post token_endpoint_url(code: @authorization.token, client: @client)
|
19
19
|
|
20
20
|
token = Doorkeeper::AccessToken.first
|
@@ -40,26 +40,26 @@ feature 'Refresh Token Flow' do
|
|
40
40
|
@token = FactoryGirl.create(:access_token, application: @client, resource_owner_id: 1, use_refresh_token: true)
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
it 'client request a token with refresh token' do
|
44
44
|
post refresh_token_endpoint_url(client: @client, refresh_token: @token.refresh_token)
|
45
45
|
should_have_json 'refresh_token', Doorkeeper::AccessToken.last.refresh_token
|
46
46
|
expect(@token.reload).to be_revoked
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
it 'client request a token with expired access token' do
|
50
50
|
@token.update_attribute :expires_in, -100
|
51
51
|
post refresh_token_endpoint_url(client: @client, refresh_token: @token.refresh_token)
|
52
52
|
should_have_json 'refresh_token', Doorkeeper::AccessToken.last.refresh_token
|
53
53
|
expect(@token.reload).to be_revoked
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
it 'client gets an error for invalid refresh token' do
|
57
57
|
post refresh_token_endpoint_url(client: @client, refresh_token: 'invalid')
|
58
58
|
should_not_have_json 'refresh_token'
|
59
59
|
should_have_json 'error', 'invalid_grant'
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
it 'client gets an error for revoked acccess token' do
|
63
63
|
@token.revoke
|
64
64
|
post refresh_token_endpoint_url(client: @client, refresh_token: @token.refresh_token)
|
65
65
|
should_not_have_json 'refresh_token'
|
@@ -80,7 +80,7 @@ feature 'Refresh Token Flow' do
|
|
80
80
|
@token.update_attribute :expires_in, -100
|
81
81
|
end
|
82
82
|
|
83
|
-
|
83
|
+
it 'client request a token after creating another token with the same user' do
|
84
84
|
post refresh_token_endpoint_url(client: @client, refresh_token: @token.refresh_token)
|
85
85
|
|
86
86
|
should_have_json 'refresh_token', last_token.refresh_token
|
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'spec_helper_integration'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
describe 'Revoke Token Flow' do
|
5
4
|
before do
|
6
5
|
Doorkeeper.configure { orm DOORKEEPER_ORM }
|
7
6
|
end
|
8
7
|
|
9
8
|
context 'with default parameters' do
|
10
|
-
|
11
9
|
let(:client_application) { FactoryGirl.create :application }
|
12
10
|
let(:resource_owner) { User.create!(name: 'John', password: 'sekret') }
|
13
11
|
let(:authorization_access_token) do
|
@@ -16,13 +14,10 @@ feature 'Revoke Token Flow' do
|
|
16
14
|
resource_owner_id: resource_owner.id,
|
17
15
|
use_refresh_token: true)
|
18
16
|
end
|
19
|
-
|
20
17
|
let(:headers) { { 'HTTP_AUTHORIZATION' => "Bearer #{authorization_access_token.token}" } }
|
21
18
|
|
22
19
|
context 'With invalid token to revoke' do
|
23
|
-
|
24
|
-
scenario 'client wants to revoke the given access token' do
|
25
|
-
|
20
|
+
it 'client wants to revoke the given access token' do
|
26
21
|
post revocation_token_endpoint_url, { token: 'I_AM_AN_INVALIDE_TOKEN' }, headers
|
27
22
|
|
28
23
|
authorization_access_token.reload
|
@@ -34,11 +29,9 @@ feature 'Revoke Token Flow' do
|
|
34
29
|
end
|
35
30
|
|
36
31
|
context 'The access token to revoke is the same than the authorization access token' do
|
37
|
-
|
38
32
|
let(:token_to_revoke) { authorization_access_token }
|
39
33
|
|
40
|
-
|
41
|
-
|
34
|
+
it 'client wants to revoke the given access token' do
|
42
35
|
post revocation_token_endpoint_url, { token: token_to_revoke.token }, headers
|
43
36
|
|
44
37
|
token_to_revoke.reload
|
@@ -47,11 +40,9 @@ feature 'Revoke Token Flow' do
|
|
47
40
|
expect(response).to be_success
|
48
41
|
expect(token_to_revoke.revoked?).to be_truthy
|
49
42
|
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_truthy
|
50
|
-
|
51
43
|
end
|
52
44
|
|
53
|
-
|
54
|
-
|
45
|
+
it 'client wants to revoke the given access token using the POST query string' do
|
55
46
|
url_with_query_string = revocation_token_endpoint_url + '?' + Rack::Utils.build_query(token: token_to_revoke.token)
|
56
47
|
post url_with_query_string, {}, headers
|
57
48
|
|
@@ -62,13 +53,10 @@ feature 'Revoke Token Flow' do
|
|
62
53
|
expect(token_to_revoke.revoked?).to be_falsey
|
63
54
|
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_falsey
|
64
55
|
expect(authorization_access_token.revoked?).to be_falsey
|
65
|
-
|
66
56
|
end
|
67
|
-
|
68
57
|
end
|
69
58
|
|
70
59
|
context 'The access token to revoke app and owners are the same than the authorization access token' do
|
71
|
-
|
72
60
|
let(:token_to_revoke) do
|
73
61
|
FactoryGirl.create(:access_token,
|
74
62
|
application: client_application,
|
@@ -76,8 +64,7 @@ feature 'Revoke Token Flow' do
|
|
76
64
|
use_refresh_token: true)
|
77
65
|
end
|
78
66
|
|
79
|
-
|
80
|
-
|
67
|
+
it 'client wants to revoke the given access token' do
|
81
68
|
post revocation_token_endpoint_url, { token: token_to_revoke.token }, headers
|
82
69
|
|
83
70
|
token_to_revoke.reload
|
@@ -87,12 +74,10 @@ feature 'Revoke Token Flow' do
|
|
87
74
|
expect(token_to_revoke.revoked?).to be_truthy
|
88
75
|
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_truthy
|
89
76
|
expect(authorization_access_token.revoked?).to be_falsey
|
90
|
-
|
91
77
|
end
|
92
78
|
end
|
93
79
|
|
94
80
|
context 'The access token to revoke authorization owner is the same than the authorization access token' do
|
95
|
-
|
96
81
|
let(:other_client_application) { FactoryGirl.create :application }
|
97
82
|
let(:token_to_revoke) do
|
98
83
|
FactoryGirl.create(:access_token,
|
@@ -101,8 +86,7 @@ feature 'Revoke Token Flow' do
|
|
101
86
|
use_refresh_token: true)
|
102
87
|
end
|
103
88
|
|
104
|
-
|
105
|
-
|
89
|
+
it 'client wants to revoke the given access token' do
|
106
90
|
post revocation_token_endpoint_url, { token: token_to_revoke.token }, headers
|
107
91
|
|
108
92
|
token_to_revoke.reload
|
@@ -112,11 +96,10 @@ feature 'Revoke Token Flow' do
|
|
112
96
|
expect(token_to_revoke.revoked?).to be_falsey
|
113
97
|
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_falsey
|
114
98
|
expect(authorization_access_token.revoked?).to be_falsey
|
115
|
-
|
116
99
|
end
|
117
100
|
end
|
118
|
-
context 'The access token to revoke app is the same than the authorization access token' do
|
119
101
|
|
102
|
+
context 'The access token to revoke app is the same than the authorization access token' do
|
120
103
|
let(:other_resource_owner) { User.create!(name: 'Matheo', password: 'pareto') }
|
121
104
|
let(:token_to_revoke) do
|
122
105
|
FactoryGirl.create(:access_token,
|
@@ -125,8 +108,7 @@ feature 'Revoke Token Flow' do
|
|
125
108
|
use_refresh_token: true)
|
126
109
|
end
|
127
110
|
|
128
|
-
|
129
|
-
|
111
|
+
it 'client wants to revoke the given access token' do
|
130
112
|
post revocation_token_endpoint_url, { token: token_to_revoke.token }, headers
|
131
113
|
|
132
114
|
token_to_revoke.reload
|
@@ -136,12 +118,10 @@ feature 'Revoke Token Flow' do
|
|
136
118
|
expect(token_to_revoke.revoked?).to be_falsey
|
137
119
|
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_falsey
|
138
120
|
expect(authorization_access_token.revoked?).to be_falsey
|
139
|
-
|
140
121
|
end
|
141
122
|
end
|
142
123
|
|
143
124
|
context 'With valid refresh token to revoke' do
|
144
|
-
|
145
125
|
let(:token_to_revoke) do
|
146
126
|
FactoryGirl.create(:access_token,
|
147
127
|
application: client_application,
|
@@ -149,8 +129,7 @@ feature 'Revoke Token Flow' do
|
|
149
129
|
use_refresh_token: true)
|
150
130
|
end
|
151
131
|
|
152
|
-
|
153
|
-
|
132
|
+
it 'client wants to revoke the given refresh token' do
|
154
133
|
post revocation_token_endpoint_url, { token: token_to_revoke.refresh_token, token_type_hint: 'refresh_token' }, headers
|
155
134
|
authorization_access_token.reload
|
156
135
|
token_to_revoke.reload
|
@@ -158,7 +137,6 @@ feature 'Revoke Token Flow' do
|
|
158
137
|
expect(response).to be_success
|
159
138
|
expect(Doorkeeper::AccessToken.by_refresh_token(token_to_revoke.refresh_token).revoked?).to be_truthy
|
160
139
|
expect(authorization_access_token).to_not be_revoked
|
161
|
-
|
162
140
|
end
|
163
141
|
end
|
164
142
|
end
|