2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/windows_task"
|
2016-11-18 23:32:52 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "Inspec::Resources::WindowsTasks" do
|
2019-06-28 07:14:24 +00:00
|
|
|
it "can handle a Windows task that does not exist" do
|
2019-06-11 22:24:35 +00:00
|
|
|
resource_fail = MockLoader.new(:windows).load_resource("windows_task", "does-not-exist")
|
2016-11-18 23:32:52 +00:00
|
|
|
_(resource_fail.exists?).must_equal false
|
|
|
|
end
|
2019-06-28 07:14:24 +00:00
|
|
|
it "parses a windows task with one trigger correctly" do
|
2019-06-11 22:24:35 +00:00
|
|
|
resource = MockLoader.new(:windows).load_resource("windows_task", "WeLovePizza")
|
2016-11-18 23:32:52 +00:00
|
|
|
_(resource.enabled?).must_equal true
|
|
|
|
_(resource.disabled?).must_equal false
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.logon_mode).must_equal "Interactive/Background"
|
|
|
|
_(resource.last_result).must_equal "1056"
|
2016-11-18 23:32:52 +00:00
|
|
|
_(resource.task_to_run).must_equal '%windir%\\system32\\sc.exe start w32time task_started'
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.run_as_user).must_equal "LOCAL SERVICE"
|
|
|
|
_(resource.type).must_equal "windows-task"
|
2016-11-18 23:32:52 +00:00
|
|
|
_(resource.to_s).must_equal "Windows Task 'WeLovePizza'"
|
|
|
|
end
|
2019-06-28 07:14:24 +00:00
|
|
|
it "parses a windows task with more than one trigger correctly" do
|
|
|
|
resource = MockLoader.new(:windows).load_resource("windows_task", "WeLoveMultiplePizzas")
|
|
|
|
_(resource.enabled?).must_equal true
|
|
|
|
_(resource.disabled?).must_equal false
|
|
|
|
_(resource.logon_mode).must_equal "Interactive/Background"
|
|
|
|
_(resource.last_result).must_equal "1056"
|
|
|
|
_(resource.task_to_run).must_equal '%windir%\\system32\\sc.exe start w32time task_started'
|
|
|
|
_(resource.run_as_user).must_equal "LOCAL SERVICE"
|
|
|
|
_(resource.type).must_equal "windows-task"
|
|
|
|
_(resource.to_s).must_equal "Windows Task 'WeLoveMultiplePizzas'"
|
|
|
|
end
|
2016-11-18 23:32:52 +00:00
|
|
|
end
|