diff options
author | Go MAEDA <maeda@farend.jp> | 2020-09-02 08:48:36 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2020-09-02 08:48:36 +0000 |
commit | 82c2c4f5332d93b48c30312a67a7382c6010cfd6 (patch) | |
tree | 187c21e81812fa57a263cf6da3c31480fbcfac7d | |
parent | 970ef52d36714095086b38a56c15706931949f41 (diff) | |
download | redmine-82c2c4f5332d93b48c30312a67a7382c6010cfd6.tar.gz redmine-82c2c4f5332d93b48c30312a67a7382c6010cfd6.zip |
Merged r19999 from trunk to 4.0-stable (#33926).
git-svn-id: http://svn.redmine.org/redmine/branches/4.0-stable@20004 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | lib/redmine/ciphering.rb | 4 | ||||
-rw-r--r-- | test/unit/lib/redmine/ciphering_test.rb | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/redmine/ciphering.rb b/lib/redmine/ciphering.rb index ad30e035f..6b9364219 100644 --- a/lib/redmine/ciphering.rb +++ b/lib/redmine/ciphering.rb @@ -72,7 +72,7 @@ module Redmine all.each do |object| clear = object.send(attribute) object.send "#{attribute}=", clear - raise(ActiveRecord::Rollback) unless object.save(:validation => false) + raise(ActiveRecord::Rollback) unless object.save(validate: false) end end ? true : false end @@ -82,7 +82,7 @@ module Redmine all.each do |object| clear = object.send(attribute) object.send :write_attribute, attribute, clear - raise(ActiveRecord::Rollback) unless object.save(:validation => false) + raise(ActiveRecord::Rollback) unless object.save(validate: false) end end ? true : false end diff --git a/test/unit/lib/redmine/ciphering_test.rb b/test/unit/lib/redmine/ciphering_test.rb index 38f87b419..d6f9d162c 100644 --- a/test/unit/lib/redmine/ciphering_test.rb +++ b/test/unit/lib/redmine/ciphering_test.rb @@ -18,6 +18,7 @@ require File.expand_path('../../../../test_helper', __FILE__) class Redmine::CipheringTest < ActiveSupport::TestCase + fixtures :auth_sources def test_password_should_be_encrypted Redmine::Configuration.with 'database_cipher_key' => 'secret' do @@ -104,4 +105,12 @@ class Redmine::CipheringTest < ActiveSupport::TestCase assert_equal 'bar', r.read_attribute(:password) end end + + def test_encrypt_all_and_decrypt_all_should_skip_validation + auth_source = auth_sources(:auth_sources_001) + # validator checks if AuthSource#host is present + auth_source.update_column(:host, nil) + assert AuthSource.encrypt_all(:account_password) + assert AuthSource.decrypt_all(:account_password) + end end |