diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-03-02 20:28:45 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-03-02 20:28:45 +0000 |
| commit | 343dd08a4ab84bdc6947239e8c514752db219c2a (patch) | |
| tree | 438f144f98a56ef6e35e4c4b670318f15c81eb31 | |
| parent | 1a93c822667e6990b45f843e56d8976c51517671 (diff) | |
| download | puppet-343dd08a4ab84bdc6947239e8c514752db219c2a.tar.gz puppet-343dd08a4ab84bdc6947239e8c514752db219c2a.tar.xz puppet-343dd08a4ab84bdc6947239e8c514752db219c2a.zip | |
Fixing tests so they do not chmod /dev/null to 640 (stupid tests).
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@967 980ebf18-57e1-0310-9a29-db15c13687c0
| -rw-r--r-- | lib/puppet/config.rb | 1 | ||||
| -rw-r--r-- | lib/puppet/type/nameservice/pw.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/util.rb | 1 | ||||
| -rw-r--r-- | test/client/client.rb | 68 | ||||
| -rwxr-xr-x | test/executables/puppetd.rb | 2 | ||||
| -rwxr-xr-x | test/other/config.rb | 18 | ||||
| -rwxr-xr-x | test/puppet/utiltest.rb | 10 | ||||
| -rw-r--r-- | test/puppettest.rb | 10 |
8 files changed, 37 insertions, 77 deletions
diff --git a/lib/puppet/config.rb b/lib/puppet/config.rb index e38e26517..ff6dd9cbf 100644 --- a/lib/puppet/config.rb +++ b/lib/puppet/config.rb @@ -336,6 +336,7 @@ class Config end if obj.respond_to? :to_transportable + next if obj.value =~ /^\/dev/ transobjects = obj.to_transportable transobjects = [transobjects] unless transobjects.is_a? Array transobjects.each do |trans| diff --git a/lib/puppet/type/nameservice/pw.rb b/lib/puppet/type/nameservice/pw.rb index 421472149..4f2a1c7b2 100644 --- a/lib/puppet/type/nameservice/pw.rb +++ b/lib/puppet/type/nameservice/pw.rb @@ -18,7 +18,7 @@ module Puppet # Does the object already exist? def self.exists?(obj) - if obj.getinfo + if obj.getinfo(true) return true else return false @@ -33,7 +33,7 @@ module Puppet cmd = ["pw", "groupadd", @parent[:name]] if gid = @parent.should(:gid) unless gid == :auto - cmd << self.class.objectaddflag << gid + cmd << @parent.state(:gid).class.objectaddflag << gid end end diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index fd283539b..1d4515b3d 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -284,6 +284,7 @@ module Util end end + # Execute a given chunk of code with a new umask. def self.withumask(mask) cur = File.umask(mask) diff --git a/test/client/client.rb b/test/client/client.rb index 659378abd..117d30426 100644 --- a/test/client/client.rb +++ b/test/client/client.rb @@ -150,72 +150,4 @@ class TestClient < Test::Unit::TestCase certbucket.backup("/etc/passwd") } end - - # disabled because the server needs to have its certs in place - # in order to start at all - # i don't think this test makes much sense anyway - def disabled_test_sslInitWithNonsigningLocalServer - Puppet[:autosign] = false - Puppet[:ssldir] = tempfile() - @@tmpfiles.push Puppet[:ssldir] - - file = File.join($puppetbase, "examples", "code", "head") - - server = nil - port = 8086 - assert_nothing_raised { - server = Puppet::Server.new( - :Port => port, - :Handlers => { - :CA => {}, # so that certs autogenerate - :Master => { - :File => file, - }, - } - ) - } - - spid = fork { - trap(:INT) { server.shutdown } - server.start - } - - @@tmppids << spid - client = nil - assert_nothing_raised { - client = Puppet::Client.new(:Server => "localhost", :Port => port) - } - certfile = File.join(Puppet[:certdir], [client.fqdn, "pem"].join(".")) - cafile = File.join(Puppet[:certdir], ["ca", "pem"].join(".")) - assert_nil(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, cacert = ca.sign(csr) - File.open(certfile, "w") { |f| f.print cert.to_pem } - File.open(cafile, "w") { |f| f.print cacert.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/executables/puppetd.rb b/test/executables/puppetd.rb index 1ac53db16..4d74782c6 100755 --- a/test/executables/puppetd.rb +++ b/test/executables/puppetd.rb @@ -34,7 +34,7 @@ class TestPuppetDExe < Test::Unit::TestCase # and verify our daemon runs assert_nothing_raised { - system cmd + system(cmd) } sleep 1 assert($? == 0, "Puppetd exited with code %s" % $?) diff --git a/test/other/config.rb b/test/other/config.rb index f01aeeaaf..b404f93ad 100755 --- a/test/other/config.rb +++ b/test/other/config.rb @@ -478,6 +478,24 @@ yay = /a/path "Group object is not managed." ) end + + def test_notmanagingdev + c = mkconfig + path = "/dev/testing" + c.setdefaults(:test, + :file => { + :default => path, + :mode => 0640, + :desc => 'yay' + } + ) + + assert_nothing_raised { + c.to_component + } + + assert(! Puppet.type(:file)["/dev/testing"], "Created dev file") + end end # $Id$ diff --git a/test/puppet/utiltest.rb b/test/puppet/utiltest.rb index 68b55b1ff..34278716f 100755 --- a/test/puppet/utiltest.rb +++ b/test/puppet/utiltest.rb @@ -144,15 +144,17 @@ class TestPuppetUtil < Test::Unit::TestCase end def test_withumask - File.umask(022) + oldmask = File.umask path = tempfile() + + # FIXME this fails on FreeBSD with a mode of 01777 Puppet::Util.withumask(000) do - Dir.mkdir(path, 01777) + Dir.mkdir(path, 0777) end - assert(File.stat(path).mode & 007777 == 01777) - assert_equal(022, File.umask) + assert(File.stat(path).mode & 007777 == 0777, "File has the incorrect mode") + assert_equal(oldmask, File.umask, "Umask was not reset") end unless Process.uid == 0 diff --git a/test/puppettest.rb b/test/puppettest.rb index dc1f94def..54dfc1f17 100644 --- a/test/puppettest.rb +++ b/test/puppettest.rb @@ -50,8 +50,8 @@ module TestPuppet $VERBOSE = 1 else Puppet::Log.close - Puppet::Log.newdestination "/dev/null" - Puppet[:httplog] = "/dev/null" + Puppet::Log.newdestination tempfile() + Puppet[:httplog] = tempfile() end Puppet[:ignoreschedules] = true @@ -120,6 +120,12 @@ module TestPuppet # Just in case there are processes waiting to die... Process.waitall + if File.stat("/dev/null").mode & 007777 != 0666 + File.open("/tmp/nullfailure", "w") { |f| + f.puts self.class + } + exit(74) + end end def tempfile |
