Fixed #1360 -- allowdupe works with groups again.

I've added a couple of tests for this bit of the user
and group useradd/groupadd providers, but I haven't migrated
the rest of the tests.
This commit is contained in:
Luke Kanies 2008-06-16 22:42:12 -05:00
Родитель 7b569fb6e1
Коммит 24ca81fcdc
7 изменённых файлов: 69 добавлений и 9 удалений

Просмотреть файл

@ -1,4 +1,6 @@
0.24.?
Fixed #1360 - allowdupe works on groups again.
Fixed #1369 - the init service provider now supports HP-UX.
Removed support for the 'node_name' setting in LDAP and external node

Просмотреть файл

@ -17,7 +17,7 @@ Puppet::Type.type(:group).provide :groupadd, :parent => Puppet::Provider::NameSe
cmd << flag(:gid) << gid
end
end
if @resource[:allowdupe] == :true
if @resource.allowdupe?
cmd << "-o"
end
cmd << @resource[:name]

Просмотреть файл

@ -323,8 +323,7 @@ class Puppet::Provider::NameService < Puppet::Provider
begin
execute(cmd)
rescue Puppet::ExecutionFailure => detail
raise Puppet::Error, "Could not set %s on %s[%s]: %s" %
[param, @resource.class.name, @resource.name, detail]
raise Puppet::Error, "Could not set %s on %s[%s]: %s" % [param, @resource.class.name, @resource.name, detail]
end
end
end

Просмотреть файл

@ -22,10 +22,8 @@ class ObjectAdd < Puppet::Provider::NameService
end
def modifycmd(param, value)
cmd = [command(:modify),
flag(param),
value]
if @resource[:allowdupe] == :true && param == :uid
cmd = [command(:modify), flag(param), value]
if @resource.allowdupe? && ((param == :uid and self.class.name == :useradd) || (param == :gid and self.class.name == :groupadd))
cmd << "-o"
end
cmd << @resource[:name]
@ -41,4 +39,3 @@ class ObjectAdd < Puppet::Provider::NameService
end
end
end

Просмотреть файл

@ -25,7 +25,7 @@ Puppet::Type.type(:user).provide :useradd, :parent => Puppet::Provider::NameServ
def addcmd
cmd = [command(:add)]
@resource.class.validproperties.each do |property|
Puppet::Type.type(:user).validproperties.each do |property|
next if property == :ensure
# the value needs to be quoted, mostly because -c might
# have spaces in it

Просмотреть файл

@ -0,0 +1,31 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../../spec_helper'
provider_class = Puppet::Type.type(:group).provider(:groupadd)
describe provider_class do
before do
@resource = stub("resource", :name => "mygroup")
@provider = provider_class.new(@resource)
end
# #1360
it "should add -o when allowdupe is enabled and the group is being created" do
@resource.stubs(:should).returns "fakeval"
@resource.stubs(:[]).returns "fakeval"
@resource.expects(:allowdupe?).returns true
@provider.expects(:execute).with { |args| args.include?("-o") }
@provider.create
end
it "should add -o when allowdupe is enabled and the gid is being modified" do
@resource.stubs(:should).returns "fakeval"
@resource.stubs(:[]).returns "fakeval"
@resource.expects(:allowdupe?).returns true
@provider.expects(:execute).with { |args| args.include?("-o") }
@provider.gid = 150
end
end

Просмотреть файл

@ -0,0 +1,31 @@
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../../spec_helper'
provider_class = Puppet::Type.type(:user).provider(:useradd)
describe provider_class do
before do
@resource = stub("resource", :name => "myuser", :managehome? => nil)
@provider = provider_class.new(@resource)
end
# #1360
it "should add -o when allowdupe is enabled and the user is being created" do
@resource.stubs(:should).returns "fakeval"
@resource.stubs(:[]).returns "fakeval"
@resource.expects(:allowdupe?).returns true
@provider.expects(:execute).with { |args| args.include?("-o") }
@provider.create
end
it "should add -o when allowdupe is enabled and the uid is being modified" do
@resource.stubs(:should).returns "fakeval"
@resource.stubs(:[]).returns "fakeval"
@resource.expects(:allowdupe?).returns true
@provider.expects(:execute).with { |args| args.include?("-o") }
@provider.uid = 150
end
end