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.

Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/CHANGELOG.md +14 -2
  4. data/README.md +93 -42
  5. data/app/controllers/doorkeeper/application_controller.rb +1 -1
  6. data/app/controllers/doorkeeper/applications_controller.rb +4 -4
  7. data/app/controllers/doorkeeper/authorizations_controller.rb +3 -3
  8. data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
  9. data/app/controllers/doorkeeper/token_info_controller.rb +3 -3
  10. data/app/controllers/doorkeeper/tokens_controller.rb +29 -2
  11. data/app/helpers/doorkeeper/form_errors_helper.rb +2 -2
  12. data/app/validators/redirect_uri_validator.rb +1 -1
  13. data/app/views/doorkeeper/applications/_form.html.erb +3 -3
  14. data/app/views/doorkeeper/applications/edit.html.erb +1 -1
  15. data/app/views/doorkeeper/applications/new.html.erb +1 -1
  16. data/app/views/doorkeeper/applications/show.html.erb +1 -1
  17. data/app/views/doorkeeper/authorizations/new.html.erb +5 -5
  18. data/doorkeeper.gemspec +1 -1
  19. data/lib/doorkeeper.rb +31 -31
  20. data/lib/doorkeeper/config.rb +66 -37
  21. data/lib/doorkeeper/doorkeeper_for.rb +6 -3
  22. data/lib/doorkeeper/engine.rb +2 -2
  23. data/lib/doorkeeper/helpers/controller.rb +9 -9
  24. data/lib/doorkeeper/helpers/filter.rb +1 -1
  25. data/lib/doorkeeper/models/access_grant.rb +5 -5
  26. data/lib/doorkeeper/models/access_token.rb +22 -18
  27. data/lib/doorkeeper/models/active_record/access_token.rb +8 -8
  28. data/lib/doorkeeper/models/active_record/application.rb +5 -5
  29. data/lib/doorkeeper/models/application.rb +8 -9
  30. data/lib/doorkeeper/models/expirable.rb +1 -1
  31. data/lib/doorkeeper/models/mongo_mapper/access_grant.rb +2 -2
  32. data/lib/doorkeeper/models/mongo_mapper/access_token.rb +11 -11
  33. data/lib/doorkeeper/models/mongo_mapper/application.rb +4 -4
  34. data/lib/doorkeeper/models/mongoid/version.rb +2 -2
  35. data/lib/doorkeeper/models/mongoid2/access_grant.rb +7 -7
  36. data/lib/doorkeeper/models/mongoid2/access_token.rb +14 -14
  37. data/lib/doorkeeper/models/mongoid2/application.rb +7 -7
  38. data/lib/doorkeeper/models/mongoid3_4/access_grant.rb +7 -7
  39. data/lib/doorkeeper/models/mongoid3_4/access_token.rb +13 -13
  40. data/lib/doorkeeper/models/mongoid3_4/application.rb +6 -6
  41. data/lib/doorkeeper/models/ownership.rb +5 -5
  42. data/lib/doorkeeper/oauth/authorization/code.rb +5 -5
  43. data/lib/doorkeeper/oauth/authorization/token.rb +7 -7
  44. data/lib/doorkeeper/oauth/authorization_code_request.rb +18 -19
  45. data/lib/doorkeeper/oauth/client.rb +1 -1
  46. data/lib/doorkeeper/oauth/client_credentials/creator.rb +4 -4
  47. data/lib/doorkeeper/oauth/client_credentials/issuer.rb +6 -4
  48. data/lib/doorkeeper/oauth/client_credentials/validation.rb +2 -2
  49. data/lib/doorkeeper/oauth/client_credentials_request.rb +11 -15
  50. data/lib/doorkeeper/oauth/code_request.rb +5 -4
  51. data/lib/doorkeeper/oauth/code_response.rb +8 -7
  52. data/lib/doorkeeper/oauth/error.rb +1 -1
  53. data/lib/doorkeeper/oauth/error_response.rb +5 -5
  54. data/lib/doorkeeper/oauth/helpers/uri_checker.rb +1 -1
  55. data/lib/doorkeeper/oauth/invalid_token_response.rb +10 -10
  56. data/lib/doorkeeper/oauth/password_access_token_request.rb +57 -54
  57. data/lib/doorkeeper/oauth/pre_authorization.rb +7 -7
  58. data/lib/doorkeeper/oauth/refresh_token_request.rb +27 -24
  59. data/lib/doorkeeper/oauth/scopes.rb +3 -3
  60. data/lib/doorkeeper/oauth/token.rb +27 -1
  61. data/lib/doorkeeper/oauth/token_request.rb +14 -4
  62. data/lib/doorkeeper/rails/routes.rb +31 -22
  63. data/lib/doorkeeper/rails/routes/mapping.rb +11 -12
  64. data/lib/doorkeeper/request.rb +5 -5
  65. data/lib/doorkeeper/version.rb +1 -1
  66. data/lib/generators/doorkeeper/application_owner_generator.rb +1 -1
  67. data/lib/generators/doorkeeper/install_generator.rb +5 -5
  68. data/lib/generators/doorkeeper/migration_generator.rb +1 -1
  69. data/lib/generators/doorkeeper/mongo_mapper/indexes_generator.rb +2 -2
  70. data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +2 -2
  71. data/lib/generators/doorkeeper/templates/initializer.rb +16 -3
  72. data/lib/generators/doorkeeper/templates/migration.rb +16 -17
  73. data/lib/generators/doorkeeper/views_generator.rb +1 -1
  74. data/spec/controllers/applications_controller_spec.rb +7 -7
  75. data/spec/controllers/authorizations_controller_spec.rb +48 -48
  76. data/spec/controllers/protected_resources_controller_spec.rb +108 -107
  77. data/spec/controllers/token_info_controller_spec.rb +11 -11
  78. data/spec/controllers/tokens_controller_spec.rb +8 -8
  79. data/spec/dummy/app/controllers/custom_authorizations_controller.rb +2 -2
  80. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +3 -3
  81. data/spec/dummy/app/controllers/home_controller.rb +5 -5
  82. data/spec/dummy/app/controllers/metal_controller.rb +1 -1
  83. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +2 -2
  84. data/spec/dummy/app/models/user.rb +3 -3
  85. data/spec/dummy/config/application.rb +8 -9
  86. data/spec/dummy/config/boot.rb +1 -1
  87. data/spec/dummy/config/environments/test.rb +1 -1
  88. data/spec/dummy/config/initializers/doorkeeper.rb +5 -5
  89. data/spec/dummy/config/initializers/session_store.rb +1 -1
  90. data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
  91. data/spec/dummy/config/routes.rb +27 -27
  92. data/spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb +16 -17
  93. data/spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb +3 -3
  94. data/spec/dummy/db/schema.rb +39 -39
  95. data/spec/factories/access_grant.rb +3 -3
  96. data/spec/factories/access_token.rb +1 -1
  97. data/spec/factories/application.rb +3 -3
  98. data/spec/generators/application_owner_generator_spec.rb +6 -7
  99. data/spec/generators/install_generator_spec.rb +9 -9
  100. data/spec/generators/migration_generator_spec.rb +4 -4
  101. data/spec/lib/config_spec.rb +136 -44
  102. data/spec/lib/models/expirable_spec.rb +9 -9
  103. data/spec/lib/models/revocable_spec.rb +4 -4
  104. data/spec/lib/oauth/authorization/uri_builder_spec.rb +4 -4
  105. data/spec/lib/oauth/authorization_code_request_spec.rb +2 -2
  106. data/spec/lib/oauth/client/credentials_spec.rb +4 -4
  107. data/spec/lib/oauth/client/methods_spec.rb +10 -10
  108. data/spec/lib/oauth/client_credentials/issuer_spec.rb +9 -7
  109. data/spec/lib/oauth/client_credentials/validation_spec.rb +2 -2
  110. data/spec/lib/oauth/client_credentials_request_spec.rb +6 -6
  111. data/spec/lib/oauth/client_spec.rb +4 -4
  112. data/spec/lib/oauth/code_request_spec.rb +10 -9
  113. data/spec/lib/oauth/error_response_spec.rb +8 -8
  114. data/spec/lib/oauth/error_spec.rb +1 -1
  115. data/spec/lib/oauth/helpers/scope_checker_spec.rb +17 -17
  116. data/spec/lib/oauth/helpers/unique_token_spec.rb +7 -7
  117. data/spec/lib/oauth/helpers/uri_checker_spec.rb +33 -33
  118. data/spec/lib/oauth/invalid_token_response_spec.rb +4 -4
  119. data/spec/lib/oauth/password_access_token_request_spec.rb +13 -13
  120. data/spec/lib/oauth/pre_authorization_spec.rb +47 -7
  121. data/spec/lib/oauth/refresh_token_request_spec.rb +11 -21
  122. data/spec/lib/oauth/scopes_spec.rb +32 -32
  123. data/spec/lib/oauth/token_request_spec.rb +10 -9
  124. data/spec/lib/oauth/token_response_spec.rb +13 -15
  125. data/spec/lib/oauth/token_spec.rb +24 -10
  126. data/spec/lib/server_spec.rb +24 -2
  127. data/spec/models/doorkeeper/access_grant_spec.rb +8 -8
  128. data/spec/models/doorkeeper/access_token_spec.rb +79 -33
  129. data/spec/models/doorkeeper/application_spec.rb +29 -29
  130. data/spec/requests/applications/applications_request_spec.rb +15 -15
  131. data/spec/requests/applications/authorized_applications_spec.rb +7 -7
  132. data/spec/requests/endpoints/authorization_spec.rb +19 -12
  133. data/spec/requests/endpoints/token_spec.rb +26 -8
  134. data/spec/requests/flows/authorization_code_errors_spec.rb +17 -17
  135. data/spec/requests/flows/authorization_code_spec.rb +28 -28
  136. data/spec/requests/flows/client_credentials_spec.rb +3 -3
  137. data/spec/requests/flows/implicit_grant_errors_spec.rb +5 -5
  138. data/spec/requests/flows/implicit_grant_spec.rb +2 -2
  139. data/spec/requests/flows/password_spec.rb +32 -32
  140. data/spec/requests/flows/refresh_token_spec.rb +23 -23
  141. data/spec/requests/flows/revoke_token_spec.rb +165 -0
  142. data/spec/requests/flows/skip_authorization_spec.rb +10 -10
  143. data/spec/requests/protected_resources/metal_spec.rb +1 -1
  144. data/spec/requests/protected_resources/private_api_spec.rb +5 -5
  145. data/spec/routing/custom_controller_routes_spec.rb +4 -0
  146. data/spec/routing/default_routes_spec.rb +5 -1
  147. data/spec/spec_helper.rb +2 -2
  148. data/spec/spec_helper_integration.rb +8 -10
  149. data/spec/support/helpers/access_token_request_helper.rb +3 -3
  150. data/spec/support/helpers/authorization_request_helper.rb +3 -3
  151. data/spec/support/helpers/config_helper.rb +1 -1
  152. data/spec/support/helpers/model_helper.rb +2 -2
  153. data/spec/support/helpers/request_spec_helper.rb +3 -3
  154. data/spec/support/helpers/url_helper.rb +25 -21
  155. data/spec/support/orm/active_record.rb +4 -4
  156. data/spec/support/orm/mongo_mapper.rb +2 -3
  157. data/spec/support/orm/mongoid.rb +5 -6
  158. data/spec/support/shared/controllers_shared_context.rb +15 -15
  159. data/spec/support/shared/models_shared_examples.rb +13 -13
  160. data/spec/validators/redirect_uri_validator_spec.rb +9 -9
  161. metadata +5 -4
@@ -10,20 +10,20 @@ describe 'Revocable' do
10
10
  end
11
11
 
12
12
  describe :revoke do
13
- it "updates :revoked_at attribute with current time" do
14
- clock = double :now => double
13
+ it 'updates :revoked_at attribute with current time' do
14
+ clock = double now: double
15
15
  expect(subject).to receive(:update_column).with(:revoked_at, clock.now)
16
16
  subject.revoke(clock)
17
17
  end
18
18
  end
19
19
 
20
20
  describe :revoked? do
21
- it "is revoked if :revoked_at is set" do
21
+ it 'is revoked if :revoked_at is set' do
22
22
  allow(subject).to receive(:revoked_at).and_return(double)
23
23
  expect(subject).to be_revoked
24
24
  end
25
25
 
26
- it "is not revoked if :revoked_at is not set" do
26
+ it 'is not revoked if :revoked_at is not set' do
27
27
  allow(subject).to receive(:revoked_at).and_return(nil)
28
28
  expect(subject).not_to be_revoked
29
29
  end
@@ -11,17 +11,17 @@ module Doorkeeper::OAuth::Authorization
11
11
 
12
12
  describe :uri_with_query do
13
13
  it 'returns the uri with query' do
14
- uri = subject.uri_with_query 'http://example.com/', :parameter => 'value'
14
+ uri = subject.uri_with_query 'http://example.com/', parameter: 'value'
15
15
  expect(uri).to eq('http://example.com/?parameter=value')
