mirror of
https://github.com/redmine/redmine.git
synced 2025-11-08 06:15:59 +01:00
Rake tasks "db:encrypt" and "db:decrypt" may fail due to validation error (#33926).
Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@19999 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -74,7 +74,7 @@ module Redmine
|
|||||||
all.each do |object|
|
all.each do |object|
|
||||||
clear = object.send(attribute)
|
clear = object.send(attribute)
|
||||||
object.send "#{attribute}=", clear
|
object.send "#{attribute}=", clear
|
||||||
raise(ActiveRecord::Rollback) unless object.save(:validation => false)
|
raise(ActiveRecord::Rollback) unless object.save(validate: false)
|
||||||
end
|
end
|
||||||
end ? true : false
|
end ? true : false
|
||||||
end
|
end
|
||||||
@@ -84,7 +84,7 @@ module Redmine
|
|||||||
all.each do |object|
|
all.each do |object|
|
||||||
clear = object.send(attribute)
|
clear = object.send(attribute)
|
||||||
object.send :write_attribute, attribute, clear
|
object.send :write_attribute, attribute, clear
|
||||||
raise(ActiveRecord::Rollback) unless object.save(:validation => false)
|
raise(ActiveRecord::Rollback) unless object.save(validate: false)
|
||||||
end
|
end
|
||||||
end ? true : false
|
end ? true : false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
require File.expand_path('../../../../test_helper', __FILE__)
|
require File.expand_path('../../../../test_helper', __FILE__)
|
||||||
|
|
||||||
class Redmine::CipheringTest < ActiveSupport::TestCase
|
class Redmine::CipheringTest < ActiveSupport::TestCase
|
||||||
|
fixtures :auth_sources
|
||||||
|
|
||||||
def test_password_should_be_encrypted
|
def test_password_should_be_encrypted
|
||||||
Redmine::Configuration.with 'database_cipher_key' => 'secret' do
|
Redmine::Configuration.with 'database_cipher_key' => 'secret' do
|
||||||
@@ -106,4 +107,12 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
|
|||||||
assert_equal 'bar', r.read_attribute(:password)
|
assert_equal 'bar', r.read_attribute(:password)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user