summaryrefslogtreecommitdiff
path: root/spec/functional
diff options
context:
space:
mode:
authorNimesh <nimesh.patni@msystechnologies.com>2018-11-13 01:07:34 +0530
committerNimesh-Msys <nimesh.patni@msystechnologies.com>2019-01-07 14:33:58 +0530
commit560d568366f73c9915f64eb0f12f3421245e7cc1 (patch)
tree47c38379b1db6d964d1f2b35ad37e3a9fc741879 /spec/functional
parent45d7d458bf74d3979b0b8ca2172996d6cba9aace (diff)
downloadchef-560d568366f73c9915f64eb0f12f3421245e7cc1.tar.gz
windows_task resource: allow non-system users without password for interactive tasks
- Minor changes in `validate_user_and_password` to support this feature - `validate_interactive_setting` would no longer be needed - Added test cases - Added support to latest version of win32-taskscheduler gem (2.0.4) - Fixes MSYS-924 Signed-off-by: Nimesh <nimesh.patni@msystechnologies.com>
Diffstat (limited to 'spec/functional')
-rw-r--r--spec/functional/resource/windows_task_spec.rb58
1 files changed, 51 insertions, 7 deletions
diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb
index 9b355d37ed..a2e1163a88 100644
--- a/spec/functional/resource/windows_task_spec.rb
+++ b/spec/functional/resource/windows_task_spec.rb
@@ -1599,26 +1599,70 @@ describe Chef::Resource::WindowsTask, :windows_only do
end
context "when start_day is passed with frequency :onstart" do
- it "not raises error" do
+ it "does not raises error" do
subject.frequency :onstart
subject.start_day "09/20/2017"
expect { subject.after_created }.not_to raise_error
end
end
- context "when a non-system user is passed without password" do
+ context "when a non system user is passed without password" do
it "raises error" do
- subject.user "Administrator"
+ subject.user "USER"
subject.frequency :onstart
- expect { subject.after_created }.to raise_error(%q{Cannot specify a user other than the system users without specifying a password!. Valid passwordless users: 'SYSTEM', 'NT AUTHORITY\SYSTEM', 'LOCAL SERVICE', 'NT AUTHORITY\LOCAL SERVICE', 'NETWORK SERVICE', 'NT AUTHORITY\NETWORK SERVICE', 'ADMINISTRATORS', 'BUILTIN\ADMINISTRATORS', 'USERS', 'BUILTIN\USERS', 'GUESTS', 'BUILTIN\GUESTS'})
+ expect { subject.after_created }.to raise_error(%q{Please provide a password or check if this task needs to be interactive! Valid passwordless users are: 'SYSTEM', 'NT AUTHORITY\SYSTEM', 'LOCAL SERVICE', 'NT AUTHORITY\LOCAL SERVICE', 'NETWORK SERVICE', 'NT AUTHORITY\NETWORK SERVICE', 'ADMINISTRATORS', 'BUILTIN\ADMINISTRATORS', 'USERS', 'BUILTIN\USERS', 'GUESTS', 'BUILTIN\GUESTS'})
+ end
+ it "does not raises error when task is interactive" do
+ subject.user "USER"
+ subject.frequency :onstart
+ subject.interactive_enabled true
+ expect { subject.after_created }.not_to raise_error
end
end
- context "when interactive_enabled is passed for a System user without password" do
- it "raises error" do
+ context "when a system user is passed without password" do
+ it "does not raises error" do
+ subject.user "ADMINISTRATORS"
+ subject.frequency :onstart
+ expect { subject.after_created }.not_to raise_error
+ end
+ it "does not raises error when task is interactive" do
+ subject.user "ADMINISTRATORS"
+ subject.frequency :onstart
+ subject.interactive_enabled true
+ expect { subject.after_created }.not_to raise_error
+ end
+ end
+
+ context "when a non system user is passed with password" do
+ it "does not raises error" do
+ subject.user "USER"
+ subject.password "XXXX"
+ subject.frequency :onstart
+ expect { subject.after_created }.not_to raise_error
+ end
+ it "does not raises error when task is interactive" do
+ subject.user "USER"
+ subject.password "XXXX"
+ subject.frequency :onstart
subject.interactive_enabled true
+ expect { subject.after_created }.not_to raise_error
+ end
+ end
+
+ context "when a system user is passed with password" do
+ it "raises error" do
+ subject.user "ADMINISTRATORS"
+ subject.password "XXXX"
subject.frequency :onstart
- expect { subject.after_created }.to raise_error("Please provide the password when attempting to set interactive/non-interactive.")
+ expect { subject.after_created }.to raise_error("Password is not required for system users.")
+ end
+ it "raises error when task is interactive" do
+ subject.user "ADMINISTRATORS"
+ subject.password "XXXX"
+ subject.frequency :onstart
+ subject.interactive_enabled true
+ expect { subject.after_created }.to raise_error("Password is not required for system users.")
end
end