diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-18 17:48:10 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-05-18 17:48:10 +0000 |
commit | 93771b7935e544630c3416fda928a3820c615df2 (patch) | |
tree | 0be17fe9135646fc6f64c8c635342bc87ae8f714 | |
parent | 738698c34bf20ae534c37e7304033344fefa4bdf (diff) | |
download | puppet-93771b7935e544630c3416fda928a3820c615df2.tar.gz puppet-93771b7935e544630c3416fda928a3820c615df2.tar.xz puppet-93771b7935e544630c3416fda928a3820c615df2.zip |
fixing user[:groups] management when the user is absent
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1211 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | conf/redhat/puppet.spec | 2 | ||||
-rwxr-xr-x | lib/puppet/type/user.rb | 19 | ||||
-rwxr-xr-x | test/types/user.rb | 19 |
3 files changed, 24 insertions, 16 deletions
diff --git a/conf/redhat/puppet.spec b/conf/redhat/puppet.spec index a085100c4..cab21b251 100644 --- a/conf/redhat/puppet.spec +++ b/conf/redhat/puppet.spec @@ -4,7 +4,7 @@ Summary: A network tool for managing many disparate systems Name: puppet -Version: 0.17.0 +Version: 0.17.1 Release: 1%{?dist} License: GPL Group: System Environment/Base diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index d1d2a6896..81f82f27d 100755 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -246,7 +246,12 @@ module Puppet if @parent[:membership] == :inclusive @should.sort.join(",") else - (@is + @should).uniq.sort.join(",") + members = @should + if @is.is_a?(Array) + members += @is + end + members.uniq.sort.join(",") + #(@is + @should).uniq.sort.join(",") end end @@ -261,6 +266,9 @@ module Puppet unless defined? @is and @is return false end + unless @is.class == @should.class + return false + end return @is.sort == @should.sort end @@ -272,16 +280,9 @@ module Puppet def sync if respond_to? :setgrouplist - groups = nil - if @parent[:membership] == :inclusive - groups = @should - else - groups = (@is + @should).uniq - end - # Pass them the group list, so that the :membership logic # is all in this class, not in parent classes. - setgrouplist(groups) + setgrouplist(self.should) return :user_modified else super diff --git a/test/types/user.rb b/test/types/user.rb index 7bcccc95d..2e0c887dd 100755 --- a/test/types/user.rb +++ b/test/types/user.rb @@ -340,15 +340,22 @@ class TestUser < Test::Unit::TestCase user.retrieve } - assert(user.state(:groups).is, "Did not retrieve group list") + # Some tests to verify that groups work correctly startig from nothing + # Remove our user + user[:ensure] = :absent + assert_apply(user) - assert(!user.insync?, "User is incorrectly in sync") + assert_nothing_raised do + user.retrieve + end - assert_events([:user_modified], user) + # And add it again + user[:ensure] = :present + assert_apply(user) - assert_nothing_raised { - user.retrieve - } + user.retrieve + + assert(user.state(:groups).is, "Did not retrieve group list") list = user.state(:groups).is assert_equal(extra.sort, list.sort, "Group list is not equal") |