From 5d1388db02a263de3515700e9c2f8a6a4a98ef00 2011-11-29 21:11:54 From: Jean-Philippe Lang Date: 2011-11-29 21:11:54 Subject: [PATCH] Merged r7985 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@7997 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/lib/redmine/ciphering.rb b/lib/redmine/ciphering.rb index 8efe37c..09509a0 100644 --- a/lib/redmine/ciphering.rb +++ b/lib/redmine/ciphering.rb @@ -23,7 +23,7 @@ module Redmine class << self def encrypt_text(text) - if cipher_key.blank? + if cipher_key.blank? || text.blank? text else c = OpenSSL::Cipher::Cipher.new("aes-256-cbc") diff --git a/test/unit/lib/redmine/ciphering_test.rb b/test/unit/lib/redmine/ciphering_test.rb index 5af5f71..958c4dd 100644 --- a/test/unit/lib/redmine/ciphering_test.rb +++ b/test/unit/lib/redmine/ciphering_test.rb @@ -43,6 +43,14 @@ class Redmine::CipheringTest < ActiveSupport::TestCase end end + def test_blank_password_should_be_clear + Redmine::Configuration.with 'database_cipher_key' => 'secret' do + r = Repository::Subversion.generate!(:password => '') + assert_equal '', r.password + assert_equal '', r.read_attribute(:password) + end + end + def test_unciphered_password_should_be_readable Redmine::Configuration.with 'database_cipher_key' => nil do r = Repository::Subversion.generate!(:password => 'clear')