summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-08-29 01:35:09 +0000
committerGo MAEDA <maeda@farend.jp>2019-08-29 01:35:09 +0000
commit35e6a532f56d1a3e54476d2adb36375169e9bef9 (patch)
tree6d225402666ad8aa85b2fe6f9d40c427669368fc /test
parent0d9f7ee64a43ce75dd87c8d035a9d335b1077c16 (diff)
downloadredmine-35e6a532f56d1a3e54476d2adb36375169e9bef9.tar.gz
redmine-35e6a532f56d1a3e54476d2adb36375169e9bef9.zip
Force passwords to contain specified character classes (#4221).
Patch by Takenori TAKAKI. git-svn-id: http://svn.redmine.org/redmine/trunk@18411 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/user_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index e03528809..519de8b04 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -539,6 +539,18 @@ class UserTest < ActiveSupport::TestCase
end
end
+ def test_validate_password_format
+ Setting::PASSWORD_CHAR_CLASSES.each do |key, regexp|
+ with_settings :password_required_char_classes => key do
+ user = User.new(:firstname => "new", :lastname => "user", :login => "random", :mail => "random@somnet.foo")
+ p = 'PASSWDpasswd01234!@#$%'.gsub(regexp, '')
+ user.password, user.password_confirmation = p, p
+ assert !user.save
+ assert_equal 1, user.errors.count
+ end
+ end
+ end
+
def test_name_format
assert_equal 'John S.', @jsmith.name(:firstname_lastinitial)
assert_equal 'Smith, John', @jsmith.name(:lastname_comma_firstname)
@@ -1058,6 +1070,14 @@ class UserTest < ActiveSupport::TestCase
assert !u.password_confirmation.blank?
end
+ def test_random_password_include_required_characters
+ with_settings :password_required_char_classes => Setting::PASSWORD_CHAR_CLASSES do
+ u = User.new(:firstname => "new", :lastname => "user", :login => "random", :mail => "random@somnet.foo")
+ u.random_password
+ assert u.valid?
+ end
+ end
+
test "#change_password_allowed? should be allowed if no auth source is set" do
user = User.generate!
assert user.change_password_allowed?