doorkeeper 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

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
@@ -6,32 +6,31 @@ module Doorkeeper
6
6
 
7
7
  def initialize
8
8
  @controllers = {
9
- :authorizations => 'doorkeeper/authorizations',
10
- :applications => 'doorkeeper/applications',
11
- :authorized_applications => 'doorkeeper/authorized_applications',
12
- :tokens => 'doorkeeper/tokens',
13
- :token_info => 'doorkeeper/token_info'
9
+ authorizations: 'doorkeeper/authorizations',
10
+ applications: 'doorkeeper/applications',
11
+ authorized_applications: 'doorkeeper/authorized_applications',
12
+ tokens: 'doorkeeper/tokens',
13
+ token_info: 'doorkeeper/token_info'
14
14
  }
15
15
 
16
16
  @as = {
17
- :authorizations => :authorization,
18
- :tokens => :token,
19
- :token_info => :token_info
17
+ authorizations: :authorization,
18
+ tokens: :token,
19
+ token_info: :token_info
20
20
  }
21
21
 
22
22
  @skips = []
23
-
24
23
  end
25
24
 
26
25
  def [](routes)
27
26
  {
28
- :controllers => @controllers[routes],
29
- :as => @as[routes]
27
+ controllers: @controllers[routes],
28
+ as: @as[routes]
30
29
  }
31
30
  end
32
31
 
33
32
  def skipped?(controller)
34
- return @skips.include?(controller)
33
+ @skips.include?(controller)
35
34
  end
36
35
  end
37
36
  end
@@ -7,23 +7,23 @@ require 'doorkeeper/request/token'
7
7
 
8
8
  module Doorkeeper
9
9
  module Request
10
- extend self
10
+ module_function
11
11
 
12
12
  def authorization_strategy(strategy)
13
- get_strategy strategy, %w[code token]
13
+ get_strategy strategy, Doorkeeper.configuration.authorization_response_types
14
14
  rescue NameError
15
15
  raise Errors::InvalidAuthorizationStrategy
16
16
  end
17
17
 
18
18
  def token_strategy(strategy)
19
- get_strategy strategy, %w[password client_credentials authorization_code refresh_token]
19
+ get_strategy strategy, Doorkeeper.configuration.token_grant_types
20
20
  rescue NameError
21
21
  raise Errors::InvalidTokenStrategy
22
22
  end
23
23
 
24
24
  def get_strategy(strategy, available)
25
- raise Errors::MissingRequestStrategy unless strategy.present?
26
- raise NameError unless available.include?(strategy.to_s)
25
+ fail Errors::MissingRequestStrategy unless strategy.present?
26
+ fail NameError unless available.include?(strategy.to_s)
27
27
  "Doorkeeper::Request::#{strategy.to_s.camelize}".constantize
28
28
  end
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module Doorkeeper
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -3,7 +3,7 @@ require 'rails/generators/active_record'
3
3
  class Doorkeeper::ApplicationOwnerGenerator < Rails::Generators::Base
4
4
  include Rails::Generators::Migration
5
5
  source_root File.expand_path('../templates', __FILE__)
6
- desc "Provide support for client application ownership."
6
+ desc 'Provide support for client application ownership.'
7
7
 
8
8
  def application_owner
9
9
  migration_template 'add_owner_to_application_migration.rb', 'db/migrate/add_owner_to_application.rb'
@@ -1,12 +1,12 @@
1
1
  class Doorkeeper::InstallGenerator < ::Rails::Generators::Base
2
2
  include Rails::Generators::Migration
3
3
  source_root File.expand_path('../templates', __FILE__)
4
- desc "Installs Doorkeeper."
4
+ desc 'Installs Doorkeeper.'
5
5
 
6
6
  def install
7
- template "initializer.rb", "config/initializers/doorkeeper.rb"
8
- copy_file "../../../../config/locales/en.yml", "config/locales/doorkeeper.en.yml"
9
- route "use_doorkeeper"
10
- readme "README"
7
+ template 'initializer.rb', 'config/initializers/doorkeeper.rb'
8
+ copy_file File.expand_path('../../../../config/locales/en.yml', __FILE__), 'config/locales/doorkeeper.en.yml'
9
+ route 'use_doorkeeper'
10
+ readme 'README'
11
11
  end
