summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-11-24 12:17:52 -0600
committerLuke Kanies <luke@madstop.com>2008-11-24 12:17:52 -0600
commitb415848841edac9b08ff604416ad2e24dd350b4d (patch)
tree85d4a612720cbacc2efd4aad1db27afea22b4efe
parent9ed382d397c79995e850a91ac92e22106d670bed (diff)
downloadpuppet-b415848841edac9b08ff604416ad2e24dd350b4d.tar.gz
puppet-b415848841edac9b08ff604416ad2e24dd350b4d.tar.xz
puppet-b415848841edac9b08ff604416ad2e24dd350b4d.zip
Fixing #1708 - user groups specified as names are now detected correctly.
There was a bug when groups were specified by name -- the group was always compared to the current gid, rather than being converted to an integer and comparing that way. This is now fixed. Signed-off-by: Luke Kanies <luke@madstop.com>
-rwxr-xr-xlib/puppet/type/user.rb10
-rwxr-xr-xspec/unit/type/user.rb20
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb
index 637fe9b46..0fe7928e6 100755
--- a/lib/puppet/type/user.rb
+++ b/lib/puppet/type/user.rb
@@ -98,6 +98,16 @@ module Puppet
end
end
+ def insync?(is)
+ # We know the 'is' is a number, so we need to convert the 'should' to a number,
+ # too.
+ @should.each do |value|
+ return true if number = Puppet::Util.gid(value) and is == number
+ end
+
+ return false
+ end
+
def sync
found = false
@should.each do |value|
diff --git a/spec/unit/type/user.rb b/spec/unit/type/user.rb
index 41b10da81..19690eee1 100755
--- a/spec/unit/type/user.rb
+++ b/spec/unit/type/user.rb
@@ -161,6 +161,26 @@ describe user do
gid.should.must == "foo"
end
+ describe "when testing whether in sync" do
+ before do
+ @gid = user.attrclass(:gid).new(:resource => @resource, :should => %w{foo bar})
+ end
+
+ it "should return true if any of the specified groups are equal to the current integer" do
+ Puppet::Util.expects(:gid).with("foo").returns 300
+ Puppet::Util.expects(:gid).with("bar").returns 500
+
+ @gid.must be_insync(500)
+ end
+
+ it "should return false if none of the specified groups are equal to the current integer" do
+ Puppet::Util.expects(:gid).with("foo").returns 300
+ Puppet::Util.expects(:gid).with("bar").returns 500
+
+ @gid.should_not be_insync(700)
+ end
+ end
+
describe "when syncing" do
before do
@gid = user.attrclass(:gid).new(:resource => @resource, :should => %w{foo bar})