Defect #33926 ยป 33926.patch
| lib/redmine/ciphering.rb | ||
|---|---|---|
| 74 | 74 |
all.each do |object| |
| 75 | 75 |
clear = object.send(attribute) |
| 76 | 76 |
object.send "#{attribute}=", clear
|
| 77 |
raise(ActiveRecord::Rollback) unless object.save(:validation => false)
|
|
| 77 |
raise(ActiveRecord::Rollback) unless object.save(validate: false)
|
|
| 78 | 78 |
end |
| 79 | 79 |
end ? true : false |
| 80 | 80 |
end |
| ... | ... | |
| 84 | 84 |
all.each do |object| |
| 85 | 85 |
clear = object.send(attribute) |
| 86 | 86 |
object.send :write_attribute, attribute, clear |
| 87 |
raise(ActiveRecord::Rollback) unless object.save(:validation => false)
|
|
| 87 |
raise(ActiveRecord::Rollback) unless object.save(validate: false)
|
|
| 88 | 88 |
end |
| 89 | 89 |
end ? true : false |
| 90 | 90 |
end |
| test/unit/lib/redmine/ciphering_test.rb | ||
|---|---|---|
| 20 | 20 |
require File.expand_path('../../../../test_helper', __FILE__)
|
| 21 | 21 | |
| 22 | 22 |
class Redmine::CipheringTest < ActiveSupport::TestCase |
| 23 |
fixtures :auth_sources |
|
| 23 | 24 | |
| 24 | 25 |
def test_password_should_be_encrypted |
| 25 | 26 |
Redmine::Configuration.with 'database_cipher_key' => 'secret' do |
| ... | ... | |
| 106 | 107 |
assert_equal 'bar', r.read_attribute(:password) |
| 107 | 108 |
end |
| 108 | 109 |
end |
| 110 | ||
| 111 |
def test_encrypt_all_and_decrypt_all_should_skip_validation |
|
| 112 |
auth_source = auth_sources(:auth_sources_001) |
|
| 113 |
# validator checks if AuthSource#host is present |
|
| 114 |
auth_source.update_column(:host, nil) |
|
| 115 |
assert AuthSource.encrypt_all(:account_password) |
|
| 116 |
assert AuthSource.decrypt_all(:account_password) |
|
| 117 |
end |
|
| 109 | 118 |
end |