Project: Chef InSpec (Provisioning / Security & Compliance)
File: iis_app.md

+++ title = "iis_app resource" draft = false gh_repo = "inspec" platform = "windows" [menu] [menu.inspec] title = "iis_app" identifier = "inspec/resources/os/iisapp.md iisapp resource" parent = "inspec/resources/os" +++ Use the `iis_app` Chef InSpec audit resource to test the state of IIS on Windows Server 2012 (and later). {{< readfile file="content/inspec/reusable/md/inspec_installation.md" >}} This resource first became available in v1.28.0 of InSpec. An `iis_app` resource block declares details about the named site: describe iisapp('applicationpath', 'site_name') do it { should exist } it { should haveapplicationpool('application_pool') } it { should have_protocol('protocol') } it { should havesitename('site') } it { should havephysicalpath('physical_path') } it { should havepath('applicationpath') } end where `'application_path'` is the path to the application, such as `'/myapp'` `haveapplicationpool`, `haveprotocol`, `havesitename`, `havephysicalpath` and `havepath` are the different for this resource. For example: describe iis_app('/myapp', 'Default Web Site') do it { should exist } it { should haveapplicationpool('MyAppPool') } it { should have_protocol('http') } it { should havesitename('Default Web Site') } it { should havephysicalpath('C:\\inetpub\\wwwroot\\myapp') } it { should have_path('\\My Application') } end `application_pool` property returns the name of the application pool in which the site's root application is run, such as `DefaultAppPool`. its('application_pool') { should eq 'root' } `path` property returns the path to the application. its('path') { should eq '\my_app' } `physical_path` property returns the physical path of the application, such as `'C:\\inetpub\\wwwroot\\myapp'`. its('physical_path') { should eq 'C:\\inetpub\\wwwroot\\myapp' } `protocols` property returns an array of protocols i.e. the binding for the site, such as `'http'`. A site may have multiple bindings. its('protocols') { should include 'http' } `site_name` property returns the name of the site, such as `'Default Web Site'` its('site_name') { should eq 'Default Web Site' } describe iis_app('Default Web Site') do it { should exist } it { should be_running } it { should haveapppool('DefaultAppPool') } it { should have_binding('http *:80:') } it { should have_path('%SystemDrive%\\inetpub\\wwwroot') } end describe service('W3SVC') do it { should be_installed } it { should be_running } end {{< readfile file="content/inspec/reusable/md/inspecmatcherslink.md" >}} This resource has the following special matchers. The `exist` matcher tests if the site exists: it { should exist } The `haveapplicationpool` matcher tests if the named application pool exists for the web application: it { should haveapplicationpool('DefaultAppPool') } The `have_protocol` matcher tests if the specified protocol exists for the web application: it { should have_protocol('http') } or: it { should have_protocol('https') } A web application may have multiple bindings; use a `have_protocol` matcher for each unique web application binding to be tested. The `have_protocol` matcher can also test attributes that are defined for a web application enabledProtocols. it { should have_protocol('http') } For example, testing a site that doesn't have https enabled: it { shouldnot haveprotocol('https') } it { should have_protocol('http') } Testing a web application with https enabled and http enabled: it { should have_protocol('https') } it { should have_protocol('http') } The `havephysicalpath` matcher tests if the named path is defined for the web application: it { should havephysicalpath('C:\\inetpub\\wwwroot') }