Doc update for interface resource

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2020-05-14 13:14:57 -04:00 committed by Mary Jinglewski
parent 58578226b8
commit 9109864fe2

View file

@ -5,10 +5,11 @@ platform: os
# interface
Use the `interface` Chef InSpec audit resource to test basic network adapter properties, such as name, status, and link speed (in MB/sec).
Use the `interface` Chef InSpec audit resource to test basic network adapter properties, such as name, status, IP addresses, and link speed (in MB/sec).
* On Linux platforms, `/sys/class/net/#{iface}` is used as source
* On the Windows platform, the `Get-NetAdapter` cmdlet is used as source
* The MacOS platform is not currently supported.
<br>
@ -30,23 +31,53 @@ An `interface` resource block declares network interface properties to be tested
it { should be_up }
its('speed') { should eq 1000 }
its('name') { should eq eth0 }
its('ipv4_addresses') { should include '10.0.0.5' }
end
<br>
## Properties
`name`, `speed`
`ipv4_addresses`, `ipv4_addresses_netmask`, `ipv4_cidrs`, `ipv6_addresses`, `ipv6_cidrs`, `name`, `speed`
<br>
## Resource Property Examples
### ipv4_addresses
The `ipv4_addresses` property returns an Array of IPv4 addresses as Strings. You may then test if the specified address exists on the named network interface:
its('ipv4_addresses') { should include '127.0.0.1' }
### ipv4\_addresses\_netmask
The `ipv4_addresses_netmask` property returns an Array of Strings, each containing the IPv4 address, a slash, and the netmask. You may then test if the specified address and netmask exists on the named network interface:
its('ipv4_addresses_netmask') { should include '127.0.0.1/255.0.0.0' }
### ipv6_addresses
The `ipv6_addresses` property returns an Array of Strings and tests if the specified address exists on the named network interface:
its('ipv6_addresses') { should include '::1' }
### ipv4_cidrs
The `ipv4_cidrs` property returns an Array of Strings and tests if the specified address and netmask combination exists on the named network interface:
its('ipv4_cidrs') { should include '127.0.0.1/8' }
### ipv6_cidrs
The `ipv6_cidrs` property returns an Array of Strings and tests if the specified address and netmask combination exists on the named network interface:
its('ipv6_cidrs') { should include '::1/128' }
### name
The `name` property tests if the named network interface exists:
The `name` property returns the name of the interface:
its('name') { should eq eth0 }
its('name') { should eq 'eth0' }
### speed
@ -54,38 +85,6 @@ The `speed` property tests the speed of the network interface, in MB/sec:
its('speed') { should eq 1000 }
### ipv4_addresses
The `ipv4_addresses` property tests if the specified address exists on the named network interface:
its('ipv4_addresses') { should include '127.0.0.1' }
### ipv4_addresses_netmask
The `ipv4_addresses_netmask` property tests if the specified address and netmask exists on the named network interface:
its('ipv4_addresses_netmask') { should include '127.0.0.1/255.0.0.0' }
### ipv6_addresses
The `ipv6_addresses` property tests if the specified address exists on the named network interface:
its('ipv6_addresses') { should include '::1' }
### ipv4_cidrs
The `ipv4_cidrs` property tests if the specified address and netmask combination exists on the named network interface:
its('ipv4_cidrs') { should include '127.0.0.1/8' }
### ipv6_cidrs
The `ipv6_cidrs` property tests if the specified address and netmask combination exists on the named network interface:
its('ipv6_cidrs') { should include '::1/128' }
<br>
## Matchers
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
@ -96,13 +95,19 @@ The `be_up` matcher tests if the network interface is available:
it { should be_up }
### have_an_ipv4_address
### exist
The `exist` matcher tests if the network interface exists:
it { should exist }
### have\_an\_ipv4\_address
The `have_an_ipv4_address` matcher tests if the network interface has any IPv4 addresses assigned:
it { should have_an_ipv4_address }
### have_an_ipv6_address
### have\_an\_ipv6\_address
The `have_an_ipv6_address` matcher tests if the network interface has any IPv6 addresses assigned: