diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-15 21:04:14 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-15 21:04:14 +0000 |
| commit | 6fe01cedeb2fe00df62bf63d7f7375d18d0663ca (patch) | |
| tree | a138de582c15714b724851c3ffc0fce5448fbedd /test/puppet | |
| parent | 8602932432c62630ec47a672fb79d6aa90dcbfc7 (diff) | |
| download | puppet-6fe01cedeb2fe00df62bf63d7f7375d18d0663ca.tar.gz puppet-6fe01cedeb2fe00df62bf63d7f7375d18d0663ca.tar.xz puppet-6fe01cedeb2fe00df62bf63d7f7375d18d0663ca.zip | |
Tracked down a few other bugs; everything now passes on debian in preparation for 0.13.2
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@914 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/puppet')
| -rwxr-xr-x | test/puppet/utiltest.rb | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/test/puppet/utiltest.rb b/test/puppet/utiltest.rb index 5ca2e4343..ec398d8b9 100755 --- a/test/puppet/utiltest.rb +++ b/test/puppet/utiltest.rb @@ -43,6 +43,106 @@ class TestPuppetUtil < Test::Unit::TestCase threads.each { |th| th.join } end + # First verify we can convert a known user + def test_gidbyname + %x{groups}.split(" ").each { |group| + gid = nil + assert_nothing_raised { + gid = Puppet::Util.gid(group) + } + + assert(gid, "Could not retrieve gid for %s" % group) + + assert(Puppet.type(:group)[group], "Util did not create %s" % group) + } + end + + # Then verify we can retrieve a known group by gid + def test_gidbyid + %x{groups}.split(" ").each { |group| + obj = Puppet.type(:group).create( + :name => group, + :check => [:gid] + ) + obj.retrieve + id = obj.is(:gid) + gid = nil + assert_nothing_raised { + gid = Puppet::Util.gid(id) + } + + assert(gid, "Could not retrieve gid for %s" % group) + assert_equal(id, gid, "Got mismatched ids") + } + end + + # Finally, verify that we can find groups by id even if we don't + # know them + def test_gidbyunknownid + gid = nil + group = Process.gid + assert_nothing_raised { + gid = Puppet::Util.gid(group) + } + + assert(gid, "Could not retrieve gid for %s" % group) + assert_equal(group, gid, "Got mismatched ids") + end + + def user + require 'etc' + unless defined? @user + obj = Etc.getpwuid(Process.uid) + @user = obj.name + end + return @user + end + + # And do it all over again for users + # First verify we can convert a known user + def test_uidbyname + user = user() + uid = nil + assert_nothing_raised { + uid = Puppet::Util.uid(user) + } + + assert(uid, "Could not retrieve uid for %s" % user) + assert_equal(Process.uid, uid, "UIDs did not match") + assert(Puppet.type(:user)[user], "Util did not create %s" % user) + end + + # Then verify we can retrieve a known user by uid + def test_uidbyid + user = user() + obj = Puppet.type(:user).create( + :name => user, + :check => [:uid] + ) + obj.retrieve + id = obj.is(:uid) + uid = nil + assert_nothing_raised { + uid = Puppet::Util.uid(id) + } + + assert(uid, "Could not retrieve uid for %s" % user) + assert_equal(id, uid, "Got mismatched ids") + end + + # Finally, verify that we can find users by id even if we don't + # know them + def test_uidbyunknownid + uid = nil + user = Process.uid + assert_nothing_raised { + uid = Puppet::Util.uid(user) + } + + assert(uid, "Could not retrieve uid for %s" % user) + assert_equal(user, uid, "Got mismatched ids") + end + unless Process.uid == 0 $stderr.puts "Run as root to perform Utility tests" def test_nothing |
