summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/suidmanager.rb4
-rw-r--r--lib/puppet/util.rb2
-rw-r--r--test/lib/puppettest.rb4
-rwxr-xr-xtest/other/storage.rb6
-rwxr-xr-xtest/types/filesources.rb6
-rw-r--r--test/types/package.rb58
6 files changed, 44 insertions, 36 deletions
diff --git a/lib/puppet/suidmanager.rb b/lib/puppet/suidmanager.rb
index a431e1456..4d00f59b0 100644
--- a/lib/puppet/suidmanager.rb
+++ b/lib/puppet/suidmanager.rb
@@ -63,6 +63,10 @@ module Puppet
module_function :system
def asuser(new_euid=nil, new_egid=nil)
+ # Unless we're root, don't do a damn thing.
+ unless Process.uid == 0
+ return yield
+ end
old_egid = old_euid = nil
if new_egid
saved_state_egid = new_egid
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index 5f8d6f31a..0141d1c3c 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -5,7 +5,7 @@ require 'puppet/lock'
module Puppet
# A command failed to execute.
- class ExecutionFailure < RuntimeError
+ class ExecutionFailure < Puppet::Error
end
module Util
require 'benchmark'
diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb
index e8b328de3..e7ee99c35 100644
--- a/test/lib/puppettest.rb
+++ b/test/lib/puppettest.rb
@@ -151,6 +151,10 @@ module PuppetTest
@@cleaners.each { |cleaner| cleaner.call() }
@@tmpfiles.each { |file|
+ unless file =~ /tmp/
+ puts "Not deleting tmpfile %s" % file
+ next
+ end
if FileTest.exists?(file)
system("chmod -R 755 %s" % file)
system("rm -rf %s" % file)
diff --git a/test/other/storage.rb b/test/other/storage.rb
index 789495fee..2b8dca5e6 100755
--- a/test/other/storage.rb
+++ b/test/other/storage.rb
@@ -21,6 +21,12 @@ class TestStorage < Test::Unit::TestCase
f = mkfile()
+ # Load first, since that's what we do in the code base; this creates
+ # all of the necessary directories.
+ assert_nothing_raised {
+ Puppet::Storage.load
+ }
+
hash = {:a => :b, :c => :d}
state = nil
diff --git a/test/types/filesources.rb b/test/types/filesources.rb
index f121586c3..bdabcf33a 100755
--- a/test/types/filesources.rb
+++ b/test/types/filesources.rb
@@ -257,18 +257,12 @@ class TestFileSources < Test::Unit::TestCase
def test_NetworkSources
server = nil
- basedir = tempfile()
- @@tmpfiles << basedir
- Dir.mkdir(basedir)
-
mounts = {
"/" => "root"
}
fileserverconf = mkfileserverconf(mounts)
- Puppet[:confdir] = basedir
- Puppet[:vardir] = basedir
Puppet[:autosign] = true
Puppet[:masterport] = 8762
diff --git a/test/types/package.rb b/test/types/package.rb
index e290d12ad..a257a9324 100644
--- a/test/types/package.rb
+++ b/test/types/package.rb
@@ -135,6 +135,34 @@ class TestPackages < Test::Unit::TestCase
}
end
+ def test_latestpkg
+ mkpkgs { |pkg|
+ next unless pkg.respond_to? :latest
+ assert_nothing_raised {
+ assert(pkg.latest,
+ "Package %s did not return value for 'latest'" % pkg.name)
+ }
+ }
+ end
+
+ # Make sure our package type supports listing.
+ def test_listing
+ pkgtype = Puppet::Type.type(:package)
+
+ assert_nothing_raised("Could not list packages") do
+ count = 0
+ pkgtype.list.each do |pkg|
+ assert_instance_of(Puppet::Type.type(:package), pkg)
+ count += 1
+ end
+
+ assert(count > 1, "Did not get any packages")
+ end
+ end
+
+ unless Puppet::SUIDManager.uid == 0
+ $stderr.puts "Run as root to perform package installation tests"
+ else
def test_nosuchpkg
obj = nil
assert_nothing_raised {
@@ -160,40 +188,12 @@ class TestPackages < Test::Unit::TestCase
file = tempfile()
File.open(file, "w") { |f| f.puts :yayness }
obj[:source] = file
- assert_raise(Puppet::Error,
+ assert_raise(Puppet::Error, Puppet::ExecutionFailure,
"Successfully installed nonexistent package") {
state.sync
}
end
- def test_latestpkg
- mkpkgs { |pkg|
- next unless pkg.respond_to? :latest
- assert_nothing_raised {
- assert(pkg.latest,
- "Package %s did not return value for 'latest'" % pkg.name)
- }
- }
- end
-
- # Make sure our package type supports listing.
- def test_listing
- pkgtype = Puppet::Type.type(:package)
-
- assert_nothing_raised("Could not list packages") do
- count = 0
- pkgtype.list.each do |pkg|
- assert_instance_of(Puppet::Type.type(:package), pkg)
- count += 1
- end
-
- assert(count > 1, "Did not get any packages")
- end
- end
-
- unless Puppet::SUIDManager.uid == 0
- $stderr.puts "Run as root to perform package installation tests"
- else
def test_installpkg
mkpkgs { |pkg|
# we first set install to 'true', and make sure something gets