summaryrefslogtreecommitdiffstats
path: root/test/util
diff options
context:
space:
mode:
authorchristian <christian@980ebf18-57e1-0310-9a29-db15c13687c0>2007-08-09 08:45:50 +0000
committerchristian <christian@980ebf18-57e1-0310-9a29-db15c13687c0>2007-08-09 08:45:50 +0000
commit3de4829cf0b607624b8a5f5f1e6055141d85af2f (patch)
tree16cb9ef447771dace252003abba400a40d8b520d /test/util
parent5a25701723431e0ebe2d7134ab65d56bee2c5244 (diff)
downloadpuppet-3de4829cf0b607624b8a5f5f1e6055141d85af2f.tar.gz
puppet-3de4829cf0b607624b8a5f5f1e6055141d85af2f.tar.xz
puppet-3de4829cf0b607624b8a5f5f1e6055141d85af2f.zip
Refactor SUIDManager tests to run without root, change SUIDManager's behavior to not silently fail when it's not root and fix all other tests that broke as a result.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2759 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/util')
-rwxr-xr-xtest/util/utiltest.rb109
1 files changed, 0 insertions, 109 deletions
diff --git a/test/util/utiltest.rb b/test/util/utiltest.rb
index 419d9820e..405ddbb48 100755
--- a/test/util/utiltest.rb
+++ b/test/util/utiltest.rb
@@ -84,115 +84,6 @@ class TestPuppetUtil < Test::Unit::TestCase
end
end
- unless Puppet::Util::SUIDManager.uid == 0
- $stderr.puts "Run as root to perform Utility tests"
- def test_nothing
- end
- else
-
- def mknverify(file, user, group = nil, id = false)
- if File.exists?(file)
- File.unlink(file)
- end
- args = []
- unless user or group
- args << nil
- end
- if user
- if id
- args << user.uid
- else
- args << user.name
- end
- end
-
- if group
- if id
- args << group.gid
- else
- args << group.name
- end
- end
-
- gid = nil
- if group
- gid = group.gid
- else
- gid = Puppet::Util::SUIDManager.gid
- end
-
- uid = nil
- if user
- uid = user.uid
- else
- uid = Puppet::Util::SUIDManager.uid
- end
-
- assert_nothing_raised {
- Puppet::Util::SUIDManager.asuser(*args) {
- assert_equal(Puppet::Util::SUIDManager.euid, uid, "UID is %s instead of %s" %
- [Puppet::Util::SUIDManager.euid, uid]
- )
- assert_equal(Puppet::Util::SUIDManager.egid, gid, "GID is %s instead of %s" %
- [Puppet::Util::SUIDManager.egid, gid]
- )
- system("touch %s" % file)
- }
- }
- if uid == 0
- #Puppet.warning "Not testing user"
- else
- #Puppet.warning "Testing user %s" % uid
- assert(File.exists?(file), "File does not exist")
- assert_equal(File.stat(file).uid, uid,
- "File is owned by %s instead of %s" %
- [File.stat(file).uid, uid]
- )
- #system("ls -l %s" % file)
- end
- # I'm skipping these, because it seems so system dependent.
- #if gid == 0
- # #Puppet.warning "Not testing group"
- #else
- # Puppet.warning "Testing group %s" % gid.inspect
- # system("ls -l %s" % file)
- # assert_equal(gid, File.stat(file).gid,
- # "File group is %s instead of %s" %
- # [File.stat(file).gid, gid]
- # )
- #end
- assert_nothing_raised {
- File.unlink(file)
- }
- end
-
- def test_asuser
- file = File.join(tmpdir, "asusertest")
- @@tmpfiles << file
- [
- [nil], # Nothing
- [nonrootuser()], # just user, by name
- [nonrootuser(), nil, true], # user, by uid
- [nonrootuser(), nonrootgroup()], # user and group, by name
- [nonrootuser(), nonrootgroup(), true], # user and group, by id
- ].each { |ary|
- mknverify(file, *ary)
- }
- end
-
- # Verify that we get reset back to the right user
- def test_asuser_recovery
- begin
- Puppet::Util.asuser(nonrootuser()) {
- raise "an error"
- }
- rescue
- end
-
- assert(Puppet::Util::SUIDManager.euid == 0, "UID did not get reset")
- end
- end
-
def test_proxy
klass = Class.new do
attr_accessor :hash