devise 3.2.4 → 3.3.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.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +12 -5
- data/CHANGELOG.md +28 -1
- data/Gemfile +5 -5
- data/Gemfile.lock +98 -92
- data/README.md +22 -16
- data/app/controllers/devise/confirmations_controller.rb +1 -1
- data/app/controllers/devise/registrations_controller.rb +18 -5
- data/app/controllers/devise/sessions_controller.rb +32 -9
- data/app/controllers/devise_controller.rb +3 -3
- data/app/views/devise/registrations/new.html.erb +1 -1
- data/app/views/devise/sessions/new.html.erb +2 -2
- data/app/views/devise/shared/_links.erb +1 -1
- data/config/locales/en.yml +16 -15
- data/gemfiles/Gemfile.rails-3.2-stable +3 -3
- data/gemfiles/Gemfile.rails-3.2-stable.lock +166 -0
- data/gemfiles/Gemfile.rails-4.0-stable +4 -4
- data/gemfiles/Gemfile.rails-4.0-stable.lock +162 -0
- data/gemfiles/Gemfile.rails-head +7 -4
- data/gemfiles/Gemfile.rails-head.lock +190 -0
- data/lib/devise.rb +8 -4
- data/lib/devise/controllers/helpers.rb +77 -6
- data/lib/devise/controllers/sign_in_out.rb +0 -1
- data/lib/devise/controllers/store_location.rb +8 -2
- data/lib/devise/controllers/url_helpers.rb +3 -1
- data/lib/devise/failure_app.rb +6 -6
- data/lib/devise/hooks/activatable.rb +3 -4
- data/lib/devise/hooks/csrf_cleaner.rb +3 -1
- data/lib/devise/hooks/timeoutable.rb +8 -1
- data/lib/devise/mapping.rb +4 -1
- data/lib/devise/models/confirmable.rb +3 -3
- data/lib/devise/models/database_authenticatable.rb +7 -3
- data/lib/devise/models/lockable.rb +2 -2
- data/lib/devise/models/recoverable.rb +23 -7
- data/lib/devise/models/rememberable.rb +2 -2
- data/lib/devise/models/trackable.rb +4 -1
- data/lib/devise/rails/routes.rb +8 -6
- data/lib/devise/strategies/authenticatable.rb +7 -0
- data/lib/devise/version.rb +1 -1
- data/lib/generators/active_record/devise_generator.rb +19 -2
- data/lib/generators/templates/README +1 -1
- data/lib/generators/templates/devise.rb +3 -0
- data/script/cached-bundle +49 -0
- data/script/s3-put +71 -0
- data/test/controllers/custom_registrations_controller_test.rb +35 -0
- data/test/controllers/helpers_test.rb +35 -0
- data/test/controllers/internal_helpers_test.rb +1 -1
- data/test/controllers/passwords_controller_test.rb +1 -1
- data/test/devise_test.rb +18 -5
- data/test/failure_app_test.rb +40 -4
- data/test/generators/active_record_generator_test.rb +6 -0
- data/test/helpers/devise_helper_test.rb +3 -2
- data/test/integration/authenticatable_test.rb +19 -3
- data/test/integration/confirmable_test.rb +49 -9
- data/test/integration/http_authenticatable_test.rb +1 -1
- data/test/integration/lockable_test.rb +6 -6
- data/test/integration/recoverable_test.rb +5 -5
- data/test/integration/registerable_test.rb +32 -22
- data/test/integration/timeoutable_test.rb +8 -2
- data/test/integration/trackable_test.rb +2 -2
- data/test/mailers/confirmation_instructions_test.rb +3 -3
- data/test/mailers/reset_password_instructions_test.rb +3 -3
- data/test/mailers/unlock_instructions_test.rb +3 -3
- data/test/models/authenticatable_test.rb +1 -1
- data/test/models/lockable_test.rb +6 -0
- data/test/models/recoverable_test.rb +12 -0
- data/test/models/rememberable_test.rb +21 -6
- data/test/models/trackable_test.rb +28 -0
- data/test/models/validatable_test.rb +2 -2
- data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
- data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
- data/test/rails_app/app/controllers/application_controller.rb +3 -0
- data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
- data/test/rails_app/app/controllers/custom/registrations_controller.rb +21 -0
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -1
- data/test/rails_app/app/controllers/users_controller.rb +1 -1
- data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
- data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
- data/test/rails_app/config/application.rb +1 -1
- data/test/rails_app/config/initializers/devise.rb +2 -0
- data/test/rails_app/config/routes.rb +17 -0
- data/test/rails_app/lib/shared_user.rb +1 -1
- data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
- data/test/routes_test.rb +5 -3
- data/test/support/assertions.rb +2 -3
- data/test/support/integration.rb +2 -2
- data/test/test_helper.rb +2 -0
- data/test/test_helpers_test.rb +22 -32
- metadata +23 -2
data/script/s3-put
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Usage: s3-put <FILE> <S3_BUCKET>[:<PATH>] [<CONTENT_TYPE>]
|
|
3
|
+
#
|
|
4
|
+
# Uploads a file to the Amazon S3 service.
|
|
5
|
+
# Outputs the URL for the newly uploaded file.
|
|
6
|
+
#
|
|
7
|
+
# Requirements:
|
|
8
|
+
# - AMAZON_ACCESS_KEY_ID
|
|
9
|
+
# - AMAZON_SECRET_ACCESS_KEY
|
|
10
|
+
# - openssl
|
|
11
|
+
# - curl
|
|
12
|
+
#
|
|
13
|
+
# Author: Mislav Marohnić
|
|
14
|
+
|
|
15
|
+
set -e
|
|
16
|
+
|
|
17
|
+
authorization() {
|
|
18
|
+
local signature="$(string_to_sign | hmac_sha1 | base64)"
|
|
19
|
+
echo "AWS ${AMAZON_ACCESS_KEY_ID?}:${signature}"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
hmac_sha1() {
|
|
23
|
+
openssl dgst -binary -sha1 -hmac "${AMAZON_SECRET_ACCESS_KEY?}"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
base64() {
|
|
27
|
+
openssl enc -base64
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
bin_md5() {
|
|
31
|
+
openssl dgst -binary -md5
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
string_to_sign() {
|
|
35
|
+
echo "$http_method"
|
|
36
|
+
echo "$content_md5"
|
|
37
|
+
echo "$content_type"
|
|
38
|
+
echo "$date"
|
|
39
|
+
echo "x-amz-acl:$acl"
|
|
40
|
+
printf "/$bucket/$remote_path"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
date_string() {
|
|
44
|
+
LC_TIME=C date "+%a, %d %h %Y %T %z"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
file="$1"
|
|
48
|
+
bucket="${2%%:*}"
|
|
49
|
+
remote_path="${2#*:}"
|
|
50
|
+
content_type="$3"
|
|
51
|
+
|
|
52
|
+
if [ -z "$remote_path" ] || [ "$remote_path" = "$bucket" ]; then
|
|
53
|
+
remote_path="${file##*/}"
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
http_method=PUT
|
|
57
|
+
acl="public-read"
|
|
58
|
+
content_md5="$(bin_md5 < "$file" | base64)"
|
|
59
|
+
date="$(date_string)"
|
|
60
|
+
|
|
61
|
+
url="https://$bucket.s3.amazonaws.com/$remote_path"
|
|
62
|
+
|
|
63
|
+
curl -qsSf -T "$file" \
|
|
64
|
+
-H "Authorization: $(authorization)" \
|
|
65
|
+
-H "x-amz-acl: $acl" \
|
|
66
|
+
-H "Date: $date" \
|
|
67
|
+
-H "Content-MD5: $content_md5" \
|
|
68
|
+
-H "Content-Type: $content_type" \
|
|
69
|
+
"$url"
|
|
70
|
+
|
|
71
|
+
echo "$url"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class CustomRegistrationsControllerTest < ActionController::TestCase
|
|
4
|
+
tests Custom::RegistrationsController
|
|
5
|
+
|
|
6
|
+
include Devise::TestHelpers
|
|
7
|
+
|
|
8
|
+
setup do
|
|
9
|
+
request.env["devise.mapping"] = Devise.mappings[:user]
|
|
10
|
+
@password = 'password'
|
|
11
|
+
@user = create_user(password: @password, password_confirmation: @password).tap(&:confirm!)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
test "yield resource to block on create success" do
|
|
15
|
+
post :create, { user: { email: "user@example.org", password: "password", password_confirmation: "password" } }
|
|
16
|
+
assert @controller.create_block_called?, "create failed to yield resource to provided block"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "yield resource to block on create failure" do
|
|
20
|
+
post :create, { user: { } }
|
|
21
|
+
assert @controller.create_block_called?, "create failed to yield resource to provided block"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test "yield resource to block on update success" do
|
|
25
|
+
sign_in @user
|
|
26
|
+
put :update, { user: { current_password: @password } }
|
|
27
|
+
assert @controller.update_block_called?, "update failed to yield resource to provided block"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
test "yield resource to block on update failure" do
|
|
31
|
+
sign_in @user
|
|
32
|
+
put :update, { user: { } }
|
|
33
|
+
assert @controller.update_block_called?, "update failed to yield resource to provided block"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -25,6 +25,13 @@ class ControllerAuthenticatableTest < ActionController::TestCase
|
|
|
25
25
|
@controller.signed_in?
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
test 'proxy [group]_signed_in? to authenticate? with each scope' do
|
|
29
|
+
[:user, :admin].each do |scope|
|
|
30
|
+
@mock_warden.expects(:authenticate?).with(scope: scope).returns(false)
|
|
31
|
+
end
|
|
32
|
+
@controller.commenter_signed_in?
|
|
33
|
+
end
|
|
34
|
+
|
|
28
35
|
test 'proxy current_user to authenticate with user scope' do
|
|
29
36
|
@mock_warden.expects(:authenticate).with(scope: :user)
|
|
30
37
|
@controller.current_user
|
|
@@ -35,6 +42,20 @@ class ControllerAuthenticatableTest < ActionController::TestCase
|
|
|
35
42
|
@controller.current_admin
|
|
36
43
|
end
|
|
37
44
|
|
|
45
|
+
test 'proxy current_[group] to authenticate with each scope' do
|
|
46
|
+
[:user, :admin].each do |scope|
|
|
47
|
+
@mock_warden.expects(:authenticate).with(scope: scope).returns(nil)
|
|
48
|
+
end
|
|
49
|
+
@controller.current_commenter
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
test 'proxy current_[plural_group] to authenticate with each scope' do
|
|
53
|
+
[:user, :admin].each do |scope|
|
|
54
|
+
@mock_warden.expects(:authenticate).with(scope: scope)
|
|
55
|
+
end
|
|
56
|
+
@controller.current_commenters
|
|
57
|
+
end
|
|
58
|
+
|
|
38
59
|
test 'proxy current_publisher_account to authenticate with namespaced publisher account scope' do
|
|
39
60
|
@mock_warden.expects(:authenticate).with(scope: :publisher_account)
|
|
40
61
|
@controller.current_publisher_account
|
|
@@ -55,6 +76,14 @@ class ControllerAuthenticatableTest < ActionController::TestCase
|
|
|
55
76
|
@controller.authenticate_admin!
|
|
56
77
|
end
|
|
57
78
|
|
|
79
|
+
test 'proxy authenticate_[group]! to authenticate!? with each scope' do
|
|
80
|
+
[:user, :admin].each do |scope|
|
|
81
|
+
@mock_warden.expects(:authenticate!).with(scope: scope)
|
|
82
|
+
@mock_warden.expects(:authenticate?).with(scope: scope).returns(false)
|
|
83
|
+
end
|
|
84
|
+
@controller.authenticate_commenter!
|
|
85
|
+
end
|
|
86
|
+
|
|
58
87
|
test 'proxy authenticate_publisher_account! to authenticate with namespaced publisher account scope' do
|
|
59
88
|
@mock_warden.expects(:authenticate!).with(scope: :publisher_account)
|
|
60
89
|
@controller.authenticate_publisher_account!
|
|
@@ -193,6 +222,12 @@ class ControllerAuthenticatableTest < ActionController::TestCase
|
|
|
193
222
|
assert_equal "/foo.bar", @controller.stored_location_for(:user)
|
|
194
223
|
end
|
|
195
224
|
|
|
225
|
+
test 'store bad location for stores a location to redirect back to' do
|
|
226
|
+
assert_nil @controller.stored_location_for(:user)
|
|
227
|
+
@controller.store_location_for(:user, "/foo.bar\">Carry")
|
|
228
|
+
assert_nil @controller.stored_location_for(:user)
|
|
229
|
+
end
|
|
230
|
+
|
|
196
231
|
test 'store location for accepts a resource as argument' do
|
|
197
232
|
@controller.store_location_for(User.new, "/foo.bar")
|
|
198
233
|
assert_equal "/foo.bar", @controller.stored_location_for(User.new)
|
|
@@ -51,7 +51,7 @@ class HelpersTest < ActionController::TestCase
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
test 'resources methods are not controller actions' do
|
|
54
|
-
assert @controller.class.action_methods.empty?
|
|
54
|
+
assert @controller.class.action_methods.delete_if { |m| m.include? 'commenter' }.empty?
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
test 'require no authentication tests current mapping' do
|
|
@@ -12,7 +12,7 @@ class PasswordsControllerTest < ActionController::TestCase
|
|
|
12
12
|
|
|
13
13
|
def put_update_with_params
|
|
14
14
|
put :update, "user" => {
|
|
15
|
-
"reset_password_token" => @raw, "password" => "
|
|
15
|
+
"reset_password_token" => @raw, "password" => "1234567", "password_confirmation" => "1234567"
|
|
16
16
|
}
|
|
17
17
|
end
|
|
18
18
|
|
data/test/devise_test.rb
CHANGED
|
@@ -3,10 +3,10 @@ require 'test_helper'
|
|
|
3
3
|
module Devise
|
|
4
4
|
def self.yield_and_restore
|
|
5
5
|
@@warden_configured = nil
|
|
6
|
-
c, b = @@warden_config, @@
|
|
6
|
+
c, b = @@warden_config, @@warden_config_blocks
|
|
7
7
|
yield
|
|
8
8
|
ensure
|
|
9
|
-
@@warden_config, @@
|
|
9
|
+
@@warden_config, @@warden_config_blocks = c, b
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
@@ -42,14 +42,27 @@ class DeviseTest < ActiveSupport::TestCase
|
|
|
42
42
|
|
|
43
43
|
test 'warden manager user configuration through a block' do
|
|
44
44
|
Devise.yield_and_restore do
|
|
45
|
-
|
|
45
|
+
executed = false
|
|
46
46
|
Devise.warden do |config|
|
|
47
|
-
|
|
47
|
+
executed = true
|
|
48
48
|
assert_kind_of Warden::Config, config
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
Devise.configure_warden!
|
|
52
|
-
assert
|
|
52
|
+
assert executed
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
test 'warden manager user configuration through multiple blocks' do
|
|
57
|
+
Devise.yield_and_restore do
|
|
58
|
+
executed = 0
|
|
59
|
+
|
|
60
|
+
3.times do
|
|
61
|
+
Devise.warden { |config| executed += 1 }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
Devise.configure_warden!
|
|
65
|
+
assert_equal 3, executed
|
|
53
66
|
end
|
|
54
67
|
end
|
|
55
68
|
|
data/test/failure_app_test.rb
CHANGED
|
@@ -8,6 +8,18 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
class FailureWithSubdomain < RootFailureApp
|
|
12
|
+
routes = ActionDispatch::Routing::RouteSet.new
|
|
13
|
+
|
|
14
|
+
routes.draw do
|
|
15
|
+
scope subdomain: 'sub' do
|
|
16
|
+
root to: 'foo#bar'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
include routes.url_helpers
|
|
21
|
+
end
|
|
22
|
+
|
|
11
23
|
class FailureWithI18nOptions < Devise::FailureApp
|
|
12
24
|
def i18n_options(options)
|
|
13
25
|
options.merge(name: 'Steve')
|
|
@@ -42,6 +54,13 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
42
54
|
assert_equal 'http://test.host/users/sign_in', @response.second['Location']
|
|
43
55
|
end
|
|
44
56
|
|
|
57
|
+
test 'returns to the default redirect location considering subdomain' do
|
|
58
|
+
call_failure('warden.options' => { scope: :subdomain_user })
|
|
59
|
+
assert_equal 302, @response.first
|
|
60
|
+
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
|
61
|
+
assert_equal 'http://sub.test.host/subdomain_users/sign_in', @response.second['Location']
|
|
62
|
+
end
|
|
63
|
+
|
|
45
64
|
test 'returns to the default redirect location for wildcard requests' do
|
|
46
65
|
call_failure 'action_dispatch.request.formats' => nil, 'HTTP_ACCEPT' => '*/*'
|
|
47
66
|
assert_equal 302, @response.first
|
|
@@ -57,6 +76,15 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
57
76
|
end
|
|
58
77
|
end
|
|
59
78
|
|
|
79
|
+
test 'returns to the root path considering subdomain if no session path is available' do
|
|
80
|
+
swap Devise, router_name: :fake_app do
|
|
81
|
+
call_failure app: FailureWithSubdomain
|
|
82
|
+
assert_equal 302, @response.first
|
|
83
|
+
assert_equal 'You need to sign in or sign up before continuing.', @request.flash[:alert]
|
|
84
|
+
assert_equal 'http://sub.test.host/', @response.second['Location']
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
60
88
|
if Rails.application.config.respond_to?(:relative_url_root)
|
|
61
89
|
test 'returns to the default redirect location considering the relative url root' do
|
|
62
90
|
swap Rails.application.config, relative_url_root: "/sample" do
|
|
@@ -65,6 +93,14 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
65
93
|
assert_equal 'http://test.host/sample/users/sign_in', @response.second['Location']
|
|
66
94
|
end
|
|
67
95
|
end
|
|
96
|
+
|
|
97
|
+
test 'returns to the default redirect location considering the relative url root and subdomain' do
|
|
98
|
+
swap Rails.application.config, relative_url_root: "/sample" do
|
|
99
|
+
call_failure('warden.options' => { scope: :subdomain_user })
|
|
100
|
+
assert_equal 302, @response.first
|
|
101
|
+
assert_equal 'http://sub.test.host/sample/subdomain_users/sign_in', @response.second['Location']
|
|
102
|
+
end
|
|
103
|
+
end
|
|
68
104
|
end
|
|
69
105
|
|
|
70
106
|
test 'uses the proxy failure message as symbol' do
|
|
@@ -203,7 +239,7 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
203
239
|
"warden" => stub_everything
|
|
204
240
|
}
|
|
205
241
|
call_failure(env)
|
|
206
|
-
assert @response.third.body.include?('<h2>
|
|
242
|
+
assert @response.third.body.include?('<h2>Log in</h2>')
|
|
207
243
|
assert @response.third.body.include?('Invalid email or password.')
|
|
208
244
|
end
|
|
209
245
|
|
|
@@ -214,8 +250,8 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
214
250
|
"warden" => stub_everything
|
|
215
251
|
}
|
|
216
252
|
call_failure(env)
|
|
217
|
-
assert @response.third.body.include?('<h2>
|
|
218
|
-
assert @response.third.body.include?('You have to confirm your
|
|
253
|
+
assert @response.third.body.include?('<h2>Log in</h2>')
|
|
254
|
+
assert @response.third.body.include?('You have to confirm your email address before continuing.')
|
|
219
255
|
end
|
|
220
256
|
|
|
221
257
|
test 'calls the original controller if inactive account' do
|
|
@@ -225,7 +261,7 @@ class FailureTest < ActiveSupport::TestCase
|
|
|
225
261
|
"warden" => stub_everything
|
|
226
262
|
}
|
|
227
263
|
call_failure(env)
|
|
228
|
-
assert @response.third.body.include?('<h2>
|
|
264
|
+
assert @response.third.body.include?('<h2>Log in</h2>')
|
|
229
265
|
assert @response.third.body.include?('Your account is not activated yet.')
|
|
230
266
|
end
|
|
231
267
|
end
|
|
@@ -37,6 +37,12 @@ if DEVISE_ORM == :active_record
|
|
|
37
37
|
assert_no_file "app/models/monster.rb"
|
|
38
38
|
assert_no_migration "db/migrate/devise_create_monsters.rb"
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
test "use string column type for ip addresses" do
|
|
42
|
+
run_generator %w(monster)
|
|
43
|
+
assert_migration "db/migrate/devise_create_monsters.rb", /t.string :current_sign_in_ip/
|
|
44
|
+
assert_migration "db/migrate/devise_create_monsters.rb", /t.string :last_sign_in_ip/
|
|
45
|
+
end
|
|
40
46
|
end
|
|
41
47
|
|
|
42
48
|
module RailsEngine
|
|
@@ -3,7 +3,9 @@ require 'test_helper'
|
|
|
3
3
|
class DeviseHelperTest < ActionDispatch::IntegrationTest
|
|
4
4
|
setup do
|
|
5
5
|
model_labels = { models: { user: "utilisateur" } }
|
|
6
|
-
|
|
6
|
+
# TODO: Remove this hack that fixes the I18n performance safeguards that
|
|
7
|
+
# breaks the custom locale.
|
|
8
|
+
I18n.available_locales += [:fr]
|
|
7
9
|
I18n.backend.store_translations :fr,
|
|
8
10
|
{
|
|
9
11
|
errors: { messages: { not_saved: {
|
|
@@ -48,4 +50,3 @@ class DeviseHelperTest < ActionDispatch::IntegrationTest
|
|
|
48
50
|
assert_contain "Erreur lors de l'enregistrement de 'utilisateur': 2 erreurs"
|
|
49
51
|
end
|
|
50
52
|
end
|
|
51
|
-
|
|
@@ -118,13 +118,13 @@ class AuthenticationSanityTest < ActionDispatch::IntegrationTest
|
|
|
118
118
|
assert_not warden.authenticated?(:admin)
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
-
test 'unauthenticated admin
|
|
121
|
+
test 'unauthenticated admin set message on sign out' do
|
|
122
122
|
get destroy_admin_session_path
|
|
123
123
|
assert_response :redirect
|
|
124
124
|
assert_redirected_to root_path
|
|
125
125
|
|
|
126
126
|
get root_path
|
|
127
|
-
|
|
127
|
+
assert_contain 'Signed out successfully'
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
test 'scope uses custom failure app' do
|
|
@@ -448,7 +448,7 @@ class AuthenticationOthersTest < ActionDispatch::IntegrationTest
|
|
|
448
448
|
|
|
449
449
|
test 'uses the custom controller with the custom controller view' do
|
|
450
450
|
get '/admin_area/sign_in'
|
|
451
|
-
assert_contain '
|
|
451
|
+
assert_contain 'Log in'
|
|
452
452
|
assert_contain 'Welcome to "admins/sessions" controller!'
|
|
453
453
|
assert_contain 'Welcome to "sessions/new" view!'
|
|
454
454
|
end
|
|
@@ -711,3 +711,19 @@ class DoubleAuthenticationRedirectTest < ActionDispatch::IntegrationTest
|
|
|
711
711
|
assert_redirected_to '/admin_area/home'
|
|
712
712
|
end
|
|
713
713
|
end
|
|
714
|
+
|
|
715
|
+
class DoubleSignOutRedirectTest < ActionDispatch::IntegrationTest
|
|
716
|
+
test 'sign out after already having signed out redirects to sign in' do
|
|
717
|
+
sign_in_as_user
|
|
718
|
+
|
|
719
|
+
post destroy_sign_out_via_delete_or_post_session_path
|
|
720
|
+
|
|
721
|
+
get root_path
|
|
722
|
+
assert_contain 'Signed out successfully.'
|
|
723
|
+
|
|
724
|
+
post destroy_sign_out_via_delete_or_post_session_path
|
|
725
|
+
|
|
726
|
+
get root_path
|
|
727
|
+
assert_contain 'Signed out successfully.'
|
|
728
|
+
end
|
|
729
|
+
end
|
|
@@ -21,7 +21,7 @@ class ConfirmationTest < ActionDispatch::IntegrationTest
|
|
|
21
21
|
resend_confirmation
|
|
22
22
|
|
|
23
23
|
assert_current_url '/users/sign_in'
|
|
24
|
-
assert_contain 'You will receive an email with instructions
|
|
24
|
+
assert_contain 'You will receive an email with instructions for how to confirm your email address in a few minutes'
|
|
25
25
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
|
26
26
|
assert_equal ['please-change-me@config-initializers-devise.com'], ActionMailer::Base.deliveries.first.from
|
|
27
27
|
end
|
|
@@ -47,6 +47,37 @@ class ConfirmationTest < ActionDispatch::IntegrationTest
|
|
|
47
47
|
assert_have_selector '#error_explanation'
|
|
48
48
|
assert_contain /needs to be confirmed within 3 days/
|
|
49
49
|
assert_not user.reload.confirmed?
|
|
50
|
+
assert_current_url "/users/confirmation?confirmation_token=#{user.raw_confirmation_token}"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
test 'user with valid confirmation token where the token has expired and with application router_name set to a different engine it should raise an error' do
|
|
55
|
+
user = create_user(confirm: false, confirmation_sent_at: 4.days.ago)
|
|
56
|
+
|
|
57
|
+
swap Devise, confirm_within: 3.days, router_name: :fake_engine do
|
|
58
|
+
assert_raise ActionView::Template::Error do
|
|
59
|
+
visit_user_confirmation_with_token(user.raw_confirmation_token)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
test 'user with valid confirmation token where the token has expired and with application router_name set to a different engine and route overrides back to main it shows the path' do
|
|
65
|
+
user = create_user(confirm: false, confirmation_sent_at: 4.days.ago)
|
|
66
|
+
|
|
67
|
+
swap Devise, confirm_within: 3.days, router_name: :fake_engine do
|
|
68
|
+
visit user_on_main_app_confirmation_path(confirmation_token: user.raw_confirmation_token)
|
|
69
|
+
|
|
70
|
+
assert_current_url "/user_on_main_apps/confirmation?confirmation_token=#{user.raw_confirmation_token}"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
test 'user with valid confirmation token where the token has expired with router overrides different engine it shows the path' do
|
|
75
|
+
user = create_user(confirm: false, confirmation_sent_at: 4.days.ago)
|
|
76
|
+
|
|
77
|
+
swap Devise, confirm_within: 3.days do
|
|
78
|
+
visit user_on_engine_confirmation_path(confirmation_token: user.raw_confirmation_token)
|
|
79
|
+
|
|
80
|
+
assert_current_url "/user_on_engines/confirmation?confirmation_token=#{user.raw_confirmation_token}"
|
|
50
81
|
end
|
|
51
82
|
end
|
|
52
83
|
|
|
@@ -56,7 +87,7 @@ class ConfirmationTest < ActionDispatch::IntegrationTest
|
|
|
56
87
|
assert_not user.confirmed?
|
|
57
88
|
visit_user_confirmation_with_token(user.raw_confirmation_token)
|
|
58
89
|
|
|
59
|
-
assert_contain 'Your
|
|
90
|
+
assert_contain 'Your email address has been successfully confirmed.'
|
|
60
91
|
assert_current_url '/users/sign_in'
|
|
61
92
|
assert user.reload.confirmed?
|
|
62
93
|
end
|
|
@@ -98,7 +129,7 @@ class ConfirmationTest < ActionDispatch::IntegrationTest
|
|
|
98
129
|
swap Devise, allow_unconfirmed_access_for: 0.days do
|
|
99
130
|
sign_in_as_user(confirm: false)
|
|
100
131
|
|
|
101
|
-
assert_contain 'You have to confirm your
|
|
132
|
+
assert_contain 'You have to confirm your email address before continuing'
|
|
102
133
|
assert_not warden.authenticated?(:user)
|
|
103
134
|
end
|
|
104
135
|
end
|
|
@@ -128,11 +159,20 @@ class ConfirmationTest < ActionDispatch::IntegrationTest
|
|
|
128
159
|
user = sign_in_as_user(confirm: false)
|
|
129
160
|
|
|
130
161
|
visit_user_confirmation_with_token(user.raw_confirmation_token)
|
|
131
|
-
assert_contain 'Your
|
|
162
|
+
assert_contain 'Your email address has been successfully confirmed.'
|
|
132
163
|
assert_current_url '/'
|
|
133
164
|
end
|
|
134
165
|
end
|
|
135
166
|
|
|
167
|
+
test 'user should be redirected to sign in page whenever signed in as another resource at same session already' do
|
|
168
|
+
sign_in_as_admin
|
|
169
|
+
|
|
170
|
+
user = create_user(confirm: false)
|
|
171
|
+
visit_user_confirmation_with_token(user.raw_confirmation_token)
|
|
172
|
+
|
|
173
|
+
assert_current_url '/users/sign_in'
|
|
174
|
+
end
|
|
175
|
+
|
|
136
176
|
test 'error message is configurable by resource name' do
|
|
137
177
|
store_translations :en, devise: {
|
|
138
178
|
failure: { user: { unconfirmed: "Not confirmed user" } }
|
|
@@ -187,7 +227,7 @@ class ConfirmationTest < ActionDispatch::IntegrationTest
|
|
|
187
227
|
fill_in 'email', with: user.email
|
|
188
228
|
click_button 'Resend confirmation instructions'
|
|
189
229
|
|
|
190
|
-
assert_contain "If your email address exists in our database, you will receive an email with instructions
|
|
230
|
+
assert_contain "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
|
|
191
231
|
assert_current_url "/users/sign_in"
|
|
192
232
|
end
|
|
193
233
|
end
|
|
@@ -203,7 +243,7 @@ class ConfirmationTest < ActionDispatch::IntegrationTest
|
|
|
203
243
|
assert_not_contain "1 error prohibited this user from being saved:"
|
|
204
244
|
assert_not_contain "Email not found"
|
|
205
245
|
|
|
206
|
-
assert_contain "If your email address exists in our database, you will receive an email with instructions
|
|
246
|
+
assert_contain "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
|
|
207
247
|
assert_current_url "/users/sign_in"
|
|
208
248
|
end
|
|
209
249
|
end
|
|
@@ -232,7 +272,7 @@ class ConfirmationOnChangeTest < ActionDispatch::IntegrationTest
|
|
|
232
272
|
end
|
|
233
273
|
|
|
234
274
|
assert_current_url '/admin_area/sign_in'
|
|
235
|
-
assert_contain 'You will receive an email with instructions
|
|
275
|
+
assert_contain 'You will receive an email with instructions for how to confirm your email address in a few minutes'
|
|
236
276
|
end
|
|
237
277
|
|
|
238
278
|
test 'admin with valid confirmation token should be able to confirm email after email changed' do
|
|
@@ -241,7 +281,7 @@ class ConfirmationOnChangeTest < ActionDispatch::IntegrationTest
|
|
|
241
281
|
assert_equal 'new_test@example.com', admin.unconfirmed_email
|
|
242
282
|
visit_admin_confirmation_with_token(admin.raw_confirmation_token)
|
|
243
283
|
|
|
244
|
-
assert_contain 'Your
|
|
284
|
+
assert_contain 'Your email address has been successfully confirmed.'
|
|
245
285
|
assert_current_url '/admin_area/sign_in'
|
|
246
286
|
assert admin.reload.confirmed?
|
|
247
287
|
assert_not admin.reload.pending_reconfirmation?
|
|
@@ -263,7 +303,7 @@ class ConfirmationOnChangeTest < ActionDispatch::IntegrationTest
|
|
|
263
303
|
assert_contain(/Confirmation token(.*)invalid/)
|
|
264
304
|
|
|
265
305
|
visit_admin_confirmation_with_token(admin.raw_confirmation_token)
|
|
266
|
-
assert_contain 'Your
|
|
306
|
+
assert_contain 'Your email address has been successfully confirmed.'
|
|
267
307
|
assert_current_url '/admin_area/sign_in'
|
|
268
308
|
assert admin.reload.confirmed?
|
|
269
309
|
assert_not admin.reload.pending_reconfirmation?
|