summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-15 17:39:22 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-15 17:39:22 +0000
commit0f78282588d5350f7e0bc04cb5e9d14c3620d65d (patch)
treeb8b9cc020bbb66ce8751b2a1551e4c13d2358995
parentdc96f987824d5ee66e36fed42065088467926a06 (diff)
downloadpuppet-0f78282588d5350f7e0bc04cb5e9d14c3620d65d.tar.gz
puppet-0f78282588d5350f7e0bc04cb5e9d14c3620d65d.tar.xz
puppet-0f78282588d5350f7e0bc04cb5e9d14c3620d65d.zip
Adding unit test for #364. It passes on OS X.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1937 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-xtest/types/file.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/types/file.rb b/test/types/file.rb
index f93d3670b..6c1635dbe 100755
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -1762,6 +1762,45 @@ class TestFile < Test::Unit::TestCase
end
end
end
+
+ if Process.uid == 0
+ # Testing #364.
+ def test_writing_in_directories_with_no_write_access
+ # Make a directory that our user does not have access to
+ dir = tempfile()
+ Dir.mkdir(dir)
+
+ # Get a fake user
+ user = nonrootuser
+ # and group
+ group = nonrootgroup
+
+ # First try putting a file in there
+ path = File.join(dir, "file")
+ file = Puppet::Type.newfile :path => path, :owner => user.name, :group => group.name, :content => "testing"
+
+ # Make sure we can create it
+ assert_apply(file)
+ assert(FileTest.exists?(path), "File did not get created")
+ # And that it's owned correctly
+ assert_equal(user.uid, File.stat(path).uid, "File has the wrong owner")
+ assert_equal(group.gid, File.stat(path).gid, "File has the wrong group")
+
+ assert_equal("testing", File.read(path), "file has the wrong content")
+
+ # Now make a dir
+ subpath = File.join(dir, "subdir")
+ subdir = Puppet::Type.newfile :path => subpath, :owner => user.name, :group => group.name, :ensure => :directory
+ # Make sure we can create it
+ assert_apply(subdir)
+ assert(FileTest.directory?(subpath), "File did not get created")
+ # And that it's owned correctly
+ assert_equal(user.uid, File.stat(subpath).uid, "File has the wrong owner")
+ assert_equal(group.gid, File.stat(subpath).gid, "File has the wrong group")
+
+ assert_equal("testing", File.read(path), "file has the wrong content")
+ end
+ end
end
# $Id$