diff options
author | Luke Kanies <luke@madstop.com> | 2008-07-02 18:12:26 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-07-02 18:12:26 -0500 |
commit | e03c1be35c5f04ba0e3d301579e8493c00d2ecf9 (patch) | |
tree | f579d054beea5e59f42ef84bde7a5f1d281201dc /test | |
parent | d3a81255245eec19ac21902ae3b877e00e620628 (diff) | |
download | puppet-e03c1be35c5f04ba0e3d301579e8493c00d2ecf9.tar.gz puppet-e03c1be35c5f04ba0e3d301579e8493c00d2ecf9.tar.xz puppet-e03c1be35c5f04ba0e3d301579e8493c00d2ecf9.zip |
Fixing #1382 - existing uppercase certs, keys, et al will be renamed.
This correctly renames the files and they still get read in.
Diffstat (limited to 'test')
-rwxr-xr-x | test/certmgr/support.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/certmgr/support.rb b/test/certmgr/support.rb index cdbbe3fda..c055cbca1 100755 --- a/test/certmgr/support.rb +++ b/test/certmgr/support.rb @@ -78,5 +78,23 @@ class TestCertSupport < Test::Unit::TestCase @user.ca_cert end 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") + end +end |