2017-06-15 09:13:07 +00:00
---
title: About the iis_app Resource
2018-02-16 00:28:15 +00:00
platform: windows
2017-06-15 09:13:07 +00:00
---
# iis_app
2019-04-26 18:24:29 +00:00
Use the `iis_app` Chef InSpec audit resource to test the state of IIS on Windows Server 2012 (and later).
2017-06-15 09:13:07 +00:00
2017-10-03 21:35:10 +00:00
<br>
2018-08-09 12:34:49 +00:00
## Availability
### Installation
2019-04-26 18:24:29 +00:00
This resource is distributed along with Chef InSpec itself. You can use it automatically.
2018-08-09 12:34:49 +00:00
### Version
This resource first became available in v1.28.0 of InSpec.
2017-06-15 09:13:07 +00:00
## Syntax
An `iis_app` resource block declares details about the named site:
describe iis_app('application_path', 'site_name') do
it { should exist }
it { should have_application_pool('application_pool') }
2019-12-31 15:51:55 +00:00
it { should have_protocol('protocol') }
2017-06-15 09:13:07 +00:00
it { should have_site_name('site') }
it { should have_physical_path('physical_path') }
it { should have_path('application_path') }
end
where
* `'application_path'` is the path to the application, such as `'/myapp'`
* `'site_name'` is the name of the site, such as `'Default Web Site'`
* `('application_pool')` is the name of the application pool in which the site's root application is run, such as `'DefaultAppPool'`
* `('protocols')` is a binding for the site, such as `'http'`. A site may have multiple bindings; therefore, use a `have_protocol` matcher for each site protocol to be tested
2018-06-06 18:10:48 +00:00
* `('physical_path')` is the physical path to the application, such as `'C:\\inetpub\\wwwroot\\myapp'`
2017-06-15 09:13:07 +00:00
For example:
describe iis_app('/myapp', 'Default Web Site') do
it { should exist }
it { should have_application_pool('MyAppPool') }
2019-12-31 15:51:55 +00:00
it { should have_protocol('http') }
2017-06-15 09:13:07 +00:00
it { should have_site_name('Default Web Site') }
it { should have_physical_path('C:\\inetpub\\wwwroot\\myapp') }
it { should have_path('\\My Application') }
end
2017-10-03 21:35:10 +00:00
<br>
2018-02-15 14:33:22 +00:00
## Properties
2018-02-08 21:41:41 +00:00
application\_pool, path, physical\_path, protocols, site\_name
<br>
2018-02-16 02:34:11 +00:00
2018-02-08 21:41:41 +00:00
## Resource Examples
2017-10-03 21:35:10 +00:00
2019-04-26 18:24:29 +00:00
The following examples show how to use this Chef InSpec audit resource.
2017-10-03 21:35:10 +00:00
### Test a default IIS web application
describe iis_app('Default Web Site') do
it { should exist }
it { should be_running }
it { should have_app_pool('DefaultAppPool') }
it { should have_binding('http *:80:') }
it { should have_path('%SystemDrive%\\inetpub\\wwwroot') }
end
2017-06-15 09:13:07 +00:00
2017-10-03 21:35:10 +00:00
### Test if IIS service is running
2017-06-15 09:13:07 +00:00
2017-10-03 21:35:10 +00:00
describe service('W3SVC') do
it { should be_installed }
it { should be_running }
end
2017-06-15 09:13:07 +00:00
2017-10-03 21:35:10 +00:00
<br>
2017-06-15 09:13:07 +00:00
2017-10-03 21:35:10 +00:00
## Matchers
2017-06-15 09:13:07 +00:00
2018-02-16 03:07:18 +00:00
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
2017-06-15 09:13:07 +00:00
### exist
The `exist` matcher tests if the site exists:
it { should exist }
### have\_application\_pool
The `have_application_pool` matcher tests if the named application pool exists for the web application:
it { should have_application_pool('DefaultAppPool') }
### have_protocol
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.
##### Protocol Attributes
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 { should_not have_protocol('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') }
2018-02-08 21:41:41 +00:00
### have\_physical\_path
2017-06-15 09:13:07 +00:00
The `have_physical_path` matcher tests if the named path is defined for the web application:
it { should have_physical_path('C:\\inetpub\\wwwroot') }