mirror of
https://github.com/inspec/inspec
synced 2024-12-11 22:02:47 +00:00
685ba1bc1e
* Update apache_conf test to check for ServerAlias values. Signed-off-by: Miah Johnson <miah@chia-pet.org> * Add ServerAlias key and values to mock apache conf which includes trailing whitespace. Signed-off-by: Miah Johnson <miah@chia-pet.org> * Updated test to reflect all ServerAlias values being put into a single array item. This is expected as we do not override the key_values default setting of '1' when passing the raw configuration to SimpleConfig. Signed-off-by: Miah Johnson <miah@chia-pet.org> * Update the regular expression to include a conditional with positive lookahead that checks if the line ends with one or more spaces. If the lookahead succeeds we non-greedily capture, and when it fails we greedily capture. Signed-off-by: Miah Johnson <miah@chia-pet.org>
38 lines
1.6 KiB
Ruby
38 lines
1.6 KiB
Ruby
# encoding: utf-8
|
|
# author: Stephan Renatus
|
|
|
|
require 'helper'
|
|
require 'inspec/resource'
|
|
require 'hashie'
|
|
|
|
describe 'Inspec::Resources::ApacheConf' do
|
|
# debian style apache2
|
|
it 'reads values in apache2.conf and from Include, IncludeOptional params' do
|
|
resource = MockLoader.new(:ubuntu1404).load_resource('apache_conf')
|
|
_(resource.params).must_be_kind_of Hash
|
|
_(resource.content).must_be_kind_of String
|
|
_(resource.params('ServerRoot')).must_equal ['"/etc/apache2"']
|
|
_(resource.params('ServerAlias')).must_equal ['inspec.test www.inspec.test io.inspec.test']
|
|
_(resource.params('Listen').sort).must_equal ['443', '80']
|
|
# sourced using a linked file in conf-enabled/
|
|
_(resource.params('ServerSignature')).must_equal ['Off']
|
|
# TODO(sr) currently, the parser only merges parameter across separate
|
|
# source files, not in one file
|
|
_(resource.params('Define')).must_equal ['ENABLE_USR_LIB_CGI_BIN',
|
|
'ENABLE_USR_LIB_CGI_BIN']
|
|
end
|
|
|
|
# non debian style httpd
|
|
it 'reads values in httpd.conf and from Include, IncludeOptional params' do
|
|
resource = MockLoader.new(:centos6).load_resource('apache_conf')
|
|
_(resource.params).must_be_kind_of Hash
|
|
_(resource.content).must_be_kind_of String
|
|
_(resource.params('ServerRoot')).must_equal ['"/etc/httpd"']
|
|
_(resource.params('Listen').sort).must_equal ['443', '80']
|
|
|
|
# sourced using an absolute path in httpd.conf
|
|
_(resource.params('ExtendedStatus')).must_equal ['Off']
|
|
# sourced using a linked file in conf-enabled/
|
|
_(resource.params('ServerSignature')).must_equal ['Off']
|
|
end
|
|
end
|