From f007b9168ce9c00b511e4e331fc6c150b39a6e1c Mon Sep 17 00:00:00 2001 From: Franklin Webber Date: Thu, 25 Jan 2018 12:19:53 -0600 Subject: [PATCH 1/3] Fixes the apache_conf Listen property returns an array The result is an array and not a string even when there is one value. Signed-off-by: Franklin Webber --- docs/resources/apache_conf.md.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/resources/apache_conf.md.erb b/docs/resources/apache_conf.md.erb index f9e1ab7aa7..3166d89337 100644 --- a/docs/resources/apache_conf.md.erb +++ b/docs/resources/apache_conf.md.erb @@ -37,7 +37,7 @@ The following examples show how to use this InSpec audit resource. ### Test ports for SSL describe apache_conf do - its('Listen') { should eq '443'} + its('Listen') { should include '443' } end
@@ -57,5 +57,5 @@ For example: describe apache_conf do its('MaxClients') { should eq 100 } - its('Listen') { should eq '443'} + its('Listen') { should include '443' } end From 1b2d8eea4aef5cd6a6e364b3bbcbb95f6d80e3f1 Mon Sep 17 00:00:00 2001 From: Franklin Webber Date: Thu, 25 Jan 2018 12:26:46 -0600 Subject: [PATCH 2/3] Updates the apache_conf timeout, allowoverride, and maxclients to include It seems that all of these values are placed in an array of values so the matcher needs to be `include`. Signed-off-by: Franklin Webber --- docs/resources/apache_conf.md.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/resources/apache_conf.md.erb b/docs/resources/apache_conf.md.erb index 3166d89337..4920e7e8aa 100644 --- a/docs/resources/apache_conf.md.erb +++ b/docs/resources/apache_conf.md.erb @@ -31,7 +31,7 @@ The following examples show how to use this InSpec audit resource. ### Test for blocking .htaccess files on CentOS describe apache_conf do - its('AllowOverride') { should eq 'None' } + its('AllowOverride') { should include 'None' } end ### Test ports for SSL @@ -51,11 +51,11 @@ This InSpec audit resource matches any service that is listed in the Apache conf or: - its('Timeout') { should eq 300 } + its('Timeout') { should include '300' } For example: describe apache_conf do - its('MaxClients') { should eq 100 } + its('MaxClients') { should include '100' } its('Listen') { should include '443' } end From 4bb55cb3285fabb62ab6e3efb8d93ae7dcff96ec Mon Sep 17 00:00:00 2001 From: Franklin Webber Date: Thu, 25 Jan 2018 17:12:20 -0600 Subject: [PATCH 3/3] Updates docs for apache_conf * Uses the suggested `cmp` instead of `include` * Adds the way to properly compare a list of multiple ports Signed-off-by: Franklin Webber --- docs/resources/apache_conf.md.erb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/resources/apache_conf.md.erb b/docs/resources/apache_conf.md.erb index 4920e7e8aa..4dddba55aa 100644 --- a/docs/resources/apache_conf.md.erb +++ b/docs/resources/apache_conf.md.erb @@ -37,7 +37,13 @@ The following examples show how to use this InSpec audit resource. ### Test ports for SSL describe apache_conf do - its('Listen') { should include '443' } + its('Listen') { should cmp '443' } + end + +### Test multiple ports are listening + + describe apache_conf do + its('Listen') { should =~ [ '80', '443' ] } end
@@ -51,11 +57,11 @@ This InSpec audit resource matches any service that is listed in the Apache conf or: - its('Timeout') { should include '300' } + its('Timeout') { should cmp '300' } For example: describe apache_conf do - its('MaxClients') { should include '100' } - its('Listen') { should include '443' } + its('MaxClients') { should cmp '100' } + its('Listen') { should cmp '443' } end