16
16
  end
17
17
 
18
18
  it 'rejects nil values' do
19
- uri = subject.uri_with_query 'http://example.com/', :parameter => ""
19
+ uri = subject.uri_with_query 'http://example.com/', parameter: ''
20
20
  expect(uri).to eq('http://example.com/?')
21
21
  end
22
22
 
23
23
  it 'preserves original query parameters' do
24
- uri = subject.uri_with_query 'http://example.com/?query1=value', :parameter => 'value'
24
+ uri = subject.uri_with_query 'http://example.com/?query1=value', parameter: 'value'
25
25
  expect(uri).to match(/query1=value/)
26
26
  expect(uri).to match(/parameter=value/)
27
27
  end
@@ -29,7 +29,7 @@ module Doorkeeper::OAuth::Authorization
29
29
 
30
30
  describe :uri_with_fragment do
31
31
  it 'returns uri with parameters as fragments' do
32
- uri = subject.uri_with_fragment 'http://example.com/', :parameter => 'value'
32
+ uri = subject.uri_with_fragment 'http://example.com/', parameter: 'value'
33
33
  expect(uri).to eq('http://example.com/#parameter=value')
34
34
  end
35
35
  end
@@ -2,12 +2,12 @@ require 'spec_helper_integration'
2
2
 