12
12
  end
@@ -3,7 +3,7 @@ require 'rails/generators/active_record'
3
3
  class Doorkeeper::MigrationGenerator < ::Rails::Generators::Base
4
4
  include Rails::Generators::Migration
5
5
  source_root File.expand_path('../templates', __FILE__)
6
- desc "Installs Doorkeeper migration file."
6
+ desc 'Installs Doorkeeper migration file.'
7
7
 
8
8
  def install
9
9
  migration_template 'migration.rb', 'db/migrate/create_doorkeeper_tables.rb'
@@ -2,10 +2,10 @@ module Doorkeeper
2
2
  module MongoMapper
3
3
  class IndexesGenerator < ::Rails::Generators::Base
4
4
  source_root File.expand_path('../../templates', __FILE__)
5
- desc "Creates an indexes file for use with MongoMapper's rake db:index"
5
+ desc 'Creates an indexes file for use with MongoMapper\'s rake db:index'
6
6
 
7
7
  def install
8
- template "indexes.rb", "db/indexes.rb"
8
+ template 'indexes.rb' 'db/indexes.rb'
9
9
  end
10
10
  end
11
11
  end
@@ -1,7 +1,7 @@
1
1
  class AddOwnerToApplication < ActiveRecord::Migration
2
2
  def change
3
- add_column :oauth_applications, :owner_id, :integer, :null => true
4
- add_column :oauth_applications, :owner_type, :string, :null => true
3
+ add_column :oauth_applications, :owner_id, :integer, null: true
4
+ add_column :oauth_applications, :owner_type, :string, null: true
5
5
  add_index :oauth_applications, [:owner_id, :owner_type]
6
6
  end
7
7
  end
@@ -5,7 +5,7 @@ Doorkeeper.configure do
5
5
 
6
6
  # This block will be called to check whether the resource owner is authenticated or not.
7
7
  resource_owner_authenticator do
8
- raise "Please configure doorkeeper resource_owner_authenticator block located in #{__FILE__}"
8
+ fail "Please configure doorkeeper resource_owner_authenticator block located in #{__FILE__}"
9
9
  # Put your resource owner authentication logic here.
10
10
  # Example implementation:
11
11
  # User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
@@ -35,7 +35,8 @@ Doorkeeper.configure do
35
35
  # enable_application_owner :confirmation => false
36
36
 
37
37
  # Define access token scopes for your provider
38
- # For more information go to https://github.com/applicake/doorkeeper/wiki/Using-Scopes
38
+ # For more information go to
39
+ # https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes
39
40
  # default_scopes :public
40
41
  # optional_scopes :write, :update
41
42
 
@@ -58,6 +59,18 @@ Doorkeeper.configure do
58
59
  #
59
60
  # test_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'
60
61
 
62
+ # Specify what grant flows are enabled in array of Strings. The valid
63
+ # strings and the flows they enable are:
64
+ #
65
+ # "authorization_code" => Authorization Code Grant Flow
66
+ # "implicit" => Implicit Grant Flow
67
+ # "password" => Resource Owner Password Credentials Grant Flow
68
+ # "client_credentials" => Client Credentials Grant Flow
69
+ #
70
+ # If not specified, Doorkeeper enables all the four grant flows.
71
+ #
72
+ # grant_flows %w(authorization_code implicit password client_credentials)
73
+
61
74
  # Under some circumstances you might want to have applications auto-approved,
62
75
  # so that the user skips the authorization step.
63
76
  # For example if dealing with trusted a application.
@@ -65,7 +78,7 @@ Doorkeeper.configure do
65
78
  # client.superapp? or resource_owner.admin?
66
79
  # end
67
80
 
68
- # WWW-Authenticate Realm (default "Doorkeeper").
81
+ # WWW-Authenticate Realm (default "Doorkeeper").
69
82
  # realm "Doorkeeper"
70
83
 
71
84
  # Allow dynamic query parameters (disabled by default)
@@ -1,42 +1,41 @@
1
1
  class CreateDoorkeeperTables < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :oauth_applications do |t|
