test/executables/puppetca.rb in puppet-0.9.2 vs test/executables/puppetca.rb in puppet-0.13.0
- old
+ new
@@ -8,23 +8,12 @@
require 'puppet/server'
require 'puppet/sslcertificates'
require 'test/unit'
require 'puppettest.rb'
-# $Id: puppetca.rb 724 2005-10-22 22:27:20Z luke $
-
-# ok, we have to add the bin directory to our search path
-ENV["PATH"] += ":" + File.join($puppetbase, "bin")
-
-# and then the library directories
-libdirs = $:.find_all { |dir|
- dir =~ /puppet/ or dir =~ /\.\./
-}
-ENV["RUBYLIB"] = libdirs.join(":")
-
class TestPuppetCA < Test::Unit::TestCase
- include ServerTest
+ include ExeTest
def mkcert(hostname)
cert = nil
assert_nothing_raised {
cert = Puppet::SSLCertificates::Certificate.new(
:name => hostname
@@ -32,48 +21,53 @@
cert.mkcsr
}
return cert
end
+
+ def runca(args)
+ return %x{puppetca --confdir=#{Puppet[:confdir]} --user #{Process.uid} --group #{Process.gid} #{args} 2>&1}
+ end
+
def test_signing
ca = nil
- Puppet[:ssldir] = "/tmp/puppetcatest"
- @@tmpfiles << Puppet[:ssldir]
Puppet[:autosign] = false
assert_nothing_raised {
ca = Puppet::Server::CA.new()
}
- #Puppet.warning "SSLDir is %s" % Puppet[:ssldir]
- #system("find %s" % Puppet[:ssldir])
+ #Puppet.warning "SSLDir is %s" % Puppet[:confdir]
+ #system("find %s" % Puppet[:confdir])
cert = mkcert("host.test.com")
resp = nil
assert_nothing_raised {
# We need to use a fake name so it doesn't think the cert is from
# itself.
resp = ca.getcert(cert.csr.to_pem, "fakename", "127.0.0.1")
}
assert_equal(["",""], resp)
- #Puppet.warning "SSLDir is %s" % Puppet[:ssldir]
- #system("find %s" % Puppet[:ssldir])
+ #Puppet.warning "SSLDir is %s" % Puppet[:confdir]
+ #system("find %s" % Puppet[:confdir])
output = nil
assert_nothing_raised {
- output = %x{puppetca --list --ssldir=#{Puppet[:ssldir]} 2>&1}.chomp.split("\n").reject { |line| line =~ /warning:/ } # stupid ssl.rb
+ output = runca("--list").chomp.split("\n").reject { |line| line =~ /warning:/ } # stupid ssl.rb
}
- #Puppet.warning "SSLDir is %s" % Puppet[:ssldir]
- #system("find %s" % Puppet[:ssldir])
+ #Puppet.warning "SSLDir is %s" % Puppet[:confdir]
+ #system("find %s" % Puppet[:confdir])
assert_equal($?,0)
assert_equal(%w{host.test.com}, output)
assert_nothing_raised {
- output = %x{puppetca --sign -a --ssldir=#{Puppet[:ssldir]}}.chomp.split("\n")
+ output = runca("--sign -a").chomp.split("\n")
}
assert_equal($?,0)
- assert_equal([], output)
+ assert_equal(["Signed host.test.com"], output)
assert_nothing_raised {
- output = %x{puppetca --list --ssldir=#{Puppet[:ssldir]}}.chomp.split("\n")
+ output = runca("--list").chomp.split("\n")
}
assert_equal($?,0)
assert_equal([], output)
end
end
+
+# $Id: puppetca.rb 873 2006-02-07 23:12:33Z luke $