summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorPhil Dibowitz <phil@ipom.com>2014-08-05 13:04:58 -0700
committerPhil Dibowitz <phil@ipom.com>2014-08-05 13:04:58 -0700
commite21909ae01533883e27c87b15783c3549fed0d9b (patch)
treefb041def84ee2f487bf28031c6ca49f5487f0f25 /spec/unit
parent36506ea5b5e2d849aa3e602ca98b6f2e72d47f4f (diff)
parentfa33c10522b7ad8719e275e6f0be981c7ada348e (diff)
downloadchef-e21909ae01533883e27c87b15783c3549fed0d9b.tar.gz
Merge pull request #1747 from jaymzh/macosx_groups_11
Fix OSX Group provider to be properly idempotent
Diffstat (limited to 'spec/unit')
-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