4
- t.string :name, :null => false
5
- t.string :uid, :null => false
6
- t.string :secret, :null => false
7
- t.text :redirect_uri, :null => false
4
+ t.string :name, null: false
5
+ t.string :uid, null: false
6
+ t.string :secret, null: false
7
+ t.text :redirect_uri, null: false
8
8
  t.timestamps
9
9
  end
10
10
 
11
- add_index :oauth_applications, :uid, :unique => true
11
+ add_index :oauth_applications, :uid, unique: true
12
12
 
13
13
  create_table :oauth_access_grants do |t|
14
- t.integer :resource_owner_id, :null => false
15
- t.integer :application_id, :null => false
16
- t.string :token, :null => false
17
- t.integer :expires_in, :null => false
18
- t.text :redirect_uri, :null => false
19
- t.datetime :created_at, :null => false
14
+ t.integer :resource_owner_id, null: false
15
+ t.integer :application_id, null: false
16
+ t.string :token, null: false
17
+ t.integer :expires_in, null: false
18
+ t.text :redirect_uri, null: false
19
+ t.datetime :created_at, null: false
20
20
  t.datetime :revoked_at
21
21
  t.string :scopes
22
22
  end
23
23
 
24
- add_index :oauth_access_grants, :token, :unique => true
24
+ add_index :oauth_access_grants, :token, unique: true
25
25
 
26
26
  create_table :oauth_access_tokens do |t|
27
27
  t.integer :resource_owner_id
28
28
  t.integer :application_id
29
- t.string :token, :null => false
29
+ t.string :token, null: false
30
30
  t.string :refresh_token
31
31
  t.integer :expires_in
32
32
  t.datetime :revoked_at
33
- t.datetime :created_at, :null => false
33
+ t.datetime :created_at, null: false
34
34
  t.string :scopes
35
35
  end
36
36
 
37
- add_index :oauth_access_tokens, :token, :unique => true
37
+ add_index :oauth_access_tokens, :token, unique: true
38
38
  add_index :oauth_access_tokens, :resource_owner_id
39
- add_index :oauth_access_tokens, :refresh_token, :unique => true
40
-
39
+ add_index :oauth_access_tokens, :refresh_token, unique: true
41
40
  end
42
41
  end
@@ -3,7 +3,7 @@ module Doorkeeper
3
3
  class ViewsGenerator < ::Rails::Generators::Base
4
4
  source_root File.expand_path('../../../../app/views/doorkeeper', __FILE__)
5
5
 
6
- desc "Copies default Doorkeeper views to your application."
6
+ desc 'Copies default Doorkeeper views to your application.'
7
7
 
8
8
  def manifest
9
9
  directory 'applications', 'app/views/doorkeeper/applications'
@@ -2,19 +2,19 @@ require 'spec_helper_integration'
2
2
 
3
3
  module Doorkeeper
4
4
  describe ApplicationsController do
5
- context "when admin is not authenticated" do
5
+ context 'when admin is not authenticated' do
6
6
  before do
7
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
11
11
 
12
- it "redirects as set in Doorkeeper.authenticate_admin" do
12
+ it 'redirects as set in Doorkeeper.authenticate_admin' do
13
13
  get :index
14
14
  expect(response).to redirect_to(controller.main_app.root_url)
15
15
  end
16
16
 
17
- it "doesn't create application" do
17
+ it 'does not create application' do
18
18
  expect do
