summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSalim Alam <salam@chef.io>2016-04-11 11:07:58 -0700
committerSalim Alam <salam@chef.io>2016-04-11 11:07:58 -0700
commit53b769dc1fc29c1620a367411bebcf175fa29284 (patch)
treed9f632cc5ed2030467366e3d61be8aa889b79002 /spec
parente8bf4a11d3cd85d3b4dba82623cd2e7aad1053a8 (diff)
parent42a7bd45202848b19f25e90a4131b967cbf4f675 (diff)
downloadchef-53b769dc1fc29c1620a367411bebcf175fa29284.tar.gz
Merge pull request #4812 from chef/salam/group-fix
Removing non-existent members from group should not fail
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/resource/group_spec.rb8
-rw-r--r--spec/unit/provider/group/windows_spec.rb10
2 files changed, 13 insertions, 5 deletions
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index 521c8e887d..f7c232b588 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -267,14 +267,14 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte
end
describe "when removing members" do
- it "raises an error for a non well-formed domain name" do
+ it "does not raise an error for a non well-formed domain name" do
group_resource.excluded_members [invalid_domain_user_name]
- expect { group_resource.run_action(tested_action) }.to raise_error Chef::Exceptions::Win32APIError
+ expect { group_resource.run_action(tested_action) }.to_not raise_error Chef::Exceptions::Win32APIError
end
- it "raises an error for a nonexistent domain" do
+ it "does not raise an error for a nonexistent domain" do
group_resource.excluded_members [nonexistent_domain_user_name]
- expect { group_resource.run_action(tested_action) }.to raise_error Chef::Exceptions::Win32APIError
+ expect { group_resource.run_action(tested_action) }.to_not raise_error Chef::Exceptions::Win32APIError
end
end
end
diff --git a/spec/unit/provider/group/windows_spec.rb b/spec/unit/provider/group/windows_spec.rb
index c424e35e0e..f059f2e717 100644
--- a/spec/unit/provider/group/windows_spec.rb
+++ b/spec/unit/provider/group/windows_spec.rb
@@ -51,11 +51,13 @@ describe Chef::Provider::Group::Windows do
@new_resource.members([ "us" ])
@current_resource = Chef::Resource::Group.new("staff")
@current_resource.members %w{all your base}
+ @new_resource.excluded_members %w{all}
allow(Chef::Util::Windows::NetGroup).to receive(:new).and_return(@net_group)
allow(@net_group).to receive(:local_add_members)
allow(@net_group).to receive(:local_set_members)
- allow(@provider).to receive(:local_group_name_to_sid)
+ allow(@provider).to receive(:lookup_account_name)
+ allow(@provider).to receive(:validate_member!).and_return(true)
@provider.current_resource = @current_resource
end
@@ -71,6 +73,12 @@ describe Chef::Provider::Group::Windows do
@provider.manage_group
end
+ it "should call @net_group.local_delete_members" do
+ allow(@new_resource).to receive(:append).and_return(true)
+ allow(@provider).to receive(:lookup_account_name).with("all").and_return("all")
+ expect(@net_group).to receive(:local_delete_members).with(@new_resource.excluded_members)
+ @provider.manage_group
+ end
end
describe "remove_group" do