summaryrefslogtreecommitdiffstats
path: root/test/certmgr
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-27 17:18:35 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-27 17:18:35 +0000
commit8ff7e0c75eda0291a169074c67fa0a90db9c4e7b (patch)
tree412ef1e461736028c982176dbec377e5016a80c5 /test/certmgr
parentf1dc103396511d30aa8ae42036b6aa1aee712da3 (diff)
downloadpuppet-8ff7e0c75eda0291a169074c67fa0a90db9c4e7b.tar.gz
puppet-8ff7e0c75eda0291a169074c67fa0a90db9c4e7b.tar.xz
puppet-8ff7e0c75eda0291a169074c67fa0a90db9c4e7b.zip
Closing #362. Case-insensitivity is handled by downcasing all host names.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1971 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/certmgr')
-rwxr-xr-xtest/certmgr/ca.rb72
-rwxr-xr-xtest/certmgr/certmgr.rb9
2 files changed, 72 insertions, 9 deletions
diff --git a/test/certmgr/ca.rb b/test/certmgr/ca.rb
new file mode 100755
index 000000000..d01725970
--- /dev/null
+++ b/test/certmgr/ca.rb
@@ -0,0 +1,72 @@
+#!/usr/bin/env ruby
+
+$:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/
+
+require 'puppet'
+require 'puppet/sslcertificates/ca.rb'
+require 'puppettest'
+require 'puppettest/certificates'
+
+class TestCA < Test::Unit::TestCase
+ include PuppetTest
+ def hosts
+ %w{host.domain.com Other.Testing.Com}
+ end
+ def mkca
+ Puppet::SSLCertificates::CA.new
+ end
+
+ def test_clean
+ dirs = [:csrdir, :signeddir, :publickeydir, :privatekeydir, :certdir]
+ ca = mkca
+
+ hosts.each do |host|
+ files = []
+ dirs.each do |dir|
+ dir = Puppet[dir]
+ # We handle case insensitivity through downcasing
+ file = File.join(dir, host.downcase + ".pem")
+ File.open(file, "w") do |f|
+ f.puts "testing"
+ end
+ files << file
+ end
+ assert_nothing_raised do
+ ca.clean(host)
+ end
+ files.each do |f|
+ assert(! FileTest.exists?(f), "File %s was not deleted" % f)
+ end
+ end
+ end
+
+ def test_host2Xfile
+ ca = mkca
+ hosts.each do |host|
+ {:signeddir => :host2certfile, :csrdir => :host2csrfile}.each do |dir, method|
+ val = nil
+ assert_nothing_raised do
+ val = ca.send(method, host)
+ end
+ assert_equal(File.join(Puppet[dir], host.downcase + ".pem"), val,
+ "incorrect response from %s" % method)
+ end
+ end
+ end
+
+ def test_list
+ ca = mkca
+ # Make a fake csr
+ dir = Puppet[:csrdir]
+ list = []
+ hosts.each do |host|
+ file = File.join(dir, host.downcase + ".pem")
+ File.open(file, "w") { |f| f.puts "yay" }
+ list << host.downcase
+ end
+
+ assert_equal(list.sort, ca.list.sort, "list was not correct")
+ end
+end
+
+# $Id$
diff --git a/test/certmgr/certmgr.rb b/test/certmgr/certmgr.rb
index 32934e8ce..90d516cb4 100755
--- a/test/certmgr/certmgr.rb
+++ b/test/certmgr/certmgr.rb
@@ -7,15 +7,6 @@ require 'puppet/sslcertificates.rb'
require 'puppettest'
require 'puppettest/certificates'
-# so, what kind of things do we want to test?
-
-# we don't need to test function, since we're confident in the
-# library tests. We do, however, need to test how things are actually
-# working in the language.
-
-# so really, we want to do things like test that our ast is correct
-# and test whether we've got things in the right scopes
-
class TestCertMgr < Test::Unit::TestCase
include PuppetTest::Certificates
def setup