summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-15 18:23:33 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-15 18:23:33 +0000
commitd1cd443e9644f945f5c55b592a2414dbaef2de5f (patch)
tree6723dc75eea5a4e19f6bfe0362db49bd8f41c651 /test
parent4df3468e920126a3d7b0ac22ab095cc5dbb785bd (diff)
Fixing users so that they can use a group created by Puppet, and they also now autorequire that group. To do so, I modified Puppet::Util.gid, which required that I fix Puppet::Type#merge to support merging managed and umanaged objects, which required fixing a bug in Puppet::Type#managed?, and I also changed the ensure state to only default to a value, when the object is managed, which required that I change the defaults system to support default procs that do not return a value. In other words, lots of fixes for a smallish problem, but we are much better off now.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@912 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/types/type.rb33
-rwxr-xr-xtest/types/user.rb23
2 files changed, 54 insertions, 2 deletions
diff --git a/test/types/type.rb b/test/types/type.rb
index e7808228a..abb3178c6 100644
--- a/test/types/type.rb
+++ b/test/types/type.rb
@@ -209,7 +209,38 @@ class TestType < Test::Unit::TestCase
assert_apply(file)
assert(Puppet.type(:file)[name], "Could not look up object by name")
- #assert(Puppet.type(:file)[path], "Could not look up object by path")
+ end
+
+ def test_ensuredefault
+ user = nil
+ assert_nothing_raised {
+ user = Puppet.type(:user).create(
+ :name => "pptestAA",
+ :check => [:uid]
+ )
+ }
+
+ # make sure we don't get :ensure for unmanaged files
+ assert(! user.state(:ensure), "User got an ensure state")
+
+ assert_nothing_raised {
+ user = Puppet.type(:user).create(
+ :name => "pptestAA",
+ :comment => "Testingness"
+ )
+ }
+ # but make sure it gets added once we manage them
+ assert(user.state(:ensure), "User did not add ensure state")
+
+ assert_nothing_raised {
+ user = Puppet.type(:user).create(
+ :name => "pptestBB",
+ :comment => "A fake user"
+ )
+ }
+
+ # and make sure managed objects start with them
+ assert(user.state(:ensure), "User did not get an ensure state")
end
end
diff --git a/test/types/user.rb b/test/types/user.rb
index a822747d1..6a7767054 100755
--- a/test/types/user.rb
+++ b/test/types/user.rb
@@ -250,7 +250,6 @@ class TestUser < Test::Unit::TestCase
newuid = old
while true
- Puppet.warning newuid.inspect
newuid += 1
if newuid - old > 1000
@@ -367,6 +366,28 @@ class TestUser < Test::Unit::TestCase
end
}
end
+
+ def test_autorequire
+ file = tempfile()
+ user = Puppet.type(:user).create(
+ :name => "pptestu",
+ :home => file,
+ :gid => "pptestg"
+ )
+ home = Puppet.type(:file).create(
+ :path => file,
+ :ensure => "directory"
+ )
+ group = Puppet.type(:group).create(
+ :name => "pptestg"
+ )
+ Puppet::Type.finalize
+ comp = newcomp(user, group)
+ comp.retrieve
+
+ assert(user.requires?(group), "User did not require group")
+ assert(user.requires?(home), "User did not require home dir")
+ end
else
$stderr.puts "Not root; skipping user creation/modification tests"
end