summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2017-12-06 16:41:40 -0800
committerTim Smith <tsmith@chef.io>2017-12-06 20:23:55 -0800
commit3fb0beab9b0acfdda33bfa26b1e99b81d9156542 (patch)
tree2eac5c12df89cd8dec3482a8d8eae06a8cc19849 /lib
parent7346ad83431004c2d4099644484a425221fc6282 (diff)
downloadchef-improved_task_logging.tar.gz
Improve the passwordless user error, logic, and testsimproved_task_logging
Specify exactly what we're checking for in the error. This needs to go into the docs site as well. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/resource/windows_task.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb
index d8e6818c0b..37a818c7fe 100644
--- a/lib/chef/resource/windows_task.rb
+++ b/lib/chef/resource/windows_task.rb
@@ -119,15 +119,14 @@ class Chef
SYSTEM_USERS = ['NT AUTHORITY\SYSTEM', "SYSTEM", 'NT AUTHORITY\LOCALSERVICE', 'NT AUTHORITY\NETWORKSERVICE', 'BUILTIN\USERS', "USERS"].freeze
def validate_user_and_password(user, password)
- if user && use_password?(user)
- if password.nil?
- raise ArgumentError, "Cannot specify a user other than the 'SYSTEM' user without specifying a password!"
- end
+ if password_required?(user) && password.nil?
+ raise ArgumentError, %q{Cannot specify a user other than the system users without specifying a password!. Valid passwordless users: 'NT AUTHORITY\SYSTEM', 'SYSTEM', 'NT AUTHORITY\LOCALSERVICE', 'NT AUTHORITY\NETWORKSERVICE', 'BUILTIN\USERS', 'USERS'}
end
end
- def use_password?(user)
- @use_password ||= !SYSTEM_USERS.include?(user.upcase)
+ def password_required?(user)
+ return false if user.nil?
+ @password_required ||= !SYSTEM_USERS.include?(user.upcase)
end
def validate_interactive_setting(interactive_enabled, password)
@@ -198,7 +197,7 @@ class Chef
end
unless idle_time.to_i > 0 && idle_time.to_i <= 999
- raise "idle_time value #{idle_time} is invalid. Valid values for :on_idle frequency are 1 - 999."
+ raise "idle_time value #{idle_time} is invalid. Valid values for :on_idle frequency are 1 - 999."
end
end