doorkeeper 1.1.0 → 1.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/.travis.yml +2 -2
- data/CHANGELOG.md +14 -2
- data/README.md +93 -42
- data/app/controllers/doorkeeper/application_controller.rb +1 -1
- data/app/controllers/doorkeeper/applications_controller.rb +4 -4
- data/app/controllers/doorkeeper/authorizations_controller.rb +3 -3
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
- data/app/controllers/doorkeeper/token_info_controller.rb +3 -3
- data/app/controllers/doorkeeper/tokens_controller.rb +29 -2
- data/app/helpers/doorkeeper/form_errors_helper.rb +2 -2
- data/app/validators/redirect_uri_validator.rb +1 -1
- data/app/views/doorkeeper/applications/_form.html.erb +3 -3
- data/app/views/doorkeeper/applications/edit.html.erb +1 -1
- data/app/views/doorkeeper/applications/new.html.erb +1 -1
- data/app/views/doorkeeper/applications/show.html.erb +1 -1
- data/app/views/doorkeeper/authorizations/new.html.erb +5 -5
- data/doorkeeper.gemspec +1 -1
- data/lib/doorkeeper.rb +31 -31
- data/lib/doorkeeper/config.rb +66 -37
- data/lib/doorkeeper/doorkeeper_for.rb +6 -3
- data/lib/doorkeeper/engine.rb +2 -2
- data/lib/doorkeeper/helpers/controller.rb +9 -9
- data/lib/doorkeeper/helpers/filter.rb +1 -1
- data/lib/doorkeeper/models/access_grant.rb +5 -5
- data/lib/doorkeeper/models/access_token.rb +22 -18
- data/lib/doorkeeper/models/active_record/access_token.rb +8 -8
- data/lib/doorkeeper/models/active_record/application.rb +5 -5
- data/lib/doorkeeper/models/application.rb +8 -9
- data/lib/doorkeeper/models/expirable.rb +1 -1
- data/lib/doorkeeper/models/mongo_mapper/access_grant.rb +2 -2
- data/lib/doorkeeper/models/mongo_mapper/access_token.rb +11 -11
- data/lib/doorkeeper/models/mongo_mapper/application.rb +4 -4
- data/lib/doorkeeper/models/mongoid/version.rb +2 -2
- data/lib/doorkeeper/models/mongoid2/access_grant.rb +7 -7
- data/lib/doorkeeper/models/mongoid2/access_token.rb +14 -14
- data/lib/doorkeeper/models/mongoid2/application.rb +7 -7
- data/lib/doorkeeper/models/mongoid3_4/access_grant.rb +7 -7
- data/lib/doorkeeper/models/mongoid3_4/access_token.rb +13 -13
- data/lib/doorkeeper/models/mongoid3_4/application.rb +6 -6
- data/lib/doorkeeper/models/ownership.rb +5 -5
- data/lib/doorkeeper/oauth/authorization/code.rb +5 -5
- data/lib/doorkeeper/oauth/authorization/token.rb +7 -7
- data/lib/doorkeeper/oauth/authorization_code_request.rb +18 -19
- data/lib/doorkeeper/oauth/client.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +4 -4
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +6 -4
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +2 -2
- data/lib/doorkeeper/oauth/client_credentials_request.rb +11 -15
- data/lib/doorkeeper/oauth/code_request.rb +5 -4
- data/lib/doorkeeper/oauth/code_response.rb +8 -7
- data/lib/doorkeeper/oauth/error.rb +1 -1
- data/lib/doorkeeper/oauth/error_response.rb +5 -5
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +1 -1
- data/lib/doorkeeper/oauth/invalid_token_response.rb +10 -10
- data/lib/doorkeeper/oauth/password_access_token_request.rb +57 -54
- data/lib/doorkeeper/oauth/pre_authorization.rb +7 -7
- data/lib/doorkeeper/oauth/refresh_token_request.rb +27 -24
- data/lib/doorkeeper/oauth/scopes.rb +3 -3
- data/lib/doorkeeper/oauth/token.rb +27 -1
- data/lib/doorkeeper/oauth/token_request.rb +14 -4
- data/lib/doorkeeper/rails/routes.rb +31 -22
- data/lib/doorkeeper/rails/routes/mapping.rb +11 -12
- data/lib/doorkeeper/request.rb +5 -5
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/generators/doorkeeper/application_owner_generator.rb +1 -1
- data/lib/generators/doorkeeper/install_generator.rb +5 -5
- data/lib/generators/doorkeeper/migration_generator.rb +1 -1
- data/lib/generators/doorkeeper/mongo_mapper/indexes_generator.rb +2 -2
- data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +2 -2
- data/lib/generators/doorkeeper/templates/initializer.rb +16 -3
- data/lib/generators/doorkeeper/templates/migration.rb +16 -17
- data/lib/generators/doorkeeper/views_generator.rb +1 -1
- data/spec/controllers/applications_controller_spec.rb +7 -7
- data/spec/controllers/authorizations_controller_spec.rb +48 -48
- data/spec/controllers/protected_resources_controller_spec.rb +108 -107
- data/spec/controllers/token_info_controller_spec.rb +11 -11
- data/spec/controllers/tokens_controller_spec.rb +8 -8
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +2 -2
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +3 -3
- data/spec/dummy/app/controllers/home_controller.rb +5 -5
- data/spec/dummy/app/controllers/metal_controller.rb +1 -1
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +2 -2
- data/spec/dummy/app/models/user.rb +3 -3
- data/spec/dummy/config/application.rb +8 -9
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/doorkeeper.rb +5 -5
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy/config/routes.rb +27 -27
- data/spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb +16 -17
- data/spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb +3 -3
- data/spec/dummy/db/schema.rb +39 -39
- data/spec/factories/access_grant.rb +3 -3
- data/spec/factories/access_token.rb +1 -1
- data/spec/factories/application.rb +3 -3
- data/spec/generators/application_owner_generator_spec.rb +6 -7
- data/spec/generators/install_generator_spec.rb +9 -9
- data/spec/generators/migration_generator_spec.rb +4 -4
- data/spec/lib/config_spec.rb +136 -44
- data/spec/lib/models/expirable_spec.rb +9 -9
- data/spec/lib/models/revocable_spec.rb +4 -4
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +4 -4
- data/spec/lib/oauth/authorization_code_request_spec.rb +2 -2
- data/spec/lib/oauth/client/credentials_spec.rb +4 -4
- data/spec/lib/oauth/client/methods_spec.rb +10 -10
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +9 -7
- data/spec/lib/oauth/client_credentials/validation_spec.rb +2 -2
- data/spec/lib/oauth/client_credentials_request_spec.rb +6 -6
- data/spec/lib/oauth/client_spec.rb +4 -4
- data/spec/lib/oauth/code_request_spec.rb +10 -9
- data/spec/lib/oauth/error_response_spec.rb +8 -8
- data/spec/lib/oauth/error_spec.rb +1 -1
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +17 -17
- data/spec/lib/oauth/helpers/unique_token_spec.rb +7 -7
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +33 -33
- data/spec/lib/oauth/invalid_token_response_spec.rb +4 -4
- data/spec/lib/oauth/password_access_token_request_spec.rb +13 -13
- data/spec/lib/oauth/pre_authorization_spec.rb +47 -7
- data/spec/lib/oauth/refresh_token_request_spec.rb +11 -21
- data/spec/lib/oauth/scopes_spec.rb +32 -32
- data/spec/lib/oauth/token_request_spec.rb +10 -9
- data/spec/lib/oauth/token_response_spec.rb +13 -15
- data/spec/lib/oauth/token_spec.rb +24 -10
- data/spec/lib/server_spec.rb +24 -2
- data/spec/models/doorkeeper/access_grant_spec.rb +8 -8
- data/spec/models/doorkeeper/access_token_spec.rb +79 -33
- data/spec/models/doorkeeper/application_spec.rb +29 -29
- data/spec/requests/applications/applications_request_spec.rb +15 -15
- data/spec/requests/applications/authorized_applications_spec.rb +7 -7
- data/spec/requests/endpoints/authorization_spec.rb +19 -12
- data/spec/requests/endpoints/token_spec.rb +26 -8
- data/spec/requests/flows/authorization_code_errors_spec.rb +17 -17
- data/spec/requests/flows/authorization_code_spec.rb +28 -28
- data/spec/requests/flows/client_credentials_spec.rb +3 -3
- data/spec/requests/flows/implicit_grant_errors_spec.rb +5 -5
- data/spec/requests/flows/implicit_grant_spec.rb +2 -2
- data/spec/requests/flows/password_spec.rb +32 -32
- data/spec/requests/flows/refresh_token_spec.rb +23 -23
- data/spec/requests/flows/revoke_token_spec.rb +165 -0
- data/spec/requests/flows/skip_authorization_spec.rb +10 -10
- data/spec/requests/protected_resources/metal_spec.rb +1 -1
- data/spec/requests/protected_resources/private_api_spec.rb +5 -5
- data/spec/routing/custom_controller_routes_spec.rb +4 -0
- data/spec/routing/default_routes_spec.rb +5 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/spec_helper_integration.rb +8 -10
- data/spec/support/helpers/access_token_request_helper.rb +3 -3
- data/spec/support/helpers/authorization_request_helper.rb +3 -3
- data/spec/support/helpers/config_helper.rb +1 -1
- data/spec/support/helpers/model_helper.rb +2 -2
- data/spec/support/helpers/request_spec_helper.rb +3 -3
- data/spec/support/helpers/url_helper.rb +25 -21
- data/spec/support/orm/active_record.rb +4 -4
- data/spec/support/orm/mongo_mapper.rb +2 -3
- data/spec/support/orm/mongoid.rb +5 -6
- data/spec/support/shared/controllers_shared_context.rb +15 -15
- data/spec/support/shared/models_shared_examples.rb +13 -13
- data/spec/validators/redirect_uri_validator_spec.rb +9 -9
- metadata +5 -4
@@ -1,9 +1,9 @@
|
|
1
1
|
FactoryGirl.define do
|
2
|
-
factory :access_grant, :
|
2
|
+
factory :access_grant, class: Doorkeeper::AccessGrant do
|
3
3
|
sequence(:resource_owner_id) { |n| n }
|
4
4
|
application
|
5
|
-
redirect_uri
|
5
|
+
redirect_uri 'https://app.com/callback'
|
6
6
|
expires_in 100
|
7
|
-
scopes
|
7
|
+
scopes 'public write'
|
8
8
|
end
|
9
9
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
FactoryGirl.define do
|
2
|
-
factory :application, :
|
3
|
-
sequence(:name){ |n| "Application #{n}" }
|
4
|
-
redirect_uri
|
2
|
+
factory :application, class: Doorkeeper::Application do
|
3
|
+
sequence(:name) { |n| "Application #{n}" }
|
4
|
+
redirect_uri 'https://app.com/callback'
|
5
5
|
end
|
6
6
|
end
|
@@ -1,23 +1,22 @@
|
|
1
1
|
require 'spec_helper_integration'
|
2
2
|
require 'generators/doorkeeper/application_owner_generator'
|
3
3
|
|
4
|
-
|
5
4
|
describe 'Doorkeeper::ApplicationOwnerGenerator' do
|
6
5
|
include GeneratorSpec::TestCase
|
7
6
|
|
8
7
|
tests Doorkeeper::ApplicationOwnerGenerator
|
9
|
-
destination ::File.expand_path(
|
8
|
+
destination ::File.expand_path('../tmp/dummy', __FILE__)
|
10
9
|
|
11
|
-
describe
|
10
|
+
describe 'after running the generator' do
|
12
11
|
before :each do
|
13
12
|
prepare_destination
|
14
|
-
FileUtils.mkdir(::File.expand_path(
|
15
|
-
FileUtils.copy_file(::File.expand_path(
|
13
|
+
FileUtils.mkdir(::File.expand_path('config', Pathname(destination_root)))
|
14
|
+
FileUtils.copy_file(::File.expand_path('../templates/routes.rb', __FILE__), ::File.expand_path('config/routes.rb', Pathname.new(destination_root)))
|
16
15
|
run_generator
|
17
16
|
end
|
18
17
|
|
19
|
-
it
|
20
|
-
assert_migration
|
18
|
+
it 'creates a migration' do
|
19
|
+
assert_migration 'db/migrate/add_owner_to_application.rb'
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
@@ -5,27 +5,27 @@ describe 'Doorkeeper::InstallGenerator' do
|
|
5
5
|
include GeneratorSpec::TestCase
|
6
6
|
|
7
7
|
tests Doorkeeper::InstallGenerator
|
8
|
-
destination ::File.expand_path(
|
8
|
+
destination ::File.expand_path('../tmp/dummy', __FILE__)
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe 'after running the generator' do
|
11
11
|
before :each do
|
12
12
|
prepare_destination
|
13
|
-
FileUtils.mkdir(::File.expand_path(
|
14
|
-
FileUtils.mkdir(::File.expand_path(
|
15
|
-
FileUtils.copy_file(::File.expand_path(
|
13
|
+
FileUtils.mkdir(::File.expand_path('config', Pathname(destination_root)))
|
14
|
+
FileUtils.mkdir(::File.expand_path('db', Pathname(destination_root)))
|
15
|
+
FileUtils.copy_file(::File.expand_path('../templates/routes.rb', __FILE__), ::File.expand_path('config/routes.rb', Pathname.new(destination_root)))
|
16
16
|
run_generator
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'creates an initializer file' do
|
20
20
|
assert_file 'config/initializers/doorkeeper.rb'
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'copies the locale file' do
|
24
24
|
assert_file 'config/locales/doorkeeper.en.yml'
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
assert_file
|
27
|
+
it 'adds sample route' do
|
28
|
+
assert_file 'config/routes.rb', /use_doorkeeper/
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -5,16 +5,16 @@ describe 'Doorkeeper::MigrationGenerator' do
|
|
5
5
|
include GeneratorSpec::TestCase
|
6
6
|
|
7
7
|
tests Doorkeeper::MigrationGenerator
|
8
|
-
destination ::File.expand_path(
|
8
|
+
destination ::File.expand_path('../tmp/dummy', __FILE__)
|
9
9
|
|
10
|
-
describe
|
10
|
+
describe 'after running the generator' do
|
11
11
|
before :each do
|
12
12
|
prepare_destination
|
13
13
|
run_generator
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
assert_migration
|
16
|
+
it 'creates a migration' do
|
17
|
+
assert_migration 'db/migrate/create_doorkeeper_tables.rb'
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/spec/lib/config_spec.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper_integration'
|
2
2
|
|
3
|
-
describe Doorkeeper,
|
3
|
+
describe Doorkeeper, 'configuration' do
|
4
4
|
subject { Doorkeeper.configuration }
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
block = proc
|
6
|
+
describe 'resource_owner_authenticator' do
|
7
|
+
it 'sets the block that is accessible via authenticate_resource_owner' do
|
8
|
+
block = proc {}
|
9
9
|
Doorkeeper.configure do
|
10
10
|
orm DOORKEEPER_ORM
|
11
11
|
resource_owner_authenticator &block
|
@@ -14,9 +14,9 @@ describe Doorkeeper, "configuration" do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
18
|
-
it
|
19
|
-
block = proc
|
17
|
+
describe 'admin_authenticator' do
|
18
|
+
it 'sets the block that is accessible via authenticate_admin' do
|
19
|
+
block = proc {}
|
20
20
|
Doorkeeper.configure do
|
21
21
|
orm DOORKEEPER_ORM
|
22
22
|
admin_authenticator &block
|
@@ -25,12 +25,12 @@ describe Doorkeeper, "configuration" do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
describe
|
29
|
-
it
|
28
|
+
describe 'access_token_expires_in' do
|
29
|
+
it 'has 2 hours by default' do
|
30
30
|
expect(subject.access_token_expires_in).to eq(2.hours)
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'can change the value' do
|
34
34
|
Doorkeeper.configure do
|
35
35
|
orm DOORKEEPER_ORM
|
36
36
|
access_token_expires_in 4.hours
|
@@ -38,7 +38,7 @@ describe Doorkeeper, "configuration" do
|
|
38
38
|
expect(subject.access_token_expires_in).to eq(4.hours)
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
41
|
+
it 'can be set to nil' do
|
42
42
|
Doorkeeper.configure do
|
43
43
|
orm DOORKEEPER_ORM
|
44
44
|
access_token_expires_in nil
|
@@ -47,20 +47,20 @@ describe Doorkeeper, "configuration" do
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
describe
|
51
|
-
it
|
52
|
-
Doorkeeper.configure
|
50
|
+
describe 'scopes' do
|
51
|
+
it 'has default scopes' do
|
52
|
+
Doorkeeper.configure do
|
53
53
|
orm DOORKEEPER_ORM
|
54
54
|
default_scopes :public
|
55
|
-
|
55
|
+
end
|
56
56
|
expect(subject.default_scopes).to include('public')
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'has optional scopes' do
|
60
|
-
Doorkeeper.configure
|
60
|
+
Doorkeeper.configure do
|
61
61
|
orm DOORKEEPER_ORM
|
62
62
|
optional_scopes :write, :update
|
63
|
-
|
63
|
+
end
|
64
64
|
expect(subject.optional_scopes).to include('write', 'update')
|
65
65
|
end
|
66
66
|
|
@@ -74,18 +74,35 @@ describe Doorkeeper, "configuration" do
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
describe
|
78
|
-
it
|
77
|
+
describe 'use_refresh_token' do
|
78
|
+
it 'is false by default' do
|
79
79
|
expect(subject.refresh_token_enabled?).to be_false
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
83
|
-
Doorkeeper.configure
|
82
|
+
it 'can change the value' do
|
83
|
+
Doorkeeper.configure do
|
84
84
|
orm DOORKEEPER_ORM
|
85
85
|
use_refresh_token
|
86
|
-
|
86
|
+
end
|
87
87
|
expect(subject.refresh_token_enabled?).to be_true
|
88
88
|
end
|
89
|
+
|
90
|
+
it "does not includes 'refresh_token' in authorization_response_types" do
|
91
|
+
expect(subject.token_grant_types).not_to include 'refresh_token'
|
92
|
+
end
|
93
|
+
|
94
|
+
context "is enabled" do
|
95
|
+
before do
|
96
|
+
Doorkeeper.configure {
|
97
|
+
orm DOORKEEPER_ORM
|
98
|
+
use_refresh_token
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
it "includes 'refresh_token' in authorization_response_types" do
|
103
|
+
expect(subject.token_grant_types).to include 'refresh_token'
|
104
|
+
end
|
105
|
+
end
|
89
106
|
end
|
90
107
|
|
91
108
|
describe 'client_credentials' do
|
@@ -93,11 +110,11 @@ describe Doorkeeper, "configuration" do
|
|
93
110
|
expect(subject.client_credentials_methods).to eq([:from_basic, :from_params])
|
94
111
|
end
|
95
112
|
|
96
|
-
it
|
97
|
-
Doorkeeper.configure
|
113
|
+
it 'can change the value' do
|
114
|
+
Doorkeeper.configure do
|
98
115
|
orm DOORKEEPER_ORM
|
99
116
|
client_credentials :from_digest, :from_params
|
100
|
-
|
117
|
+
end
|
101
118
|
expect(subject.client_credentials_methods).to eq([:from_digest, :from_params])
|
102
119
|
end
|
103
120
|
end
|
@@ -107,68 +124,143 @@ describe Doorkeeper, "configuration" do
|
|
107
124
|
expect(subject.access_token_methods).to eq([:from_bearer_authorization, :from_access_token_param, :from_bearer_param])
|
108
125
|
end
|
109
126
|
|
110
|
-
it
|
111
|
-
Doorkeeper.configure
|
127
|
+
it 'can change the value' do
|
128
|
+
Doorkeeper.configure do
|
112
129
|
orm DOORKEEPER_ORM
|
113
130
|
access_token_methods :from_access_token_param, :from_bearer_param
|
114
|
-
|
131
|
+
end
|
115
132
|
expect(subject.access_token_methods).to eq([:from_access_token_param, :from_bearer_param])
|
116
133
|
end
|
117
134
|
end
|
118
135
|
|
119
|
-
describe
|
120
|
-
it
|
136
|
+
describe 'enable_application_owner' do
|
137
|
+
it 'is disabled by default' do
|
121
138
|
expect(Doorkeeper.configuration.enable_application_owner?).not_to be_true
|
122
139
|
end
|
123
140
|
|
124
|
-
context
|
141
|
+
context 'when enabled without confirmation' do
|
125
142
|
before do
|
126
143
|
Doorkeeper.configure do
|
127
144
|
orm DOORKEEPER_ORM
|
128
145
|
enable_application_owner
|
129
146
|
end
|
130
147
|
end
|
131
|
-
it
|
148
|
+
it 'adds support for application owner' do
|
132
149
|
expect(Doorkeeper::Application.new).to respond_to :owner
|
133
150
|
end
|
134
|
-
it
|
151
|
+
it 'Doorkeeper.configuration.confirm_application_owner? returns false' do
|
135
152
|
expect(Doorkeeper.configuration.confirm_application_owner?).not_to be_true
|
136
153
|
end
|
137
154
|
end
|
138
155
|
|
139
|
-
context
|
156
|
+
context 'when enabled with confirmation set to true' do
|
140
157
|
before do
|
141
158
|
Doorkeeper.configure do
|
142
159
|
orm DOORKEEPER_ORM
|
143
|
-
enable_application_owner :
|
160
|
+
enable_application_owner confirmation: true
|
144
161
|
end
|
145
162
|
end
|
146
|
-
it
|
163
|
+
it 'adds support for application owner' do
|
147
164
|
expect(Doorkeeper::Application.new).to respond_to :owner
|
148
165
|
end
|
149
|
-
it
|
166
|
+
it 'Doorkeeper.configuration.confirm_application_owner? returns true' do
|
150
167
|
expect(Doorkeeper.configuration.confirm_application_owner?).to be_true
|
151
168
|
end
|
152
169
|
end
|
153
170
|
end
|
154
171
|
|
155
|
-
describe
|
156
|
-
it
|
172
|
+
describe 'wildcard_redirect_uri' do
|
173
|
+
it 'is disabled by default' do
|
157
174
|
Doorkeeper.configuration.wildcard_redirect_uri.should be_false
|
158
175
|
end
|
159
176
|
end
|
160
177
|
|
161
|
-
describe
|
162
|
-
it
|
163
|
-
expect(Doorkeeper.configuration.realm).to eq(
|
178
|
+
describe 'realm' do
|
179
|
+
it 'is \'Doorkeeper\' by default' do
|
180
|
+
expect(Doorkeeper.configuration.realm).to eq('Doorkeeper')
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'can change the value' do
|
184
|
+
Doorkeeper.configure do
|
185
|
+
orm DOORKEEPER_ORM
|
186
|
+
realm 'Example'
|
187
|
+
end
|
188
|
+
expect(subject.realm).to eq('Example')
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe "grant_flows" do
|
193
|
+
it "is set to all grant flows by default" do
|
194
|
+
expect(Doorkeeper.configuration.grant_flows).to eq [
|
195
|
+
'authorization_code',
|
196
|
+
'implicit',
|
197
|
+
'password',
|
198
|
+
'client_credentials'
|
199
|
+
]
|
164
200
|
end
|
165
201
|
|
166
202
|
it "can change the value" do
|
167
203
|
Doorkeeper.configure {
|
168
204
|
orm DOORKEEPER_ORM
|
169
|
-
|
205
|
+
grant_flows [ 'authorization_code', 'implicit' ]
|
170
206
|
}
|
171
|
-
expect(subject.
|
207
|
+
expect(subject.grant_flows).to eq ['authorization_code', 'implicit']
|
208
|
+
end
|
209
|
+
|
210
|
+
context "when including 'authorization_code'" do
|
211
|
+
before do
|
212
|
+
Doorkeeper.configure {
|
213
|
+
orm DOORKEEPER_ORM
|
214
|
+
grant_flows ['authorization_code']
|
215
|
+
}
|
216
|
+
end
|
217
|
+
|
218
|
+
it "includes 'code' in authorization_response_types" do
|
219
|
+
expect(subject.authorization_response_types).to include 'code'
|
220
|
+
end
|
221
|
+
|
222
|
+
it "includes 'authorization_code' in token_grant_types" do
|
223
|
+
expect(subject.token_grant_types).to include 'authorization_code'
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
context "when including 'implicit'" do
|
228
|
+
before do
|
229
|
+
Doorkeeper.configure {
|
230
|
+
orm DOORKEEPER_ORM
|
231
|
+
grant_flows ['implicit']
|
232
|
+
}
|
233
|
+
end
|
234
|
+
|
235
|
+
it "includes 'token' in authorization_response_types" do
|
236
|
+
expect(subject.authorization_response_types).to include 'token'
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
context "when including 'password'" do
|
241
|
+
before do
|
242
|
+
Doorkeeper.configure {
|
243
|
+
orm DOORKEEPER_ORM
|
244
|
+
grant_flows ['password']
|
245
|
+
}
|
246
|
+
end
|
247
|
+
|
248
|
+
it "includes 'password' in token_grant_types" do
|
249
|
+
expect(subject.token_grant_types).to include 'password'
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
context "when including 'client_credentials'" do
|
254
|
+
before do
|
255
|
+
Doorkeeper.configure {
|
256
|
+
orm DOORKEEPER_ORM
|
257
|
+
grant_flows ['client_credentials']
|
258
|
+
}
|
259
|
+
end
|
260
|
+
|
261
|
+
it "includes 'client_credentials' in token_grant_types" do
|
262
|
+
expect(subject.token_grant_types).to include 'client_credentials'
|
263
|
+
end
|
172
264
|
end
|
173
265
|
end
|
174
266
|
|
@@ -15,37 +15,37 @@ describe 'Expirable' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe :expired? do
|
18
|
-
it
|
18
|
+
it 'is not expired if time has not passed' do
|
19
19
|
allow(subject).to receive(:expires_in).and_return(2.minutes)
|
20
20
|
expect(subject).not_to be_expired
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'is expired if time has passed' do
|
24
24
|
allow(subject).to receive(:expires_in).and_return(10.seconds)
|
25
25
|
expect(subject).to be_expired
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'is not expired if expires_in is not set' do
|
29
29
|
allow(subject).to receive(:expires_in).and_return(nil)
|
30
30
|
expect(subject).not_to be_expired
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe :expires_in_seconds do
|
35
|
-
it
|
35
|
+
it 'should return the amount of time remaining until the token is expired' do
|
36
36
|
allow(subject).to receive(:expires_in).and_return(2.minutes)
|
37
|
-
expect(subject.expires_in_seconds).to eq(60)
|
37
|
+
expect(subject.expires_in_seconds).to eq(60)
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it 'should return 0 when expired' do
|
41
41
|
allow(subject).to receive(:expires_in).and_return(30.seconds)
|
42
|
-
expect(subject.expires_in_seconds).to eq(0)
|
42
|
+
expect(subject.expires_in_seconds).to eq(0)
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'should return nil when expires_in is nil' do
|
46
46
|
allow(subject).to receive(:expires_in).and_return(nil)
|
47
47
|
expect(subject.expires_in_seconds).to be_nil
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
end
|
51
51
|
end
|