diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-10-22 22:27:20 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-10-22 22:27:20 +0000 |
| commit | f7328804d00d8a82d7ab3a955ff579ff956ef3d0 (patch) | |
| tree | 7a6d5119dea6a6309675120fd99f5cc023ad644a /test/executables/puppetca.rb | |
| parent | 8fe558cca075ab85619a73f4a80408de58810ef7 (diff) | |
| download | puppet-f7328804d00d8a82d7ab3a955ff579ff956ef3d0.tar.gz puppet-f7328804d00d8a82d7ab3a955ff579ff956ef3d0.tar.xz puppet-f7328804d00d8a82d7ab3a955ff579ff956ef3d0.zip | |
Getting rid of the tc_ prefix to test cases
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@724 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/executables/puppetca.rb')
| -rwxr-xr-x | test/executables/puppetca.rb | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/test/executables/puppetca.rb b/test/executables/puppetca.rb new file mode 100755 index 000000000..2fed58557 --- /dev/null +++ b/test/executables/puppetca.rb @@ -0,0 +1,79 @@ +if __FILE__ == $0 + $:.unshift '../../lib' + $:.unshift '..' + $puppetbase = "../.." +end + +require 'puppet' +require 'puppet/server' +require 'puppet/sslcertificates' +require 'test/unit' +require 'puppettest.rb' + +# $Id$ + +# 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 + def mkcert(hostname) + cert = nil + assert_nothing_raised { + cert = Puppet::SSLCertificates::Certificate.new( + :name => hostname + ) + cert.mkcsr + } + + return cert + 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]) + + 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]) + + output = nil + assert_nothing_raised { + output = %x{puppetca --list --ssldir=#{Puppet[:ssldir]} 2>&1}.chomp.split("\n").reject { |line| line =~ /warning:/ } # stupid ssl.rb + } + #Puppet.warning "SSLDir is %s" % Puppet[:ssldir] + #system("find %s" % Puppet[:ssldir]) + assert_equal($?,0) + assert_equal(%w{host.test.com}, output) + assert_nothing_raised { + output = %x{puppetca --sign -a --ssldir=#{Puppet[:ssldir]}}.chomp.split("\n") + } + assert_equal($?,0) + assert_equal([], output) + assert_nothing_raised { + output = %x{puppetca --list --ssldir=#{Puppet[:ssldir]}}.chomp.split("\n") + } + assert_equal($?,0) + assert_equal([], output) + end +end |
