diff options
author | Rein Henrichs <reinh@reinh.com> | 2010-03-23 15:34:11 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2010-03-26 12:16:45 +1100 |
commit | eeb3d7477932e03a0c97f0fb0eda29926c14c801 (patch) | |
tree | c04b286e3c07944115c71c279150a31b6f6b7528 | |
parent | 9ea27dba2a52286da90574cc0367f20371fb9aeb (diff) | |
download | puppet-eeb3d7477932e03a0c97f0fb0eda29926c14c801.tar.gz puppet-eeb3d7477932e03a0c97f0fb0eda29926c14c801.tar.xz puppet-eeb3d7477932e03a0c97f0fb0eda29926c14c801.zip |
Mock user in SUIDManager tests
-rwxr-xr-x | test/puppet/tc_suidmanager.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/puppet/tc_suidmanager.rb b/test/puppet/tc_suidmanager.rb index 2e4a13c72..2075427f8 100755 --- a/test/puppet/tc_suidmanager.rb +++ b/test/puppet/tc_suidmanager.rb @@ -11,7 +11,10 @@ class TestSUIDManager < Test::Unit::TestCase include PuppetTest def setup - @user = nonrootuser + the_id = 42 + Puppet::Util::SUIDManager.stubs(:convert_xid).returns(the_id) + Puppet::Util::SUIDManager.stubs(:initgroups) + @user = stub('user', :uid => the_id, :gid => the_id, :name => 'name') super end @@ -39,13 +42,14 @@ class TestSUIDManager < Test::Unit::TestCase end def test_utiluid - assert_not_equal(nil, Puppet::Util.uid(@user.name)) + assert_not_equal(nil, Puppet::Util.uid(nonrootuser.name)) end def test_asuser_as_root Process.stubs(:uid).returns(0) expects_id_set_and_revert @user.uid, @user.gid Puppet::Util::SUIDManager.asuser @user.uid, @user.gid do end + rescue Errno::EPERM end def test_asuser_as_nonroot @@ -96,6 +100,7 @@ class TestSUIDManager < Test::Unit::TestCase private def expects_id_set_and_revert(uid, gid) + Process.stubs(:groups=) Process.expects(:euid).returns(99997) Process.expects(:egid).returns(99996) |