3
3
  module Doorkeeper::OAuth
4
4
  describe AuthorizationCodeRequest do
5
- let(:server) { double :server, :access_token_expires_in => 2.days, :refresh_token_enabled? => false }
5
+ let(:server) { double :server, access_token_expires_in: 2.days, refresh_token_enabled?: false }
6
6
  let(:grant) { FactoryGirl.create :access_grant }
7
7
  let(:client) { grant.application }
8
8
 
9
9
  subject do
10
- AuthorizationCodeRequest.new server, grant, client, :redirect_uri => client.redirect_uri
10
+ AuthorizationCodeRequest.new server, grant, client, redirect_uri: client.redirect_uri
11
11
  end
12
12
 
13
13
  it 'issues a new token for the client' do
@@ -5,15 +5,15 @@ require 'doorkeeper/oauth/client'
5
5
  class Doorkeeper::OAuth::Client
6
6
  describe Credentials do
7
7
  it 'is blank when any of the credentials is blank' do
8
- expect(Credentials.new(nil, "something")).to be_blank
9
- expect(Credentials.new("something", nil)).to be_blank
8
+ expect(Credentials.new(nil, 'something')).to be_blank
9
+ expect(Credentials.new('something', nil)).to be_blank
10
10
  end
11
11
 
12
12
  describe :from_request do
13
13
  let(:request) { double.as_null_object }
14
14
 
15
15
  let(:method) do
16
- lambda { |request| return 'uid', 'secret' }
16
+ ->(request) { return 'uid', 'secret' }
17
17
  end
18
18
 
19
19
  it 'accepts anything that responds to #call' do
@@ -29,7 +29,7 @@ class Doorkeeper::OAuth::Client
29
29
  it 'stops at the first credentials found' do
30
30
  not_called_method = double
31
31
  expect(not_called_method).not_to receive(:call)
32
- credentials = Credentials.from_request request, lambda { |r| }, method, not_called_method
32
+ credentials = Credentials.from_request request, ->(r) {}, method, not_called_method
33
33
  end
34
34
 
35
35
  it 'returns new Credentials' do
