diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-09-11 11:28:23 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-09-11 11:28:23 -0700 |
commit | 9b5d5f5172001bce80689635514f713469c142a7 (patch) | |
tree | cbdd67a98ad3a98367d980e5b73584cb47f7ca64 | |
parent | bbc16fe716ff2351fe81a18e4bf7d0ce75c5b555 (diff) | |
download | chef-9b5d5f5172001bce80689635514f713469c142a7.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.rb | 7 | ||||
-rw-r--r-- | spec/unit/resource/windows_user_privilege_spec.rb | 9 |
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 |