Defect #33926 ยป 33926.patch
| lib/redmine/ciphering.rb | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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
|
||
| test/unit/lib/redmine/ciphering_test.rb | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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
|
||