mirror of
https://github.com/inspec/inspec
synced 2024-11-26 22:50:36 +00:00
Fix platform on apache_conf to include all unix.
Now discovers the first available conf file from a list of known paths. Might have to expand based on various distros. Had to tweak the tests because the mock loader mocks EVERYTHING every time. :/ Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
parent
df31f744f4
commit
9c051da22b
2 changed files with 14 additions and 10 deletions
|
@ -7,9 +7,9 @@ require "inspec/utils/file_reader"
|
|||
module Inspec::Resources
|
||||
class ApacheConf < Inspec.resource(1)
|
||||
name "apache_conf"
|
||||
supports platform: "linux"
|
||||
supports platform: "debian"
|
||||
desc "Use the apache_conf InSpec audit resource to test the configuration settings for Apache. This file is typically located under /etc/apache2 on the Debian and Ubuntu platforms and under /etc/httpd on the Fedora, CentOS, Red Hat Enterprise Linux, and Arch Linux platforms. The configuration settings may vary significantly from platform to platform."
|
||||
supports platform: "unix"
|
||||
|
||||
desc "Use the apache_conf InSpec audit resource to test the configuration settings for Apache. The configuration settings may vary significantly from platform to platform."
|
||||
example <<~EXAMPLE
|
||||
describe apache_conf do
|
||||
its('setting_name') { should eq 'value' }
|
||||
|
@ -145,12 +145,13 @@ module Inspec::Resources
|
|||
|
||||
private
|
||||
|
||||
PATHS = ["/etc/apache2/apache2.conf",
|
||||
"/etc/httpd/conf/httpd.conf"]
|
||||
.map(&:freeze)
|
||||
.freeze
|
||||
|
||||
def default_conf_path
|
||||
if inspec.os.debian?
|
||||
"/etc/apache2/apache2.conf"
|
||||
else
|
||||
"/etc/httpd/conf/httpd.conf"
|
||||
end
|
||||
@default ||= PATHS.find { |path| inspec.file(path).exist? }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,8 @@ 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 = MockLoader.new(:ubuntu1404).load_resource("apache_conf",
|
||||
"/etc/apache2/apache2.conf")
|
||||
_(resource.params).must_be_kind_of Hash
|
||||
_(resource.content).must_be_kind_of String
|
||||
_(resource.params("ServerRoot")).must_equal ["/etc/apache2"]
|
||||
|
@ -22,7 +23,9 @@ describe "Inspec::Resources::ApacheConf" do
|
|||
|
||||
# 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 = MockLoader.new(:centos6).load_resource("apache_conf",
|
||||
"/etc/httpd/conf/httpd.conf")
|
||||
|
||||
_(resource.params).must_be_kind_of Hash
|
||||
_(resource.content).must_be_kind_of String
|
||||
_(resource.params("ServerRoot")).must_equal ["/etc/httpd"]
|
||||
|
|
Loading…
Reference in a new issue