summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPhil Dibowitz <phil@ipom.com>2014-08-05 13:04:58 -0700
committerClaire McQuin <claire@getchef.com>2014-08-07 09:53:01 -0700
commit2a4f1d1df70294939ccbc08388cee01c56f0aa57 (patch)
tree21cd1d2492886022bb6d52c68492782b4a26a08e /spec
parent1b33710ff6c58d1f734d760620400a7613dbccfd (diff)
downloadchef-2a4f1d1df70294939ccbc08388cee01c56f0aa57.tar.gz
Merge pull request #1747 from jaymzh/macosx_groups_11
Fix OSX Group provider to be properly idempotent Conflicts: CHANGELOG.md RELEASE_NOTES.md
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/group/dscl_spec.rb39
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