devise 3.5.10 → 4.0.0.rc1
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.
- checksums.yaml +4 -4
- data/.travis.yml +9 -9
- data/CHANGELOG.md +33 -1188
- data/Gemfile +0 -1
- data/Gemfile.lock +15 -18
- data/MIT-LICENSE +1 -1
- data/README.md +20 -10
- data/app/controllers/devise/omniauth_callbacks_controller.rb +4 -4
- data/app/controllers/devise/passwords_controller.rb +2 -2
- data/app/controllers/devise/registrations_controller.rb +2 -2
- data/app/controllers/devise/sessions_controller.rb +4 -4
- data/app/controllers/devise/unlocks_controller.rb +1 -1
- data/app/controllers/devise_controller.rb +11 -7
- data/devise.gemspec +2 -3
- data/gemfiles/Gemfile.rails-4.1-stable +0 -1
- data/gemfiles/Gemfile.rails-4.1-stable.lock +38 -41
- data/gemfiles/Gemfile.rails-4.2-stable +0 -1
- data/gemfiles/Gemfile.rails-4.2-stable.lock +47 -50
- data/gemfiles/Gemfile.rails-5.0-beta +37 -0
- data/gemfiles/Gemfile.rails-5.0-beta.lock +242 -0
- data/lib/devise.rb +8 -8
- data/lib/devise/controllers/helpers.rb +7 -11
- data/lib/devise/failure_app.rb +17 -9
- data/lib/devise/models/authenticatable.rb +5 -1
- data/lib/devise/models/confirmable.rb +3 -4
- data/lib/devise/models/database_authenticatable.rb +1 -0
- data/lib/devise/models/lockable.rb +1 -5
- data/lib/devise/models/rememberable.rb +5 -11
- data/lib/devise/parameter_sanitizer.rb +176 -61
- data/lib/devise/rails.rb +1 -10
- data/lib/devise/rails/routes.rb +25 -14
- data/lib/devise/rails/warden_compat.rb +1 -10
- data/lib/devise/strategies/rememberable.rb +6 -3
- data/lib/devise/test_helpers.rb +9 -4
- data/lib/devise/token_generator.rb +1 -41
- data/lib/devise/version.rb +1 -1
- data/lib/generators/active_record/devise_generator.rb +3 -3
- data/lib/generators/active_record/templates/migration.rb +1 -1
- data/lib/generators/active_record/templates/migration_existing.rb +1 -1
- data/lib/generators/devise/orm_helpers.rb +0 -17
- data/lib/generators/templates/controllers/registrations_controller.rb +4 -4
- data/lib/generators/templates/controllers/sessions_controller.rb +2 -2
- data/lib/generators/templates/devise.rb +4 -5
- data/test/controllers/custom_registrations_controller_test.rb +5 -5
- data/test/controllers/custom_strategy_test.rb +7 -5
- data/test/controllers/helper_methods_test.rb +3 -2
- data/test/controllers/helpers_test.rb +1 -1
- data/test/controllers/inherited_controller_i18n_messages_test.rb +2 -2
- data/test/controllers/internal_helpers_test.rb +8 -10
- data/test/controllers/load_hooks_controller_test.rb +1 -1
- data/test/controllers/passwords_controller_test.rb +4 -3
- data/test/controllers/sessions_controller_test.rb +21 -18
- data/test/controllers/url_helpers_test.rb +1 -1
- data/test/failure_app_test.rb +19 -14
- data/test/generators/active_record_generator_test.rb +0 -26
- data/test/helpers/devise_helper_test.rb +1 -1
- data/test/integration/authenticatable_test.rb +18 -18
- data/test/integration/confirmable_test.rb +5 -5
- data/test/integration/database_authenticatable_test.rb +1 -1
- data/test/integration/http_authenticatable_test.rb +4 -5
- data/test/integration/lockable_test.rb +4 -3
- data/test/integration/omniauthable_test.rb +1 -1
- data/test/integration/recoverable_test.rb +10 -10
- data/test/integration/registerable_test.rb +9 -11
- data/test/integration/rememberable_test.rb +7 -43
- data/test/integration/timeoutable_test.rb +4 -4
- data/test/integration/trackable_test.rb +1 -1
- data/test/models/confirmable_test.rb +5 -13
- data/test/models/lockable_test.rb +0 -22
- data/test/models/rememberable_test.rb +0 -12
- data/test/models/validatable_test.rb +2 -10
- data/test/omniauth/url_helpers_test.rb +1 -2
- data/test/orm/active_record.rb +6 -1
- data/test/parameter_sanitizer_test.rb +103 -53
- data/test/rails_app/app/active_record/user.rb +3 -0
- data/test/rails_app/app/controllers/admins_controller.rb +1 -1
- data/test/rails_app/app/controllers/application_controller.rb +2 -2
- data/test/rails_app/app/controllers/home_controller.rb +5 -1
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +2 -2
- data/test/rails_app/app/controllers/users_controller.rb +5 -5
- data/test/rails_app/config/application.rb +1 -1
- data/test/rails_app/config/boot.rb +3 -3
- data/test/rails_app/config/environments/test.rb +6 -1
- data/test/rails_app/config/initializers/secret_token.rb +1 -6
- data/test/routes_test.rb +26 -11
- data/test/support/http_method_compatibility.rb +51 -0
- data/test/support/webrat/integrations/rails.rb +9 -0
- data/test/test_helpers_test.rb +3 -3
- metadata +13 -31
- data/gemfiles/Gemfile.rails-3.2-stable +0 -29
- data/gemfiles/Gemfile.rails-3.2-stable.lock +0 -172
- data/gemfiles/Gemfile.rails-4.0-stable +0 -30
- data/gemfiles/Gemfile.rails-4.0-stable.lock +0 -166
- data/script/cached-bundle +0 -49
- data/script/s3-put +0 -71
- data/test/time_helpers.rb +0 -137
|
@@ -14,7 +14,7 @@ class AnotherInheritedController < SessionsInheritedController
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
class InheritedControllerTest <
|
|
17
|
+
class InheritedControllerTest < Devise::ControllerTestCase
|
|
18
18
|
tests SessionsInheritedController
|
|
19
19
|
|
|
20
20
|
def setup
|
|
@@ -32,7 +32,7 @@ class InheritedControllerTest < ActionController::TestCase
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
class AnotherInheritedControllerTest <
|
|
35
|
+
class AnotherInheritedControllerTest < Devise::ControllerTestCase
|
|
36
36
|
tests AnotherInheritedController
|
|
37
37
|
|
|
38
38
|
def setup
|
|
@@ -3,7 +3,7 @@ require 'test_helper'
|
|
|
3
3
|
class MyController < DeviseController
|
|
4
4
|
end
|
|
5
5
|
|
|
6
|
-
class HelpersTest <
|
|
6
|
+
class HelpersTest < Devise::ControllerTestCase
|
|
7
7
|
tests MyController
|
|
8
8
|
|
|
9
9
|
def setup
|
|
@@ -36,18 +36,16 @@ class HelpersTest < ActionController::TestCase
|
|
|
36
36
|
test 'get resource params from request params using resource name as key' do
|
|
37
37
|
user_params = {'email' => 'shirley@templar.com'}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
# Stub controller name so strong parameters can filter properly.
|
|
40
|
+
# DeviseController does not allow any parameters by default.
|
|
41
|
+
@controller.stubs(:controller_name).returns(:sessions_controller)
|
|
42
|
+
|
|
43
|
+
params = ActionController::Parameters.new({'user' => user_params})
|
|
43
44
|
|
|
44
|
-
ActionController::Parameters.new({'user' => user_params})
|
|
45
|
-
else
|
|
46
|
-
HashWithIndifferentAccess.new({'user' => user_params})
|
|
47
|
-
end
|
|
48
45
|
@controller.stubs(:params).returns(params)
|
|
49
46
|
|
|
50
|
-
|
|
47
|
+
res_params = @controller.send(:resource_params).permit!.to_h
|
|
48
|
+
assert_equal user_params, res_params
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
test 'resources methods are not controller actions' do
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'test_helper'
|
|
2
2
|
|
|
3
|
-
class PasswordsControllerTest <
|
|
3
|
+
class PasswordsControllerTest < Devise::ControllerTestCase
|
|
4
4
|
tests Devise::PasswordsController
|
|
5
5
|
include Devise::TestHelpers
|
|
6
6
|
|
|
@@ -11,8 +11,9 @@ class PasswordsControllerTest < ActionController::TestCase
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def put_update_with_params
|
|
14
|
-
put :update, "user" => {
|
|
15
|
-
|
|
14
|
+
put :update, params: { "user" => {
|
|
15
|
+
"reset_password_token" => @raw, "password" => "1234567", "password_confirmation" => "1234567"
|
|
16
|
+
}
|
|
16
17
|
}
|
|
17
18
|
end
|
|
18
19
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'test_helper'
|
|
2
2
|
|
|
3
|
-
class SessionsControllerTest <
|
|
3
|
+
class SessionsControllerTest < Devise::ControllerTestCase
|
|
4
4
|
tests Devise::SessionsController
|
|
5
5
|
include Devise::TestHelpers
|
|
6
6
|
|
|
@@ -12,9 +12,10 @@ class SessionsControllerTest < ActionController::TestCase
|
|
|
12
12
|
request.env["devise.mapping"] = Devise.mappings[:user]
|
|
13
13
|
request.session["user_return_to"] = 'foo.bar'
|
|
14
14
|
create_user
|
|
15
|
-
post :create, user: {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
post :create, params: { user: {
|
|
16
|
+
email: "wrong@email.com",
|
|
17
|
+
password: "wrongpassword"
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
20
|
assert_equal 200, @response.status
|
|
20
21
|
ensure
|
|
@@ -37,11 +38,11 @@ class SessionsControllerTest < ActionController::TestCase
|
|
|
37
38
|
|
|
38
39
|
user = create_user
|
|
39
40
|
user.confirm
|
|
40
|
-
post :create, user: {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
post :create, params: { user: {
|
|
42
|
+
email: user.email,
|
|
43
|
+
password: user.password
|
|
44
|
+
}
|
|
43
45
|
}
|
|
44
|
-
|
|
45
46
|
assert_nil request.session["user_return_to"]
|
|
46
47
|
end
|
|
47
48
|
|
|
@@ -51,9 +52,10 @@ class SessionsControllerTest < ActionController::TestCase
|
|
|
51
52
|
|
|
52
53
|
user = create_user
|
|
53
54
|
user.confirm
|
|
54
|
-
post :create, format: 'json', user: {
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
post :create, params: { format: 'json', user: {
|
|
56
|
+
email: user.email,
|
|
57
|
+
password: user.password
|
|
58
|
+
}
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
assert_equal 'foo.bar', request.session["user_return_to"]
|
|
@@ -61,9 +63,10 @@ class SessionsControllerTest < ActionController::TestCase
|
|
|
61
63
|
|
|
62
64
|
test "#create doesn't raise exception after Warden authentication fails when TestHelpers included" do
|
|
63
65
|
request.env["devise.mapping"] = Devise.mappings[:user]
|
|
64
|
-
post :create, user: {
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
post :create, params: { user: {
|
|
67
|
+
email: "nosuchuser@example.com",
|
|
68
|
+
password: "wevdude"
|
|
69
|
+
}
|
|
67
70
|
}
|
|
68
71
|
assert_equal 200, @response.status
|
|
69
72
|
assert_template "devise/sessions/new"
|
|
@@ -73,11 +76,11 @@ class SessionsControllerTest < ActionController::TestCase
|
|
|
73
76
|
request.env["devise.mapping"] = Devise.mappings[:user]
|
|
74
77
|
user = create_user
|
|
75
78
|
user.confirm
|
|
76
|
-
post :create, format: 'json', user: {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
post :create, params: { format: 'json', user: {
|
|
80
|
+
email: user.email,
|
|
81
|
+
password: user.password
|
|
82
|
+
}
|
|
79
83
|
}
|
|
80
|
-
|
|
81
84
|
delete :destroy, format: 'json'
|
|
82
85
|
assert flash[:notice].blank?, "flash[:notice] should be blank, not #{flash[:notice].inspect}"
|
|
83
86
|
assert_equal 204, @response.status
|
data/test/failure_app_test.rb
CHANGED
|
@@ -53,11 +53,16 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
53
53
|
'REQUEST_METHOD' => 'GET',
|
|
54
54
|
'warden.options' => { scope: :user },
|
|
55
55
|
'rack.session' => {},
|
|
56
|
-
'action_dispatch.request.formats' => Array(env_params.delete('formats') || Mime
|
|
56
|
+
'action_dispatch.request.formats' => Array(env_params.delete('formats') || Mime[:html]),
|
|
57
57
|
'rack.input' => "",
|
|
58
58
|
'warden' => OpenStruct.new(message: nil)
|
|
59
59
|
}.merge!(env_params)
|
|
60
60
|
|
|
61
|
+
# Passing nil for action_dispatch.request.formats prevents the default from being used in Rails 5, need to remove it
|
|
62
|
+
if env.has_key?('action_dispatch.request.formats') && env['action_dispatch.request.formats'].nil?
|
|
63
|
+
env.delete 'action_dispatch.request.formats' unless env['action_dispatch.request.formats']
|
|
64
|
+
end
|
|
65
|
+
|
|
61
66
|
@response = (env.delete(:app) || Devise::FailureApp).call(env).to_a
|
|
62
67
|
@request = ActionDispatch::Request.new(env)
|
|
63
68
|
end
|
|
@@ -164,14 +169,14 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
164
169
|
|
|
165
170
|
test 'works for any navigational format' do
|
|
166
171
|
swap Devise, navigational_formats: [:xml] do
|
|
167
|
-
call_failure('formats' => Mime
|
|
172
|
+
call_failure('formats' => Mime[:xml])
|
|
168
173
|
assert_equal 302, @response.first
|
|
169
174
|
end
|
|
170
175
|
end
|
|
171
176
|
|
|
172
177
|
test 'redirects the correct format if it is a non-html format request' do
|
|
173
178
|
swap Devise, navigational_formats: [:js] do
|
|
174
|
-
call_failure('formats' => Mime
|
|
179
|
+
call_failure('formats' => Mime[:js])
|
|
175
180
|
assert_equal 'http://test.host/users/sign_in.js', @response.second["Location"]
|
|
176
181
|
end
|
|
177
182
|
end
|
|
@@ -179,18 +184,18 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
179
184
|
|
|
180
185
|
context 'For HTTP request' do
|
|
181
186
|
test 'return 401 status' do
|
|
182
|
-
call_failure('formats' => Mime
|
|
187
|
+
call_failure('formats' => Mime[:xml])
|
|
183
188
|
assert_equal 401, @response.first
|
|
184
189
|
end
|
|
185
190
|
|
|
186
191
|
test 'return appropriate body for xml' do
|
|
187
|
-
call_failure('formats' => Mime
|
|
192
|
+
call_failure('formats' => Mime[:xml])
|
|
188
193
|
result = %(<?xml version="1.0" encoding="UTF-8"?>\n<errors>\n <error>You need to sign in or sign up before continuing.</error>\n</errors>\n)
|
|
189
194
|
assert_equal result, @response.last.body
|
|
190
195
|
end
|
|
191
196
|
|
|
192
197
|
test 'return appropriate body for json' do
|
|
193
|
-
call_failure('formats' => Mime
|
|
198
|
+
call_failure('formats' => Mime[:json])
|
|
194
199
|
result = %({"error":"You need to sign in or sign up before continuing."})
|
|
195
200
|
assert_equal result, @response.last.body
|
|
196
201
|
end
|
|
@@ -201,26 +206,26 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
201
206
|
end
|
|
202
207
|
|
|
203
208
|
test 'return WWW-authenticate headers if model allows' do
|
|
204
|
-
call_failure('formats' => Mime
|
|
209
|
+
call_failure('formats' => Mime[:xml])
|
|
205
210
|
assert_equal 'Basic realm="Application"', @response.second["WWW-Authenticate"]
|
|
206
211
|
end
|
|
207
212
|
|
|
208
213
|
test 'does not return WWW-authenticate headers if model does not allow' do
|
|
209
214
|
swap Devise, http_authenticatable: false do
|
|
210
|
-
call_failure('formats' => Mime
|
|
215
|
+
call_failure('formats' => Mime[:xml])
|
|
211
216
|
assert_nil @response.second["WWW-Authenticate"]
|
|
212
217
|
end
|
|
213
218
|
end
|
|
214
219
|
|
|
215
220
|
test 'works for any non navigational format' do
|
|
216
221
|
swap Devise, navigational_formats: [] do
|
|
217
|
-
call_failure('formats' => Mime
|
|
222
|
+
call_failure('formats' => Mime[:html])
|
|
218
223
|
assert_equal 401, @response.first
|
|
219
224
|
end
|
|
220
225
|
end
|
|
221
226
|
|
|
222
227
|
test 'uses the failure message as response body' do
|
|
223
|
-
call_failure('formats' => Mime
|
|
228
|
+
call_failure('formats' => Mime[:xml], 'warden' => OpenStruct.new(message: :invalid))
|
|
224
229
|
assert_match '<error>Invalid email or password.</error>', @response.third.body
|
|
225
230
|
end
|
|
226
231
|
|
|
@@ -228,7 +233,7 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
228
233
|
context 'when http_authenticatable_on_xhr is false' do
|
|
229
234
|
test 'dont return 401 with navigational formats' do
|
|
230
235
|
swap Devise, http_authenticatable_on_xhr: false do
|
|
231
|
-
call_failure('formats' => Mime
|
|
236
|
+
call_failure('formats' => Mime[:html], 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest')
|
|
232
237
|
assert_equal 302, @response.first
|
|
233
238
|
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
|
|
234
239
|
end
|
|
@@ -236,7 +241,7 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
236
241
|
|
|
237
242
|
test 'dont return 401 with non navigational formats' do
|
|
238
243
|
swap Devise, http_authenticatable_on_xhr: false do
|
|
239
|
-
call_failure('formats' => Mime
|
|
244
|
+
call_failure('formats' => Mime[:json], 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest')
|
|
240
245
|
assert_equal 302, @response.first
|
|
241
246
|
assert_equal 'http://test.host/users/sign_in.json', @response.second["Location"]
|
|
242
247
|
end
|
|
@@ -246,14 +251,14 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
246
251
|
context 'when http_authenticatable_on_xhr is true' do
|
|
247
252
|
test 'return 401' do
|
|
248
253
|
swap Devise, http_authenticatable_on_xhr: true do
|
|
249
|
-
call_failure('formats' => Mime
|
|
254
|
+
call_failure('formats' => Mime[:html], 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest')
|
|
250
255
|
assert_equal 401, @response.first
|
|
251
256
|
end
|
|
252
257
|
end
|
|
253
258
|
|
|
254
259
|
test 'skip WWW-Authenticate header' do
|
|
255
260
|
swap Devise, http_authenticatable_on_xhr: true do
|
|
256
|
-
call_failure('formats' => Mime
|
|
261
|
+
call_failure('formats' => Mime[:html], 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest')
|
|
257
262
|
assert_nil @response.second['WWW-Authenticate']
|
|
258
263
|
end
|
|
259
264
|
end
|
|
@@ -69,7 +69,6 @@ if DEVISE_ORM == :active_record
|
|
|
69
69
|
setup :prepare_destination
|
|
70
70
|
|
|
71
71
|
test "all files are properly created in rails 4.0" do
|
|
72
|
-
ActiveRecord::Generators::DeviseGenerator.any_instance.stubs(:rails_3?).returns(false)
|
|
73
72
|
simulate_inside_engine(RailsEngine::Engine, RailsEngine) do
|
|
74
73
|
run_generator ["monster"]
|
|
75
74
|
|
|
@@ -80,30 +79,5 @@ if DEVISE_ORM == :active_record
|
|
|
80
79
|
end
|
|
81
80
|
end
|
|
82
81
|
|
|
83
|
-
test "all files are properly created in rails 3.2 when strong_parameters gem is not installed" do
|
|
84
|
-
ActiveRecord::Generators::DeviseGenerator.any_instance.stubs(:rails_3?).returns(true)
|
|
85
|
-
ActiveRecord::Generators::DeviseGenerator.any_instance.stubs(:strong_parameters_enabled?).returns(false)
|
|
86
|
-
simulate_inside_engine(RailsEngine::Engine, RailsEngine) do
|
|
87
|
-
run_generator ["monster"]
|
|
88
|
-
|
|
89
|
-
assert_file "app/models/rails_engine/monster.rb", /devise/
|
|
90
|
-
assert_file "app/models/rails_engine/monster.rb" do |content|
|
|
91
|
-
assert_match /attr_accessible :email/, content
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
test "all files are properly created in rails 3.2 when strong_parameters gem is installed" do
|
|
97
|
-
ActiveRecord::Generators::DeviseGenerator.any_instance.stubs(:rails_3?).returns(true)
|
|
98
|
-
ActiveRecord::Generators::DeviseGenerator.any_instance.stubs(:strong_parameters_enabled?).returns(true)
|
|
99
|
-
simulate_inside_engine(RailsEngine::Engine, RailsEngine) do
|
|
100
|
-
run_generator ["monster"]
|
|
101
|
-
|
|
102
|
-
assert_file "app/models/rails_engine/monster.rb", /devise/
|
|
103
|
-
assert_file "app/models/rails_engine/monster.rb" do |content|
|
|
104
|
-
assert_no_match /attr_accessible :email/, content
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
82
|
end
|
|
109
83
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'test_helper'
|
|
2
2
|
|
|
3
|
-
class AuthenticationSanityTest <
|
|
3
|
+
class AuthenticationSanityTest < Devise::IntegrationTest
|
|
4
4
|
test 'home should be accessible without sign in' do
|
|
5
5
|
visit '/'
|
|
6
6
|
assert_response :success
|
|
@@ -134,7 +134,7 @@ class AuthenticationSanityTest < ActionDispatch::IntegrationTest
|
|
|
134
134
|
end
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
-
class AuthenticationRoutesRestrictions <
|
|
137
|
+
class AuthenticationRoutesRestrictions < Devise::IntegrationTest
|
|
138
138
|
test 'not signed in should not be able to access private route (authenticate denied)' do
|
|
139
139
|
get private_path
|
|
140
140
|
assert_redirected_to new_admin_session_path
|
|
@@ -254,7 +254,7 @@ class AuthenticationRoutesRestrictions < ActionDispatch::IntegrationTest
|
|
|
254
254
|
end
|
|
255
255
|
end
|
|
256
256
|
|
|
257
|
-
class AuthenticationRedirectTest <
|
|
257
|
+
class AuthenticationRedirectTest < Devise::IntegrationTest
|
|
258
258
|
test 'redirect from warden shows sign in or sign up message' do
|
|
259
259
|
get admins_path
|
|
260
260
|
|
|
@@ -300,7 +300,7 @@ class AuthenticationRedirectTest < ActionDispatch::IntegrationTest
|
|
|
300
300
|
end
|
|
301
301
|
|
|
302
302
|
test 'xml http requests does not store urls for redirect' do
|
|
303
|
-
get users_path, {
|
|
303
|
+
get users_path, headers: { 'HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest' }
|
|
304
304
|
assert_equal 401, response.status
|
|
305
305
|
assert_nil session[:"user_return_to"]
|
|
306
306
|
end
|
|
@@ -317,7 +317,7 @@ class AuthenticationRedirectTest < ActionDispatch::IntegrationTest
|
|
|
317
317
|
end
|
|
318
318
|
end
|
|
319
319
|
|
|
320
|
-
class AuthenticationSessionTest <
|
|
320
|
+
class AuthenticationSessionTest < Devise::IntegrationTest
|
|
321
321
|
test 'destroyed account is signed out' do
|
|
322
322
|
sign_in_as_user
|
|
323
323
|
get '/users'
|
|
@@ -390,7 +390,7 @@ class AuthenticationSessionTest < ActionDispatch::IntegrationTest
|
|
|
390
390
|
end
|
|
391
391
|
end
|
|
392
392
|
|
|
393
|
-
class AuthenticationWithScopedViewsTest <
|
|
393
|
+
class AuthenticationWithScopedViewsTest < Devise::IntegrationTest
|
|
394
394
|
test 'renders the scoped view if turned on and view is available' do
|
|
395
395
|
swap Devise, scoped_views: true do
|
|
396
396
|
assert_raise Webrat::NotFoundError do
|
|
@@ -431,7 +431,7 @@ class AuthenticationWithScopedViewsTest < ActionDispatch::IntegrationTest
|
|
|
431
431
|
end
|
|
432
432
|
end
|
|
433
433
|
|
|
434
|
-
class AuthenticationOthersTest <
|
|
434
|
+
class AuthenticationOthersTest < Devise::IntegrationTest
|
|
435
435
|
test 'handles unverified requests gets rid of caches' do
|
|
436
436
|
swap ApplicationController, allow_forgery_protection: true do
|
|
437
437
|
post exhibit_user_url(1)
|
|
@@ -472,7 +472,7 @@ class AuthenticationOthersTest < ActionDispatch::IntegrationTest
|
|
|
472
472
|
|
|
473
473
|
test 'sign in with script name' do
|
|
474
474
|
assert_nothing_raised do
|
|
475
|
-
get new_user_session_path, {
|
|
475
|
+
get new_user_session_path, headers: { "SCRIPT_NAME" => "/omg" }
|
|
476
476
|
fill_in "email", with: "user@test.com"
|
|
477
477
|
end
|
|
478
478
|
end
|
|
@@ -509,7 +509,7 @@ class AuthenticationOthersTest < ActionDispatch::IntegrationTest
|
|
|
509
509
|
|
|
510
510
|
test 'sign in with xml format returns xml response' do
|
|
511
511
|
create_user
|
|
512
|
-
post user_session_path(format: 'xml'), user: {email: "user@test.com", password: '12345678'}
|
|
512
|
+
post user_session_path(format: 'xml'), params: { user: {email: "user@test.com", password: '12345678'} }
|
|
513
513
|
assert_response :success
|
|
514
514
|
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
|
|
515
515
|
end
|
|
@@ -519,13 +519,13 @@ class AuthenticationOthersTest < ActionDispatch::IntegrationTest
|
|
|
519
519
|
assert_response :success
|
|
520
520
|
|
|
521
521
|
create_user
|
|
522
|
-
post user_session_path(format: 'xml'), user: {email: "user@test.com", password: '12345678'}
|
|
522
|
+
post user_session_path(format: 'xml'), params: { user: {email: "user@test.com", password: '12345678'} }
|
|
523
523
|
assert_response :success
|
|
524
524
|
|
|
525
525
|
get new_user_session_path(format: 'xml')
|
|
526
526
|
assert_response :success
|
|
527
527
|
|
|
528
|
-
post user_session_path(format: 'xml'), user: {email: "user@test.com", password: '12345678'}
|
|
528
|
+
post user_session_path(format: 'xml'), params: { user: {email: "user@test.com", password: '12345678'} }
|
|
529
529
|
assert_response :success
|
|
530
530
|
assert response.body.include? %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<user>)
|
|
531
531
|
end
|
|
@@ -559,7 +559,7 @@ class AuthenticationOthersTest < ActionDispatch::IntegrationTest
|
|
|
559
559
|
test 'sign out with non-navigational format via XHR does not redirect' do
|
|
560
560
|
swap Devise, navigational_formats: ['*/*', :html] do
|
|
561
561
|
sign_in_as_user
|
|
562
|
-
|
|
562
|
+
get destroy_user_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "application/json,text/javascript,*/*" } # NOTE: Bug is triggered by combination of XHR and */*.
|
|
563
563
|
assert_response :no_content
|
|
564
564
|
assert_not warden.authenticated?(:user)
|
|
565
565
|
end
|
|
@@ -569,14 +569,14 @@ class AuthenticationOthersTest < ActionDispatch::IntegrationTest
|
|
|
569
569
|
test 'sign out with navigational format via XHR does redirect' do
|
|
570
570
|
swap Devise, navigational_formats: ['*/*', :html] do
|
|
571
571
|
sign_in_as_user
|
|
572
|
-
|
|
572
|
+
get destroy_user_session_path, xhr: true, headers: { "HTTP_ACCEPT" => "text/html,*/*" }
|
|
573
573
|
assert_response :redirect
|
|
574
574
|
assert_not warden.authenticated?(:user)
|
|
575
575
|
end
|
|
576
576
|
end
|
|
577
577
|
end
|
|
578
578
|
|
|
579
|
-
class AuthenticationKeysTest <
|
|
579
|
+
class AuthenticationKeysTest < Devise::IntegrationTest
|
|
580
580
|
test 'missing authentication keys cause authentication to abort' do
|
|
581
581
|
swap Devise, authentication_keys: [:subdomain] do
|
|
582
582
|
sign_in_as_user
|
|
@@ -593,7 +593,7 @@ class AuthenticationKeysTest < ActionDispatch::IntegrationTest
|
|
|
593
593
|
end
|
|
594
594
|
end
|
|
595
595
|
|
|
596
|
-
class AuthenticationRequestKeysTest <
|
|
596
|
+
class AuthenticationRequestKeysTest < Devise::IntegrationTest
|
|
597
597
|
test 'request keys are used on authentication' do
|
|
598
598
|
host! 'foo.bar.baz'
|
|
599
599
|
|
|
@@ -634,7 +634,7 @@ class AuthenticationRequestKeysTest < ActionDispatch::IntegrationTest
|
|
|
634
634
|
end
|
|
635
635
|
end
|
|
636
636
|
|
|
637
|
-
class AuthenticationSignOutViaTest <
|
|
637
|
+
class AuthenticationSignOutViaTest < Devise::IntegrationTest
|
|
638
638
|
def sign_in!(scope)
|
|
639
639
|
sign_in_as_admin(visit: send("new_#{scope}_session_path"))
|
|
640
640
|
assert warden.authenticated?(scope)
|
|
@@ -689,7 +689,7 @@ class AuthenticationSignOutViaTest < ActionDispatch::IntegrationTest
|
|
|
689
689
|
end
|
|
690
690
|
end
|
|
691
691
|
|
|
692
|
-
class DoubleAuthenticationRedirectTest <
|
|
692
|
+
class DoubleAuthenticationRedirectTest < Devise::IntegrationTest
|
|
693
693
|
test 'signed in as user redirects when visiting user sign in page' do
|
|
694
694
|
sign_in_as_user
|
|
695
695
|
get new_user_session_path(format: :html)
|
|
@@ -712,7 +712,7 @@ class DoubleAuthenticationRedirectTest < ActionDispatch::IntegrationTest
|
|
|
712
712
|
end
|
|
713
713
|
end
|
|
714
714
|
|
|
715
|
-
class DoubleSignOutRedirectTest <
|
|
715
|
+
class DoubleSignOutRedirectTest < Devise::IntegrationTest
|
|
716
716
|
test 'sign out after already having signed out redirects to sign in' do
|
|
717
717
|
sign_in_as_user
|
|
718
718
|
|