summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-09-11 11:28:23 -0700
committerTim Smith <tsmith84@gmail.com>2020-09-11 17:15:46 -0700
commit3643b3254966efd9821fe398a4289f4c52592215 (patch)
treef0e9b8558d009022da7a47afae7cc15f024709dc
parent405778e51c3ffde480b6d2e94ec56b7dde9232c5 (diff)
downloadchef-3643b3254966efd9821fe398a4289f4c52592215.tar.gz
Allow users to take a String as well
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/windows_user_privilege.rb7
-rw-r--r--spec/unit/resource/windows_user_privilege_spec.rb9
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/chef/resource/windows_user_privilege.rb b/lib/chef/resource/windows_user_privilege.rb
index 2814896fc3..639e27e987 100644
--- a/lib/chef/resource/windows_user_privilege.rb
+++ b/lib/chef/resource/windows_user_privilege.rb
@@ -129,13 +129,14 @@ class Chef
description: "An optional property to add the user to the given privilege. Use only with add and remove action.",
name_property: true
- property :users, Array,
- description: "An optional property to set the privilege for given users. Use only with set action."
+ property :users, [Array, String],
+ description: "An optional property to set the privilege for given users. Use only with set action.",
+ coerce: proc { |v| Array(v) }
property :privilege, [Array, String],
description: "One or more privileges to set for users.",
required: true,
- coerce: proc { |v| Array[v] },
+ coerce: proc { |v| Array(v) },
callbacks: {
"Option privilege must include any of the: #{PRIVILEGE_OPTS}" => lambda { |n| (n - PRIVILEGE_OPTS).empty? },
}
diff --git a/spec/unit/resource/windows_user_privilege_spec.rb b/spec/unit/resource/windows_user_privilege_spec.rb
index 96f9eb93fe..73c800c8bd 100644
--- a/spec/unit/resource/windows_user_privilege_spec.rb
+++ b/spec/unit/resource/windows_user_privilege_spec.rb
@@ -28,12 +28,17 @@ describe Chef::Resource::WindowsUserPrivilege do
expect(resource.principal).to eql("fakey_fakerton")
end
- it "the principal privilege property coerces to an array" do
+ it "the users property coerces to an array" do
+ resource.users "Administrator"
+ expect(resource.users).to eql(["Administrator"])
+ end
+
+ it "the privilege property coerces to an array" do
resource.privilege "SeDenyRemoteInteractiveLogonRight"
expect(resource.privilege).to eql(["SeDenyRemoteInteractiveLogonRight"])
end
- it "the principal privilege validates inputs against the allowed list of privs" do
+ it "the privilege property validates inputs against the allowed list of privs" do
expect { resource.privilege "invalidPriv" }.to raise_error(Chef::Exceptions::ValidationFailed)
end