mirror of
https://github.com/inspec/inspec
synced 2024-11-30 16:39:20 +00:00
e23249d635
* Add hotfix resource for Windows Signed-off-by: Matt Ray <matthewhray@gmail.com> * Renamed hotfix to windows_hotfix Added additional unit test checking for KB that is not present on a box Signed-off-by: Matt Ray <matthewhray@gmail.com> * Integration test to spot-check for hotfixes Queries the Windows operating system via Powershell for a list of all installed hotfixes and spot-checks every 10th one with the windows_hotfix resource. Checking hundreds is time-consuming. Also checks to ensure a non-installed hotfix is not present. Signed-off-by: Matt Ray <matthewhray@gmail.com>
23 lines
636 B
Ruby
23 lines
636 B
Ruby
# encoding: utf-8
|
|
|
|
# the following test will iterate over all packages retrieved via Powershell and
|
|
# verify that the a sampling of them are installed
|
|
if os.windows?
|
|
|
|
# test that a KB is not installed
|
|
describe windows_hotfix('KB000000') do
|
|
it { should_not be_installed }
|
|
end
|
|
|
|
# get all the KBs applied
|
|
content = powershell('Get-WmiObject -class "win32_quickfixengineering"').stdout.split()
|
|
filter = /^KB\d{7}$/
|
|
kbs = content.select {|i| i =~ filter}
|
|
|
|
# test every 10th package for speed
|
|
for i in (0..kbs.length).step(10) do
|
|
describe windows_hotfix(kbs[i]) do
|
|
it { should be_installed }
|
|
end
|
|
end
|
|
end
|