2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/apache_conf"
|
|
|
|
require "hashie"
|
2015-12-04 07:59:44 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "Inspec::Resources::ApacheConf" do
|
2016-09-03 02:00:12 +00:00
|
|
|
# debian style apache2
|
2019-06-11 22:24:35 +00:00
|
|
|
it "reads values in apache2.conf and from Include, IncludeOptional params" do
|
2020-01-28 20:11:58 +00:00
|
|
|
resource = MockLoader.new(:ubuntu1404).load_resource("apache_conf",
|
|
|
|
"/etc/apache2/apache2.conf")
|
2016-09-03 01:55:28 +00:00
|
|
|
_(resource.params).must_be_kind_of Hash
|
|
|
|
_(resource.content).must_be_kind_of String
|
2019-06-11 22:24:35 +00:00
|
|
|
_(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 %w{443 80}
|
2017-02-24 05:13:22 +00:00
|
|
|
# sourced using a linked file in conf-enabled/
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.params("ServerSignature")).must_equal ["Off"]
|
2015-12-04 07:59:44 +00:00
|
|
|
# TODO(sr) currently, the parser only merges parameter across separate
|
|
|
|
# source files, not in one file
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.params("Define")).must_equal %w{ENABLE_USR_LIB_CGI_BIN
|
|
|
|
ENABLE_USR_LIB_CGI_BIN}
|
2015-12-04 07:59:44 +00:00
|
|
|
end
|
2016-09-03 01:55:28 +00:00
|
|
|
|
2016-09-03 02:00:12 +00:00
|
|
|
# non debian style httpd
|
2019-06-11 22:24:35 +00:00
|
|
|
it "reads values in httpd.conf and from Include, IncludeOptional params" do
|
2020-01-28 20:11:58 +00:00
|
|
|
resource = MockLoader.new(:centos6).load_resource("apache_conf",
|
|
|
|
"/etc/httpd/conf/httpd.conf")
|
|
|
|
|
2016-09-03 01:55:28 +00:00
|
|
|
_(resource.params).must_be_kind_of Hash
|
|
|
|
_(resource.content).must_be_kind_of String
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.params("ServerRoot")).must_equal ["/etc/httpd"]
|
|
|
|
_(resource.params("Listen").sort).must_equal %w{443 80}
|
2016-09-03 01:55:28 +00:00
|
|
|
|
2016-09-09 17:16:42 +00:00
|
|
|
# sourced using an absolute path in httpd.conf
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.params("ExtendedStatus")).must_equal ["Off"]
|
2017-02-24 05:13:22 +00:00
|
|
|
# sourced using a linked file in conf-enabled/
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.params("ServerSignature")).must_equal ["Off"]
|
2016-09-09 17:16:42 +00:00
|
|
|
end
|
2015-12-04 07:59:44 +00:00
|
|
|
end
|