@@ -4,8 +4,8 @@ require 'doorkeeper/oauth/client'
4
4
 
5
5
  class Doorkeeper::OAuth::Client
6
6
  describe 'Methods' do
7
- let(:client_id) { "some-uid" }
8
- let(:client_secret) { "some-secret" }
7
+ let(:client_id) { 'some-uid' }
8
+ let(:client_secret) { 'some-secret' }
9
9
 
10
10
  subject do
11
11
  Class.new do
@@ -15,15 +15,15 @@ class Doorkeeper::OAuth::Client
15
15
 
16
16
  describe :from_params do
17
17
  it 'returns credentials from parameters when Authorization header is not available' do
18
- request = double :parameters => { :client_id => client_id, :client_secret => client_secret }
18
+ request = double parameters: { client_id: client_id, client_secret: client_secret }
19
19
  uid, secret = subject.from_params(request)
20
20
 
21
- expect(uid).to eq("some-uid")
22
- expect(secret).to eq("some-secret")
21
+ expect(uid).to eq('some-uid')
22
+ expect(secret).to eq('some-secret')
23
23
  end
24
24
 
25
25
  it 'is blank when there are no credentials' do
26
- request = double :parameters => {}
26
+ request = double parameters: {}
27
27
  uid, secret = subject.from_params(request)
28
28
 
29
29
  expect(uid).to be_blank
@@ -35,15 +35,15 @@ class Doorkeeper::OAuth::Client
35
35
  let(:credentials) { Base64.encode64("#{client_id}:#{client_secret}") }
36
36
 
37
37
  it 'decodes the credentials' do
38
- request = double :authorization => "Basic #{credentials}"
38
+ request = double authorization: "Basic #{credentials}"
39
39
  uid, secret = subject.from_basic(request)
40
40
 
41
- expect(uid).to eq("some-uid")
42
- expect(secret).to eq("some-secret")
41
+ expect(uid).to eq('some-uid')
42
+ expect(secret).to eq('some-secret')
43
43
  end
44
44
 
45
45
  it 'is blank if Authorization is not Basic' do
46
- request = double :authorization => "#{credentials}"
46
+ request = double authorization: "#{credentials}"
47
47
  uid, secret = subject.from_basic(request)
48
48
 
49
49
  expect(uid).to be_blank
@@ -5,13 +5,13 @@ require 'doorkeeper/oauth/client_credentials/issuer'
5
5
  class Doorkeeper::OAuth::ClientCredentialsRequest
6
6
  describe Issuer do
7
7
  let(:creator) { double :acces_token_creator }
8
- let(:server) { double :server, :access_token_expires_in => 100 }
9
- let(:validation) { double :validation, :valid? => true }
8
+ let(:server) { double :server, access_token_expires_in: 100 }
9
+ let(:validation) { double :validation, valid?: true }
10
10
 
11
11
  subject { Issuer.new(server, validation) }
12
12
 
13
13
  describe :create do
14
- let(:client) { double :client, :id => 'some-id' }
14
+ let(:client) { double :client, id: 'some-id' }
15
15
  let(:scopes) { 'some scope' }
16
16
 
17
17
  it 'creates and sets the token' do
@@ -22,10 +22,12 @@ class Doorkeeper::OAuth::ClientCredentialsRequest
22
22
  end
23
23
 
24
24
  it 'creates with correct token parameters' do
25
- expect(creator).to receive(:call).with(client, scopes, {
26
- :expires_in => 100,
27
- :use_refresh_token => false
28
- })
25
+ expect(creator).to receive(:call).with(
26
+ client,
27
+ scopes,
28
+ expires_in: 100,
29
+ use_refresh_token: false
30
+ )
29
31
 
30
32
  subject.create client, scopes, creator
31
33
  end
@@ -4,8 +4,8 @@ require 'doorkeeper/oauth/client_credentials/validation'
4
4
 
5
5
  class Doorkeeper::OAuth::ClientCredentialsRequest
6
6
  describe Validation do
7
- let(:server) { double :server, :scopes => nil }
8
- let(:request) { double :request, :client => double, :original_scopes => nil }
7
+ let(:server) { double :server, scopes: nil }
8
+ let(:request) { double :request, client: double, original_scopes: nil }
9
9
 