19
19
  post :create, application: {
20
20
  name: 'Example',
@@ -23,12 +23,12 @@ module Doorkeeper
23
23
  end
24
24
  end
25
25
 
26
- context "when admin is authenticated" do
26
+ context 'when admin is authenticated' do
27
27
  before do
28
28
  allow(Doorkeeper.configuration).to receive(:authenticate_admin).and_return(->(arg) { true })
29
29
  end
30
30
 
31
- it "creates application" do
31
+ it 'creates application' do
32
32
  expect do
33
33
  post :create, application: {
34
34
  name: 'Example',
@@ -37,7 +37,7 @@ module Doorkeeper
37
37
  expect(response).to be_redirect
38
38
  end
39
39
 
40
- it "does not allow mass assignment of uid or secret" do
40
+ it 'does not allow mass assignment of uid or secret' do
41
41
  application = FactoryGirl.create(:application)
42
42
  put :update, id: application.id, application: {
43
43
  uid: '1A2B3C4D',
@@ -46,7 +46,7 @@ module Doorkeeper
46
46
  expect(application.reload.uid).not_to eq '1A2B3C4D'
47
47
  end
48
48
 
49
- it "updates application" do
49
+ it 'updates application' do
50
50
  application = FactoryGirl.create(:application)
51
51
  put :update, id: application.id, application: {
52
52
  name: 'Example',
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper_integration'
2
2
 
3
- describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
3
+ describe Doorkeeper::AuthorizationsController, 'implicit grant flow' do
4
4
  include AuthorizationRequestHelper
5
5
 
6
6
  def fragments(param)
@@ -9,88 +9,88 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
9
9
  end
10
10
 
11
11
  def translated_error_message(key)
12
- I18n.translate key, :scope => [:doorkeeper, :errors, :messages]
12
+ I18n.translate key, scope: [:doorkeeper, :errors, :messages]
13
13
  end
14
14
 
15
15
  let(:client) { FactoryGirl.create :application }
16
- let(:user) { User.create!(:name => "Joe", :password => "sekret") }
16
+ let(:user) { User.create!(name: 'Joe', password: 'sekret') }
17
17
 
18
18
  before do
19
19
  allow(controller).to receive(:current_resource_owner).and_return(user)
20
20
  end
21
21
 
22
- describe "POST #create" do
22
+ describe 'POST #create' do
23
23
  before do
24
- post :create, :client_id => client.uid, :response_type => "token", :redirect_uri => client.redirect_uri
24
+ post :create, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri
25
25
  end
26
26
 
27
- it "redirects after authorization" do
27
+ it 'redirects after authorization' do
28
28
  expect(response).to be_redirect
29
29
  end
30
30
 
31
- it "redirects to client redirect uri" do
32
- expect(response.location).to match(%r[^#{client.redirect_uri}])
31
+ it 'redirects to client redirect uri' do
32
+ expect(response.location).to match(%r{^#{client.redirect_uri}})
33
33
  end
34
34
 
35
- it "includes access token in fragment" do
36
- expect(fragments("access_token")).to eq(Doorkeeper::AccessToken.first.token)
35
+ it 'includes access token in fragment' do
36
+ expect(fragments('access_token')).to eq(Doorkeeper::AccessToken.first.token)
37
37
  end
38
38
 
39
- it "includes token type in fragment" do
40
- expect(fragments("token_type")).to eq('bearer')
39
+ it 'includes token type in fragment' do
40
+ expect(fragments('token_type')).to eq('bearer')
41
41
  end
42
42
 
43
- it "includes token expiration in fragment" do
44
- expect(fragments("expires_in").to_i).to eq(2.hours.to_i)
43
+ it 'includes token expiration in fragment' do
44
+ expect(fragments('expires_in').to_i).to eq(2.hours.to_i)
45
45
  end
46
46
 
47
- it "issues the token for the current client" do
47
+ it 'issues the token for the current client' do
48
48
  expect(Doorkeeper::AccessToken.first.application_id).to eq(client.id)
49
49
  end
50
50
 
51
- it "issues the token for the current resource owner" do
51
+ it 'issues the token for the current resource owner' do
52
52
  expect(Doorkeeper::AccessToken.first.resource_owner_id).to eq(user.id)
53
53
  end
54
54
  end
55
55
 
56
- describe "POST #create with errors" do
56
+ describe 'POST #create with errors' do
57
57
  before do
58
58
  default_scopes_exist :public
59
- post :create, :client_id => client.uid, :response_type => "token", :scope => "invalid", :redirect_uri => client.redirect_uri
59
+ post :create, client_id: client.uid, response_type: 'token', scope: 'invalid', redirect_uri: client.redirect_uri
60
60
  end
61
61
 
62
- it "redirects after authorization" do
62
+ it 'redirects after authorization' do
63
63
  expect(response).to be_redirect
64
64
  end
65
65
 
66
- it "redirects to client redirect uri" do
67
- expect(response.location).to match(%r[^#{client.redirect_uri}])
66
+ it 'redirects to client redirect uri' do
67
+ expect(response.location).to match(%r{^#{client.redirect_uri}})
68
68
  end
69
69
 
70
- it "does not include access token in fragment" do
71
- expect(fragments("access_token")).to be_nil
70
+ it 'does not include access token in fragment' do
71
+ expect(fragments('access_token')).to be_nil
72
72
  end
73
73
 
74
- it "includes error in fragment" do
75
- expect(fragments("error")).to eq('invalid_scope')
74
+ it 'includes error in fragment' do
75
+ expect(fragments('error')).to eq('invalid_scope')
76
76
  end
77
77
 
78
- it "includes error description in fragment" do
79
- expect(fragments("error_description")).to eq(translated_error_message(:invalid_scope))
78
+ it 'includes error description in fragment' do
79
+ expect(fragments('error_description')).to eq(translated_error_message(:invalid_scope))
80
80
  end
81
81
 
82
- it "does not issue any access token" do
82
+ it 'does not issue any access token' do
83
83
  expect(Doorkeeper::AccessToken.all).to be_empty
84
84
  end
85
85
  end
86
86
 
87
- describe "POST #create with application already authorized" do
88
- it "returns the existing access token in a fragment"
87
+ describe 'POST #create with application already authorized' do
88
+ it 'returns the existing access token in a fragment'
89
89
  end
90
90
 
91
- describe "GET #new" do
91
+ describe 'GET #new' do
92
92
  before do
93
- get :new, :client_id => client.uid, :response_type => "token", :redirect_uri => client.redirect_uri
93
+ get :new, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri
94
94
  end
95
95
 
96
96
  it 'renders new template' do
@@ -98,47 +98,47 @@ describe Doorkeeper::AuthorizationsController, "implicit grant flow" do
98
98
  end
99
99
  end
100
100
 
101
- describe "GET #new with skip_authorization true" do
101
+ describe 'GET #new with skip_authorization true' do
102
102
  before do
103
103
  allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc do
104
- true
105
- end)
106
- get :new, :client_id => client.uid, :response_type => "token", :redirect_uri => client.redirect_uri
104
+ true
105
+ end)
106
+ get :new, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri
107
107
  end
108
108
 
109
- it "should redirect immediately" do
109
+ it 'should redirect immediately' do
110
110
  expect(response).to be_redirect
111
- expect(response.location).to match(%r[^#{client.redirect_uri}])
111
+ expect(response.location).to match(%r{^#{client.redirect_uri}})
112
112
  end
113
113
 
114
- it "should issue a token" do
114
+ it 'should issue a token' do
115
115
  expect(Doorkeeper::AccessToken.count).to be 1
116
116
  end
117
117
 
118
- it "includes token type in fragment" do
119
- expect(fragments("token_type")).to eq("bearer")
118
+ it 'includes token type in fragment' do
119
+ expect(fragments('token_type')).to eq('bearer')
120
120
  end
121
121
 
122
- it "includes token expiration in fragment" do
123
- expect(fragments("expires_in").to_i).to eq(2.hours.to_i)
122
+ it 'includes token expiration in fragment' do
123
+ expect(fragments('expires_in').to_i).to eq(2.hours.to_i)
124
124
  end
125
125
 
126
- it "issues the token for the current client" do
126
+ it 'issues the token for the current client' do
127
127
  expect(Doorkeeper::AccessToken.first.application_id).to eq(client.id)
128
128
  end
129
129
 
130
- it "issues the token for the current resource owner" do
130
+ it 'issues the token for the current resource owner' do
131
131
  expect(Doorkeeper::AccessToken.first.resource_owner_id).to eq(user.id)
132
132
  end
133
133
  end
134
134
 
135
- describe "GET #new with errors" do
135
+ describe 'GET #new with errors' do
136
136
  before do
137
137
  default_scopes_exist :public
138
- get :new, :an_invalid => 'request'
138
+ get :new, an_invalid: 'request'
139
139
  end
140
140
 
141
- it "does not redirect" do
141
+ it 'does not redirect' do
142
142
  expect(response).to_not be_redirect
143
143
  end
144
144