diff options
-rw-r--r-- | lib/puppet/sslcertificates/support.rb | 1 | ||||
-rwxr-xr-x | test/certmgr/support.rb | 43 |
2 files changed, 27 insertions, 17 deletions
diff --git a/lib/puppet/sslcertificates/support.rb b/lib/puppet/sslcertificates/support.rb index 95f15f0a8..bab250d47 100644 --- a/lib/puppet/sslcertificates/support.rb +++ b/lib/puppet/sslcertificates/support.rb @@ -28,6 +28,7 @@ module Puppet::SSLCertificates::Support # Define the reading method. define_method(reader) do + p Puppet[param] return nil unless FileTest.exists?(Puppet[param]) or rename_files_with_uppercase(Puppet[param]) begin diff --git a/test/certmgr/support.rb b/test/certmgr/support.rb index c055cbca1..10d431939 100755 --- a/test/certmgr/support.rb +++ b/test/certmgr/support.rb @@ -79,22 +79,31 @@ class TestCertSupport < Test::Unit::TestCase end end - # Fixing #1382. - def test_uppercase_files_are_renamed_and_read - # Write a key out to disk in a file containing upper-case. - key = OpenSSL::PKey::RSA.new(32) - should_path = Puppet[:hostprivkey] - - dir, file = File.split(should_path) - newfile = file.sub(/^([a-z.]+)\./) { $1.upcase + "."} - upper_path = File.join(dir, newfile) - File.open(upper_path, "w") { |f| f.print key.to_s } - - user = CertUser.new - - assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk") - assert(! FileTest.exist?(upper_path), "Upper case file was not removed") - assert(FileTest.exist?(should_path), "File was not renamed to lower-case file") - assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk") + # Fixing #1382. This test will always fail on Darwin, because its + # FS is case-insensitive. + unless Facter.value(:operatingsystem) == "Darwin" + def test_uppercase_files_are_renamed_and_read + # Write a key out to disk in a file containing upper-case. + key = OpenSSL::PKey::RSA.new(32) + should_path = Puppet[:hostprivkey] + puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect] + + dir, file = File.split(should_path) + newfile = file.sub(/^([a-z.]+)\./) { $1.upcase + "."} + puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect] + upper_path = File.join(dir, newfile) + puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect] + puts "%s: %s" % [upper_path, FileTest.exist?(upper_path).inspect] + File.open(upper_path, "w") { |f| f.print key.to_s } + puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect] + puts "%s: %s" % [upper_path, FileTest.exist?(upper_path).inspect] + + user = CertUser.new + + assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk") + assert(! FileTest.exist?(upper_path), "Upper case file was not removed") + assert(FileTest.exist?(should_path), "File was not renamed to lower-case file") + assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk") + end end end |