10
10
  subject { Validation.new(server, request) }
11
11
 
@@ -5,9 +5,9 @@ require 'doorkeeper/oauth/client_credentials_request'
5
5
 
6
6
  module Doorkeeper::OAuth
7
7
  describe ClientCredentialsRequest do
8
- let(:server) { double :default_scopes => nil }
8
+ let(:server) { double default_scopes: nil }
9
9
  let(:client) { double }
10
- let(:token_creator) { double :issuer, :create => true, :token => double }
10
+ let(:token_creator) { double :issuer, create: true, token: double }
11
11
 
12
12
  subject { ClientCredentialsRequest.new(server, client) }
13
13
 
@@ -27,7 +27,7 @@ module Doorkeeper::OAuth
27
27
 
28
28
  context 'if issue was not created' do
29
29
  before do
30
- subject.issuer = double :create => false, :error => :invalid
30
+ subject.issuer = double create: false, error: :invalid
31
31
  end
32
32
 
33
33
  it 'has an error response' do
@@ -42,7 +42,7 @@ module Doorkeeper::OAuth
42
42
  end
43
43
 
44
44
  context 'with scopes' do
45
- let(:default_scopes) { Doorkeeper::OAuth::Scopes.from_string("public email") }
45
+ let(:default_scopes) { Doorkeeper::OAuth::Scopes.from_string('public email') }
46
46
 
47
47
  before do
48
48
  allow(server).to receive(:default_scopes).and_return(default_scopes)
@@ -54,9 +54,9 @@ module Doorkeeper::OAuth
54
54
  end
55
55
 
56
56
  it 'issues an access token with requested scopes' do
57
- subject = ClientCredentialsRequest.new(server, client, :scope => "email")
57
+ subject = ClientCredentialsRequest.new(server, client, scope: 'email')
58
58
  subject.issuer = token_creator
59
- expect(token_creator).to receive(:create).with(client, Doorkeeper::OAuth::Scopes.from_string("email"))
59
+ expect(token_creator).to receive(:create).with(client, Doorkeeper::OAuth::Scopes.from_string('email'))
60
60
  subject.authorize
61
61
  end
62
62
  end
@@ -22,16 +22,16 @@ module Doorkeeper::OAuth
22
22
 
23
23
  describe :authenticate do
24
24
  it 'returns the authenticated client via credentials' do
25
- credentials = Client::Credentials.new("some-uid", "some-secret")
25
+ credentials = Client::Credentials.new('some-uid', 'some-secret')
26
26
  authenticator = double
27
- expect(authenticator).to receive(:call).with("some-uid", "some-secret").and_return(double)
27
+ expect(authenticator).to receive(:call).with('some-uid', 'some-secret').and_return(double)
28
28
  expect(Client.authenticate(credentials, authenticator)).to be_a(Client)
29
29
  end
30
30
 
31
31
  it 'retunrs nil if client was not authenticated' do
32
- credentials = Client::Credentials.new("some-uid", "some-secret")
32
+ credentials = Client::Credentials.new('some-uid', 'some-secret')
33
33
  authenticator = double
34
- expect(authenticator).to receive(:call).with("some-uid", "some-secret").and_return(nil)
34
+ expect(authenticator).to receive(:call).with('some-uid', 'some-secret').and_return(nil)
35
35
  expect(Client.authenticate(credentials, authenticator)).to be_nil
36
36
  end
37
37
  end
@@ -3,17 +3,18 @@ require 'spec_helper_integration'
3
3
  module Doorkeeper::OAuth
4
4
  describe CodeRequest do
5
5
  let(:pre_auth) do
6
- double(:pre_auth, {
7
- :client => double(:application, :id => 9990),
8
- :redirect_uri => 'http://tst.com/cb',
9
- :scopes => nil,
10
- :state => nil,
11
- :error => nil,
12
- :authorizable? => true
13
- })
6
+ double(
7
+ :pre_auth,
8
+ client: double(:application, id: 9990),
9
+ redirect_uri: 'http://tst.com/cb',
10
+ scopes: nil,
11
+ state: nil,
12
+ error: nil,
13
+ authorizable?: true
14
+ )
14
15
  end
15
16
 
