handle nil properties in iis_site (#3040)

* return nil instead of trying to index into nil
* fix typo
* add spec for deleted site

Signed-off-by: Tor Magnus Rakvåg <tm@intility.no>
This commit is contained in:
Tor Magnus Rakvåg 2018-05-31 19:36:15 +02:00 committed by Jared Quick
parent 1046a77027
commit 367f91ea31
2 changed files with 14 additions and 5 deletions

View file

@ -40,19 +40,19 @@ module Inspec::Resources
end
def app_pool
iis_site[:app_pool]
iis_site.nil? ? nil : iis_site[:app_pool]
end
def bindings
iis_site[:bindings]
iis_site.nil? ? nil : iis_site[:bindings]
end
def state
iis_site[:state]
iis_site.nil? ? nil : iis_site[:state]
end
def path
iis_site[:path]
iis_site.nil? ? nil : iis_site[:path]
end
def exists?

View file

@ -33,10 +33,19 @@ describe iis_website('Default Web Site') do
end
describe iis_app('/TestApp', 'Default Web Site') do
it { sould exist }
it { should exist }
it { should have_application_pool('DefaultAppPool') }
it { should have_protocols('http') }
it { should have_site_name('Default Web Site') }
it { should have_physical_path('C:\\inetpub\\wwwroot\\Test') }
it { should have_path('\\TestApp') }
end
# test testing a non existing website
describe iis_site('DeletedSite') do
it { should_not exist }
its('app_pool') { should eq nil }
its('bindings') { should eq nil }
its('state') { should eq nil }
its('path') { should eq nil }
end