diff options
author | Nimesh <nimesh.patni@msystechnologies.com> | 2018-11-13 01:07:34 +0530 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2019-01-16 10:33:18 -0800 |
commit | fec16ccf380af3ee514a04fd95e27226fc7cf011 (patch) | |
tree | 51d60f074308c10fd3ef859749cbef53e15db979 /spec/functional | |
parent | a24649f8d3cf0108b6acccde76953d8d145afa04 (diff) | |
download | chef-fec16ccf380af3ee514a04fd95e27226fc7cf011.tar.gz |
windows_task resource: allow non-system users without password for interactive taskstasks
- 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.rb | 58 |
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 |