summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/executables/tc_puppetca.rb4
-rwxr-xr-xtest/executables/tc_puppetd.rb5
-rw-r--r--test/other/tc_metrics.rb4
-rw-r--r--test/puppettest.rb10
-rw-r--r--test/server/tc_bucket.rb2
-rw-r--r--test/server/tc_ca.rb53
-rw-r--r--test/tagging/tc_tagging.rb3
7 files changed, 60 insertions, 21 deletions
diff --git a/test/executables/tc_puppetca.rb b/test/executables/tc_puppetca.rb
index 61b83b178..2fed58557 100755
--- a/test/executables/tc_puppetca.rb
+++ b/test/executables/tc_puppetca.rb
@@ -49,7 +49,9 @@ class TestPuppetCA < Test::Unit::TestCase
cert = mkcert("host.test.com")
resp = nil
assert_nothing_raised {
- resp = ca.getcert(cert.csr.to_pem)
+ # 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]
diff --git a/test/executables/tc_puppetd.rb b/test/executables/tc_puppetd.rb
index e7a55b480..72cf1f031 100755
--- a/test/executables/tc_puppetd.rb
+++ b/test/executables/tc_puppetd.rb
@@ -36,7 +36,7 @@ class TestPuppetDExe < Test::Unit::TestCase
cmd = "puppetd"
cmd += " --verbose"
- cmd += " --fqdn %s" % fqdn
+ #cmd += " --fqdn %s" % fqdn
cmd += " --port %s" % @@port
cmd += " --ssldir %s" % Puppet[:ssldir]
cmd += " --server localhost"
@@ -44,11 +44,10 @@ class TestPuppetDExe < Test::Unit::TestCase
# and verify our daemon runs
assert_nothing_raised {
output = %x{#{cmd}}.chomp
+ puts output
}
sleep 1
assert($? == 0, "Puppetd exited with code %s" % $?)
- #puts output
- #assert_equal("", output, "Puppetd produced output %s" % output)
assert(FileTest.exists?(@createdfile),
"Failed to create config'ed file")
diff --git a/test/other/tc_metrics.rb b/test/other/tc_metrics.rb
index 9db8683e9..dbae3cf54 100644
--- a/test/other/tc_metrics.rb
+++ b/test/other/tc_metrics.rb
@@ -9,8 +9,6 @@ require 'puppet'
require 'puppet/type'
require 'test/unit'
-# $Id$
-
$haverrd = true
begin
require 'RRD'
@@ -90,3 +88,5 @@ if $haverrd
else
$stderr.puts "Missing RRD library -- skipping metric tests"
end
+
+# $Id$
diff --git a/test/puppettest.rb b/test/puppettest.rb
index 2aba1f7c6..daa13e3d9 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -16,6 +16,11 @@ module TestPuppet
end
def setup
+ if defined? @@testcount
+ @@testcount += 1
+ else
+ @@testcount = 0
+ end
if $0 =~ /tc_.+\.rb/
Puppet[:loglevel] = :debug
$VERBOSE = 1
@@ -24,7 +29,10 @@ module TestPuppet
Puppet[:httplog] = "/dev/null"
end
- @configpath = File.join(tmpdir, self.class.to_s + "configdir")
+ @configpath = File.join(tmpdir,
+ self.class.to_s + "configdir" + @@testcount.to_s
+ )
+
Puppet[:puppetconf] = @configpath
Puppet[:puppetvar] = @configpath
diff --git a/test/server/tc_bucket.rb b/test/server/tc_bucket.rb
index 658b8fcce..5d45eedb2 100644
--- a/test/server/tc_bucket.rb
+++ b/test/server/tc_bucket.rb
@@ -204,7 +204,7 @@ class TestBucket < Test::Unit::TestCase
client = nil
port = Puppet[:masterport]
- pid = mkserver(:CA => nil, :FileBucket => { :Bucket => @bucket})
+ pid = mkserver(:CA => {}, :FileBucket => { :Bucket => @bucket})
assert_nothing_raised {
client = Puppet::Client::Dipper.new(
diff --git a/test/server/tc_ca.rb b/test/server/tc_ca.rb
index 39c476675..b48cb42c7 100644
--- a/test/server/tc_ca.rb
+++ b/test/server/tc_ca.rb
@@ -26,14 +26,14 @@ class TestCA < Test::Unit::TestCase
print "\n\n" if Puppet[:debug]
end
- # verify that we're autosigning
- def test_zautocertgeneration
- Puppet[:autosign] = true
+ # Verify that we're autosigning. We have to autosign a "different" machine,
+ # since we always autosign the CA server's certificate.
+ def test_autocertgeneration
ca = nil
# create our ca
assert_nothing_raised {
- ca = Puppet::Server::CA.new()
+ ca = Puppet::Server::CA.new(:autosign => true)
}
# create a cert with a fake name
@@ -74,7 +74,9 @@ class TestCA < Test::Unit::TestCase
# and pull it again, just to make sure we're getting the same thing
newtext = nil
assert_nothing_raised {
- newtext, cacerttext = ca.getcert(cert.csr.to_s)
+ newtext, cacerttext = ca.getcert(
+ cert.csr.to_s, "test.reductivelabs.com", "127.0.0.1"
+ )
}
assert_equal(certtext,newtext)
@@ -82,15 +84,12 @@ class TestCA < Test::Unit::TestCase
# this time don't use autosign
def test_storeAndSign
- assert_nothing_raised {
- Puppet[:autosign] = false
- }
ca = nil
caserv = nil
# make our CA server
assert_nothing_raised {
- caserv = Puppet::Server::CA.new()
+ caserv = Puppet::Server::CA.new(:autosign => false)
}
# retrieve the actual ca object
@@ -116,7 +115,9 @@ class TestCA < Test::Unit::TestCase
# retrieve them
certtext = nil
assert_nothing_raised {
- certtext, cacerttext = caserv.getcert(cert.csr.to_s)
+ certtext, cacerttext = caserv.getcert(
+ cert.csr.to_s, "test.reductivelabs.com", "127.0.0.1"
+ )
}
# verify we got nothing back, since autosign is off
@@ -151,7 +152,6 @@ class TestCA < Test::Unit::TestCase
# and now test the autosign file
def test_autosign
autosign = File.join(tmpdir, "autosigntesting")
- Puppet[:autosign] = autosign
@@tmpfiles << autosign
File.open(autosign, "w") { |f|
f.puts "hostmatch.domain.com"
@@ -160,7 +160,7 @@ class TestCA < Test::Unit::TestCase
caserv = nil
assert_nothing_raised {
- caserv = Puppet::Server::CA.new()
+ caserv = Puppet::Server::CA.new(:autosign => autosign)
}
# make sure we know what's going on
@@ -169,4 +169,33 @@ class TestCA < Test::Unit::TestCase
assert(!caserv.autosign?("kirby.reductivelabs.com"))
assert(!caserv.autosign?("culain.domain.com"))
end
+
+ # verify that things aren't autosigned by default
+ def test_nodefaultautosign
+ caserv = nil
+ assert_nothing_raised {
+ caserv = Puppet::Server::CA.new()
+ }
+
+ # make sure we know what's going on
+ assert(!caserv.autosign?("hostmatch.domain.com"))
+ assert(!caserv.autosign?("fakehost.other.com"))
+ assert(!caserv.autosign?("kirby.reductivelabs.com"))
+ assert(!caserv.autosign?("culain.domain.com"))
+ end
+
+ # We want the CA to autosign its own certificate, because otherwise
+ # the puppetmasterd CA does not autostart.
+ def test_caautosign
+ server = nil
+ assert_nothing_raised {
+ server = Puppet::Server.new(
+ :Port => @@port,
+ :Handlers => {
+ :CA => {}, # so that certs autogenerate
+ :Status => nil
+ }
+ )
+ }
+ end
end
diff --git a/test/tagging/tc_tagging.rb b/test/tagging/tc_tagging.rb
index a3bc9592b..260e0e53a 100644
--- a/test/tagging/tc_tagging.rb
+++ b/test/tagging/tc_tagging.rb
@@ -38,7 +38,8 @@ class TestTagging < Test::Unit::TestCase
}
assert_nothing_raised {
- assert_equal(%w{solaris apache}, scope.tags, "Incorrect scope tags")
+ # Scopes put their own tags first
+ assert_equal(%w{apache solaris}, scope.tags, "Incorrect scope tags")
}
end