diff options
author | Phil Dibowitz <phil@ipom.com> | 2014-08-04 11:45:40 -0700 |
---|---|---|
committer | Phil Dibowitz <phil@ipom.com> | 2014-08-04 15:38:31 -0700 |
commit | fa33c10522b7ad8719e275e6f0be981c7ada348e (patch) | |
tree | a4faa39dbc4715d4d0799a39fd8c56850aed69f7 /spec | |
parent | 1dc4da1720c8bdbd8f44429c6d7861d484dcd631 (diff) | |
download | chef-fa33c10522b7ad8719e275e6f0be981c7ada348e.tar.gz |
Fix OSX Group provider to be properly idempotent
Currently the OSX Group provider use the 'Etc' module to determine
what exists, and the 'dscl' command to change things. Etc will look
to /etc/group by default and fallback to 'dscl', which causes idempotency
incorrectness. This change the Group provider to simply look at 'dscl' always.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/provider/group/dscl_spec.rb | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb index 5a02ee8dfb..8848a01bf2 100644 --- a/spec/unit/provider/group/dscl_spec.rb +++ b/spec/unit/provider/group/dscl_spec.rb @@ -240,6 +240,7 @@ describe Chef::Provider::Group::Dscl do @provider.load_current_resource @provider.define_resource_requirements end + it "raises an error if the required binary /usr/bin/dscl doesn't exist" do File.should_receive(:exists?).with("/usr/bin/dscl").and_return(false) @@ -251,7 +252,7 @@ describe Chef::Provider::Group::Dscl do lambda { @provider.process_resource_requirements }.should_not raise_error end end - + describe "when creating the group" do it "creates the group, password field, gid, and sets group membership" do @provider.should_receive(:set_gid).and_return(true) @@ -294,3 +295,39 @@ describe Chef::Provider::Group::Dscl do end end end + +describe 'Test DSCL loading' do + before do + @node = Chef::Node.new + @events = Chef::EventDispatch::Dispatcher.new + @run_context = Chef::RunContext.new(@node, {}, @events) + @new_resource = Chef::Resource::Group.new("aj") + @provider = Chef::Provider::Group::Dscl.new(@new_resource, @run_context) + @output = <<-EOF +AppleMetaNodeLocation: /Local/Default +Comment: + Test Group +GeneratedUID: AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA +NestedGroups: AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAB +Password: * +PrimaryGroupID: 999 +RealName: + TestGroup +RecordName: com.apple.aj +RecordType: dsRecTypeStandard:Groups +GroupMembership: waka bar +EOF + @provider.stub(:safe_dscl).with("read /Groups/aj").and_return(@output) + @current_resource = @provider.load_current_resource + + end + + it 'should parse gid properly' do + File.stub(:exists?).and_return(true) + @current_resource.gid.should eq("999") + end + it 'should parse members properly' do + File.stub(:exists?).and_return(true) + @current_resource.members.should eq(['waka', 'bar']) + end +end |