summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-07-23 09:19:59 -0700
committerGitHub <noreply@github.com>2018-07-23 09:19:59 -0700
commit6b66a43ff779f95b73543a5b9a68b950408083b6 (patch)
treee5817d2898fd95a68ecd36953aa53f488f2b9ff2 /spec
parent83fef3b411ba66134287d1cbd6a56df2179d3512 (diff)
parent4b5f73868ea131780ac29c3b8d6dfb7506b02afa (diff)
downloadchef-6b66a43ff779f95b73543a5b9a68b950408083b6.tar.gz
Merge pull request #7497 from MsysTechnologiesllc/nimesh/MSYS-855_fixing_windows_task_quotes
Handling Quotes in Windows Task Commands and Arguments
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/resource/windows_task_spec.rb32
1 files changed, 24 insertions, 8 deletions
diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb
index 05f46d20ce..a4cee114f4 100644
--- a/spec/functional/resource/windows_task_spec.rb
+++ b/spec/functional/resource/windows_task_spec.rb
@@ -61,14 +61,14 @@ describe Chef::Resource::WindowsTask, :windows_only do
expect(subject).not_to be_updated_by_last_action
end
- it "creates scheduled task and sets command arguments" do
+ it "creates scheduled task and sets command arguments when arguments inclusive single quotes" do
subject.command "chef-client -W -L 'C:\\chef\\chef-ad-join.log'"
call_for_create_action
# loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
expect(current_resource.task.application_name).to eq("chef-client")
- expect(current_resource.task.parameters).to eq("-W -L C:\\\\chef\\\\chef-ad-join.log")
+ expect(current_resource.task.parameters).to eq("-W -L 'C:\\chef\\chef-ad-join.log'")
end
it "does not converge the resource if it is already converged" do
@@ -79,20 +79,36 @@ describe Chef::Resource::WindowsTask, :windows_only do
expect(subject).not_to be_updated_by_last_action
end
- it "creates scheduled task and sets command arguments" do
- subject.command '"C:\\Program Files\\example\program.exe" -arg1 --arg2'
+ it "creates scheduled task and sets command arguments with spaces in command" do
+ subject.command '"C:\\Program Files\\example\\program.exe" -arg1 --arg2'
call_for_create_action
- # loading current resource again to check new task is creted and it matches task parameters
current_resource = call_for_load_current_resource
expect(current_resource.exists).to eq(true)
- expect(current_resource.task.application_name).to eq("C:\\Program Files\\example\\program.exe")
+ expect(current_resource.task.application_name).to eq('"C:\\Program Files\\example\\program.exe"')
expect(current_resource.task.parameters).to eq("-arg1 --arg2")
end
it "does not converge the resource if it is already converged" do
- subject.command '"C:\\Program Files\\example\program.exe" -arg1 --arg2'
+ subject.command '"C:\\Program Files\\example\\program.exe" -arg1 --arg2'
+ subject.run_action(:create)
+ subject.command '"C:\\Program Files\\example\\program.exe" -arg1 --arg2'
+ subject.run_action(:create)
+ expect(subject).not_to be_updated_by_last_action
+ end
+
+ it "creates scheduled task and sets command arguments with spaces in arguments" do
+ subject.command 'powershell.exe -file "C:\\Program Files\\app\\script.ps1"'
+ call_for_create_action
+ current_resource = call_for_load_current_resource
+ expect(current_resource.exists).to eq(true)
+ expect(current_resource.task.application_name).to eq("powershell.exe")
+ expect(current_resource.task.parameters).to eq('-file "C:\\Program Files\\app\\script.ps1"')
+ end
+
+ it "does not converge the resource if it is already converged" do
+ subject.command 'powershell.exe -file "C:\\Program Files\\app\\script.ps1"'
subject.run_action(:create)
- subject.command '"C:\\Program Files\\example\program.exe" -arg1 --arg2'
+ subject.command 'powershell.exe -file "C:\\Program Files\\app\\script.ps1"'
subject.run_action(:create)
expect(subject).not_to be_updated_by_last_action
end