summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-23 02:22:28 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2005-10-23 02:22:28 +0000
commite8912d51f1818bc59015ba687fbbb8a33fe91ecf (patch)
tree9ebc61afe499dc096042a3efb1551bf16be5d88f /test
parent1b74e8e493abe1951f1e535e752521326a63c6d3 (diff)
downloadpuppet-e8912d51f1818bc59015ba687fbbb8a33fe91ecf.tar.gz
puppet-e8912d51f1818bc59015ba687fbbb8a33fe91ecf.tar.xz
puppet-e8912d51f1818bc59015ba687fbbb8a33fe91ecf.zip
files and directories are now created as the correct user and group if they are set
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@727 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/other/transactions.rb10
-rw-r--r--test/puppettest.rb3
-rw-r--r--test/types/file.rb25
3 files changed, 34 insertions, 4 deletions
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 338bb6844..738337dc4 100644
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -114,8 +114,16 @@ class TestTransactions < Test::Unit::TestCase
component = newcomp("file",file)
+ require 'etc'
+ groupname = Etc.getgrgid(File.stat(file.name).gid).name
assert_nothing_raised() {
- file[:group] = @groups[1]
+ # Find a group that it's not set to
+ group = @groups.find { |group| group != groupname }
+ unless group
+ raise "Could not find suitable group"
+ end
+ file[:group] = group
+
file[:mode] = "755"
}
trans = assert_events(component, [:inode_changed, :inode_changed], "file")
diff --git a/test/puppettest.rb b/test/puppettest.rb
index cfd0b9342..3d483d4de 100644
--- a/test/puppettest.rb
+++ b/test/puppettest.rb
@@ -119,8 +119,9 @@ module TestPuppet
run_events(:rollback, trans, events, msg)
end
- def assert_events(comp, events, msg)
+ def assert_events(comp, events, msg = nil)
trans = nil
+ msg ||= comp.name
assert_nothing_raised("Component %s failed" % [msg]) {
trans = comp.evaluate
}
diff --git a/test/types/file.rb b/test/types/file.rb
index 713dd96c1..54b290fc7 100644
--- a/test/types/file.rb
+++ b/test/types/file.rb
@@ -104,7 +104,7 @@ class TestFile < Test::Unit::TestCase
}
end
- def test_zgroup
+ def test_group
file = mktestfile()
[%x{groups}.chomp.split(/ /), Process.groups].flatten.each { |group|
assert_nothing_raised() {
@@ -116,6 +116,28 @@ class TestFile < Test::Unit::TestCase
end
if Process.uid == 0
+ def test_zcreateasuser
+ dir = tmpdir()
+
+ user = nonrootuser()
+ path = File.join(tmpdir, "createusertesting")
+ @@tmpfiles << path
+
+ file = nil
+ assert_nothing_raised {
+ file = Puppet::Type::PFile.create(
+ :path => path,
+ :owner => user.name,
+ :create => true,
+ :mode => "755"
+ )
+ }
+
+ comp = newcomp("createusertest", file)
+
+ assert_events(comp, [:file_created])
+ end
+
def test_ownerasroot
file = mktestfile()
@@ -460,7 +482,6 @@ class TestFile < Test::Unit::TestCase
def test_filetype_retrieval
file = nil
- Puppet.err tmpdir()
assert_nothing_raised {
file = Puppet::Type::PFile.create(
:name => tmpdir(),