16
- let(:owner) { double :owner, :id => 8900 }
17
+ let(:owner) { double :owner, id: 8900 }
17
18
 
18
19
  subject do
19
20
  CodeRequest.new(pre_auth, owner)
@@ -13,28 +13,28 @@ module Doorkeeper::OAuth
13
13
 
14
14
  describe :from_request do
15
15
  it 'has the error from request' do
16
- error = ErrorResponse.from_request double(:error => :some_error)
16
+ error = ErrorResponse.from_request double(error: :some_error)
17
17
  expect(error.name).to eq(:some_error)
18
18
  end
19
19
 
20
20
  it 'ignores state if request does not respond to state' do
21
- error = ErrorResponse.from_request double(:error => :some_error)
21
+ error = ErrorResponse.from_request double(error: :some_error)
22
22
  expect(error.state).to be_nil
23
23
  end
24
24
 
25
25
  it 'has state if request responds to state' do
26
- error = ErrorResponse.from_request double(:error => :some_error, :state => :hello)
26
+ error = ErrorResponse.from_request double(error: :some_error, state: :hello)
27
27
  expect(error.state).to eq(:hello)
28
28
  end
29
29
  end
30
30
 
31
31
  it 'ignores empty error values' do
32
- subject = ErrorResponse.new(:error => :some_error, :state => nil)
32
+ subject = ErrorResponse.new(error: :some_error, state: nil)
33
33
  expect(subject.body).not_to have_key(:state)
34
34
  end
35
35
 
36
36
  describe '.body' do
37
- subject { ErrorResponse.new(:name => :some_error, :state => :some_state).body }
37
+ subject { ErrorResponse.new(name: :some_error, state: :some_state).body }
38
38
 
39
39
  describe '#body' do
40
40
  it { should have_key(:error) }
@@ -44,7 +44,7 @@ module Doorkeeper::OAuth
44
44
  end
45
45
 
46
46
  describe '.authenticate_info' do
47
- let(:error_response) { ErrorResponse.new(:name => :some_error, :state => :some_state) }
47
+ let(:error_response) { ErrorResponse.new(name: :some_error, state: :some_state) }
48
48
  subject { error_response.authenticate_info }
49
49
 
50
50
  it { should include("realm=\"#{error_response.realm}\"") }
@@ -53,9 +53,9 @@ module Doorkeeper::OAuth
53
53
  end
54
54
 
55
55
  describe '.headers' do
56
- subject { ErrorResponse.new(:name => :some_error, :state => :some_state).headers }
56
+ subject { ErrorResponse.new(name: :some_error, state: :some_state).headers }
57
57
 
58
- it { should include "WWW-Authenticate" }
58
+ it { should include 'WWW-Authenticate' }
59
59
  end
60
60
  end
61
61
  end
@@ -11,7 +11,7 @@ module Doorkeeper::OAuth
11
11
 
12
12
  describe :description do
13
13
  it 'is translated from translation messages' do
14
- expect(I18n).to receive(:translate).with(:some_error, :scope => [:doorkeeper, :errors, :messages])
14
+ expect(I18n).to receive(:translate).with(:some_error, scope: [:doorkeeper, :errors, :messages])
15
15
  subject.description
16
16
  end
17
17
  end
@@ -4,71 +4,71 @@ require 'doorkeeper/oauth/helpers/scope_checker'
4
4
  require 'doorkeeper/oauth/scopes'
5
5
 
6
6
  module Doorkeeper::OAuth::Helpers
7
- describe ScopeChecker, ".matches?" do
7
+ describe ScopeChecker, '.matches?' do
8
8
  def new_scope(*args)
9
9
  Doorkeeper::OAuth::Scopes.from_array args
10
10
  end
11
11
 
12
- it "true if scopes matches" do
12
+ it 'true if scopes matches' do
13
13
  scopes = new_scope :public
14
14
  scopes_to_match = new_scope :public
15
15
  expect(ScopeChecker.matches?(scopes, scopes_to_match)).to be_true
16
16
  end
17
17
 
18
- it "is false when scopes differs" do
18
+ it 'is false when scopes differs' do
19
19
  scopes = new_scope :public
20
20
  scopes_to_match = new_scope :write
21
21
  expect(ScopeChecker.matches?(scopes, scopes_to_match)).to be_false
22
22
  end
23
23
 
24
- it "is false when scope in array is missing" do
24
+ it 'is false when scope in array is missing' do
25
25
  scopes = new_scope :public
26
26
  scopes_to_match = new_scope :public, :write
27
27
  expect(ScopeChecker.matches?(scopes, scopes_to_match)).to be_false
28
28
  end
29
29
 
30
- it "is false when scope in string is missing" do
30
+ it 'is false when scope in string is missing' do
31
31
  scopes = new_scope :public, :write
32
32
  scopes_to_match = new_scope :public
33
33
  expect(ScopeChecker.matches?(scopes, scopes_to_match)).to be_false
34
34
  end
35
35
 
36
- it "is false when any of attributes is nil" do
36
+ it 'is false when any of attributes is nil' do
37
37
  expect(ScopeChecker.matches?(nil, double)).to be_false
38
38
  expect(ScopeChecker.matches?(double, nil)).to be_false
39
39
  end
40
40
  end
41
41
 
42
- describe ScopeChecker, ".valid?" do
42
+ describe ScopeChecker, '.valid?' do
43
43
  let(:server_scopes) { Doorkeeper::OAuth::Scopes.new }
44
44
 
45
- it "is valid if scope is present" do
45
+ it 'is valid if scope is present' do
46
46
  server_scopes.add :scope
47
- expect(ScopeChecker.valid?("scope", server_scopes)).to be_true
47
+ expect(ScopeChecker.valid?('scope', server_scopes)).to be_true
48
48
  end
49
49
 
50
- it "is invalid if includes tabs space" do
50
+ it 'is invalid if includes tabs space' do
51
51
  expect(ScopeChecker.valid?("\tsomething", server_scopes)).to be_false
52
52
  end
53
53
 
54
- it "is invalid if scope is not present" do
54
+ it 'is invalid if scope is not present' do
55
55
  expect(ScopeChecker.valid?(nil, server_scopes)).to be_false
56
56
  end
57
57
 
58
- it "is invalid if scope is blank" do
59
- expect(ScopeChecker.valid?(" ", server_scopes)).to be_false
58
+ it 'is invalid if scope is blank' do
59
+ expect(ScopeChecker.valid?(' ', server_scopes)).to be_false
60
60
  end
61
61
 
62
- it "is invalid if includes return space" do
62
+ it 'is invalid if includes return space' do
63
63
  expect(ScopeChecker.valid?("scope\r", server_scopes)).to be_false
64
64
  end
65
65
 
66
- it "is invalid if includes new lines" do
66
+ it 'is invalid if includes new lines' do
67
67
  expect(ScopeChecker.valid?("scope\nanother", server_scopes)).to be_false
68
68
  end
69
69
 
70
- it "is invalid if any scope is not included in server scopes" do
71
- expect(ScopeChecker.valid?("scope another", server_scopes)).to be_false
70
+ it 'is invalid if any scope is not included in server scopes' do
71
+ expect(ScopeChecker.valid?('scope another', server_scopes)).to be_false
72
72
  end
73
73
  end
74
74
  end
@@ -4,17 +4,17 @@ require 'doorkeeper/oauth/helpers/unique_token'
4
4
  module Doorkeeper::OAuth::Helpers
5
5
  describe UniqueToken do
6
6
  let :generator do
7
- lambda { |size| "a" * size }
7
+ ->(size) { 'a' * size }
8
8
  end
9
9
 
10
- it "is able to customize the generator method" do
11
- token = UniqueToken.generate(:generator => generator)
12
- expect(token).to eq("a" * 32)
10
+ it 'is able to customize the generator method' do
11
+ token = UniqueToken.generate(generator: generator)
12
+ expect(token).to eq('a' * 32)
13
13
  end
14
14
 
15
- it "is able to customize the size of the token" do
16
- token = UniqueToken.generate(:generator => generator, :size => 2)
17
- expect(token).to eq("aa")
15
+ it 'is able to customize the size of the token' do
16
+ token = UniqueToken.generate(generator: generator, size: 2)
17
+ expect(token).to eq('aa')
18
18
  end
19
19
  end
20
20
  end