diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-09-11 11:26:35 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-09-11 17:15:46 -0700 |
commit | 405778e51c3ffde480b6d2e94ec56b7dde9232c5 (patch) | |
tree | c3df03226b73115db5e30920e2bc343f297d447f /lib | |
parent | c0c510a465cb22cace9e37595945e50b6e79fba3 (diff) | |
download | chef-405778e51c3ffde480b6d2e94ec56b7dde9232c5.tar.gz |
Simplify validation and add some unit tests
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource/windows_user_privilege.rb | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/lib/chef/resource/windows_user_privilege.rb b/lib/chef/resource/windows_user_privilege.rb index bfdab8cdf9..2814896fc3 100644 --- a/lib/chef/resource/windows_user_privilege.rb +++ b/lib/chef/resource/windows_user_privilege.rb @@ -133,23 +133,11 @@ class Chef description: "An optional property to set the privilege for given users. Use only with set action." property :privilege, [Array, String], - description: "Privilege to set for users.", + description: "One or more privileges to set for users.", required: true, - coerce: proc { |v| v.is_a?(String) ? Array[v] : v }, + coerce: proc { |v| Array[v] }, callbacks: { - "Option privilege must include any of the: #{PRIVILEGE_OPTS}" => lambda { |n| - if n.is_a?(String) - these_options = Array[n] - else - these_options = n - end - - if (these_options - PRIVILEGE_OPTS).empty? - true - else - false - end - }, + "Option privilege must include any of the: #{PRIVILEGE_OPTS}" => lambda { |n| (n - PRIVILEGE_OPTS).empty? }, } load_current_value do |new_resource| |