summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-08-09 22:47:32 +0000
committerLuke Kanies <luke@madstop.com>2005-08-09 22:47:32 +0000
commitbb4b5a544e85e5a56065ebb5dd175fbdea7280d2 (patch)
treec26ed941fe70d4674a6bea700135dd76f58a8d8c /test
parente2e247428faa15c299a5dc7bc802afa4a2dbc74a (diff)
downloadpuppet-bb4b5a544e85e5a56065ebb5dd175fbdea7280d2.tar.gz
puppet-bb4b5a544e85e5a56065ebb5dd175fbdea7280d2.tar.xz
puppet-bb4b5a544e85e5a56065ebb5dd175fbdea7280d2.zip
done a lot of work on certificates; all tests except one puppetca test pass
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@523 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/client/tc_client.rb123
-rw-r--r--test/other/tc_selector.rb7
-rwxr-xr-xtest/puppet/tc_defaults.rb6
-rw-r--r--test/types/tc_service.rb5
4 files changed, 106 insertions, 35 deletions
diff --git a/test/client/tc_client.rb b/test/client/tc_client.rb
index 33f40dcf0..2ddf53c98 100644
--- a/test/client/tc_client.rb
+++ b/test/client/tc_client.rb
@@ -7,36 +7,109 @@ end
require 'puppet'
require 'puppet/client'
-#require 'puppet/server'
-require 'puppet/fact'
+require 'puppet/server'
require 'test/unit'
require 'puppettest.rb'
# $Id$
class TestClient < Test::Unit::TestCase
-# def test_local
-# client = nil
-# server = nil
-# assert_nothing_raised() {
-# server = Puppet::Master.new(
-# :File => file,
-# :Local => true
-# )
-# }
-# assert_nothing_raised() {
-# client = Puppet::Client.new(:Server => server)
-# }
-#
-# facts = %w{operatingsystem operatingsystemrelease}
-# facts.each { |fact|
-# assert_equal(
-# Puppet::Fact[fact],
-# client.callfunc("fact",fact)
-# )
-# }
-# end
-
- def test_files
+ def setup
+ Puppet[:loglevel] = :debug if __FILE__ == $0
+ @@tmpfiles = []
+ end
+
+ def teardown
+ Puppet::Type.allclear
+ @@tmpfiles.each { |f|
+ if FileTest.exists?(f)
+ system("rm -rf %s" % f)
+ end
+ }
+ end
+
+ def test_sslInitWithAutosigningLocalServer
+ Puppet[:autosign] = true
+ Puppet[:ssldir] = "/tmp/puppetclientcertests"
+ @@tmpfiles.push Puppet[:ssldir]
+
+ file = File.join($puppetbase, "examples", "code", "head")
+
+ server = nil
+ assert_nothing_raised {
+ server = Puppet::Master.new(
+ :File => file,
+ :Local => true,
+ :CA => true
+ )
+ }
+ client = nil
+ assert_nothing_raised {
+ client = Puppet::Client.new(:Server => server)
+ }
+ assert_nothing_raised {
+ client.initcerts
+ }
+
+ certfile = File.join(Puppet[:certdir], [client.fqdn, "pem"].join("."))
+ keyfile = File.join(Puppet[:privatekeydir], [client.fqdn, "pem"].join("."))
+ publickeyfile = File.join(Puppet[:publickeydir], [client.fqdn, "pem"].join("."))
+
+ assert(File.exists?(keyfile))
+ assert(File.exists?(certfile))
+ assert(File.exists?(publickeyfile))
+ end
+
+ def test_sslInitWithNonsigningLocalServer
+ Puppet[:autosign] = false
+ Puppet[:ssldir] = "/tmp/puppetclientcertests"
+ @@tmpfiles.push Puppet[:ssldir]
+
+ file = File.join($puppetbase, "examples", "code", "head")
+
+ server = nil
+ assert_nothing_raised {
+ server = Puppet::Master.new(
+ :File => file,
+ :Local => true,
+ :CA => true
+ )
+ }
+ client = nil
+ assert_nothing_raised {
+ client = Puppet::Client.new(:Server => server)
+ }
+ certfile = File.join(Puppet[:certdir], [client.fqdn, "pem"].join("."))
+ assert_raise(Puppet::Error) {
+ client.initcerts
+ }
+ assert(! File.exists?(certfile))
+
+ ca = nil
+ assert_nothing_raised {
+ ca = Puppet::SSLCertificates::CA.new()
+ }
+
+
+ csr = nil
+ assert_nothing_raised {
+ csr = ca.getclientcsr(client.fqdn)
+ }
+
+ assert(csr)
+
+ cert = nil
+ assert_nothing_raised {
+ cert = ca.sign(csr)
+ File.open(certfile, "w") { |f| f.print cert.to_pem }
+ }
+
+ # this time it should get the cert correctly
+ assert_nothing_raised {
+ client.initcerts
+ }
+
+ # this isn't a very good test, since i just wrote the file out
+ assert(File.exists?(certfile))
end
end
diff --git a/test/other/tc_selector.rb b/test/other/tc_selector.rb
index 7c8ffbd68..47e0d9ff5 100644
--- a/test/other/tc_selector.rb
+++ b/test/other/tc_selector.rb
@@ -5,14 +5,15 @@ if __FILE__ == $0
end
require 'puppet/selector'
+require 'facter'
require 'test/unit'
# $Id$
class TestSelector < Test::Unit::TestCase
def setup
- @os = Puppet::Fact["operatingsystem"]
- @hostname = Puppet::Fact["hostname"]
+ @os = Facter["operatingsystem"].value
+ @hostname = Facter["hostname"].value
Puppet[:loglevel] = :debug if __FILE__ == $0
end
@@ -22,7 +23,7 @@ class TestSelector < Test::Unit::TestCase
assert_nothing_raised() {
selector = Puppet::Selector.new { |select|
select.add("value1") {
- Puppet::Fact["hostname"] == @hostname
+ Facter["hostname"].value == @hostname
}
}
}
diff --git a/test/puppet/tc_defaults.rb b/test/puppet/tc_defaults.rb
index 06edd7873..0f46e6496 100755
--- a/test/puppet/tc_defaults.rb
+++ b/test/puppet/tc_defaults.rb
@@ -10,9 +10,9 @@ require 'test/unit'
# $Id$
class TestPuppetDefaults < Test::Unit::TestCase
- @@dirs = %w{rrddir puppetconf puppetvar logdir statedir certdir bucketdir}
- @@files = %w{logfile checksumfile localcert localkey localpub
- rootcert rootkey rootpub manifest masterlog}
+ @@dirs = %w{rrddir puppetconf puppetvar logdir statedir}
+ @@files = %w{logfile checksumfile
+ manifest masterlog}
@@normals = %w{puppetport masterport server}
@@booleans = %w{rrdgraph noop}
def testStringOrParam
diff --git a/test/types/tc_service.rb b/test/types/tc_service.rb
index a46f158a1..4bbc37594 100644
--- a/test/types/tc_service.rb
+++ b/test/types/tc_service.rb
@@ -33,6 +33,7 @@ class TestService < Test::Unit::TestCase
def teardown
Puppet::Type.allclear
+ Kernel.system("pkill sleeper")
end
def test_process_start
@@ -83,8 +84,4 @@ class TestService < Test::Unit::TestCase
)
}
end
-
- def teardown
- Kernel.system("pkill sleeper")
- end
end