mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
Test case to test apache_conf when server root is not configured
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
This commit is contained in:
parent
bc429a27f1
commit
1e8363587e
3 changed files with 27 additions and 2 deletions
4
test/fixtures/files/apache2_server_root_void.conf
vendored
Normal file
4
test/fixtures/files/apache2_server_root_void.conf
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
# This is the modified Apache server configuration file. It contains comments.
|
||||
# ServerRoot "/etc/apache2" --> This is commented to test non configuration of serverRoot.
|
||||
ServerAlias inspec.test www.inspec.test io.inspec.test
|
||||
Include ports.conf
|
|
@ -88,7 +88,7 @@ class MockLoader
|
|||
mockfile.call("emptyfile")
|
||||
}
|
||||
|
||||
mock.files = {
|
||||
mock_files = {
|
||||
"/proc/net/bonding/bond0" => mockfile.call("bond0"),
|
||||
"/etc/ssh/ssh_config" => mockfile.call("ssh_config"),
|
||||
"/etc/ssh/sshd_config" => mockfile.call("sshd_config"),
|
||||
|
@ -118,7 +118,6 @@ class MockLoader
|
|||
"nonexistent.json" => mockfile.call("nonexistent.json"),
|
||||
"/sys/class/net/br0/bridge" => mockdir.call(true),
|
||||
"rootwrap.conf" => mockfile.call("rootwrap.conf"),
|
||||
"/etc/apache2/apache2.conf" => mockfile.call("apache2.conf"),
|
||||
"/etc/apache2/ports.conf" => mockfile.call("ports.conf"),
|
||||
"/etc/httpd/conf/httpd.conf" => mockfile.call("httpd.conf"),
|
||||
"/etc/httpd/conf.d/ssl.conf" => mockfile.call("ssl.conf"),
|
||||
|
@ -175,6 +174,19 @@ class MockLoader
|
|||
"/etc/selinux/selinux_conf" => mockfile.call("selinux_conf"),
|
||||
}
|
||||
|
||||
if @platform[:name] == "ubuntu" && @platform[:release] == "14.04"
|
||||
mock_files.merge!(
|
||||
"/etc/apache2/apache2.conf" => mockfile.call("apache2.conf")
|
||||
)
|
||||
elsif @platform[:name] == "ubuntu" && @platform[:release] == "15.04"
|
||||
# using this ubuntu version to test apache_conf with non configured server root in conf file
|
||||
mock_files.merge!(
|
||||
"/etc/apache2/apache2.conf" => mockfile.call("apache2_server_root_void.conf")
|
||||
)
|
||||
end
|
||||
|
||||
mock.files = mock_files
|
||||
|
||||
# create all mock commands
|
||||
cmd = lambda { |x|
|
||||
stdout = ::File.read(::File.join(scriptpath, "/fixtures/cmd/" + x))
|
||||
|
|
|
@ -21,6 +21,15 @@ describe "Inspec::Resources::ApacheConf" do
|
|||
ENABLE_USR_LIB_CGI_BIN}
|
||||
end
|
||||
|
||||
it "reads values successfully from apache2.conf and ignores Include, IncludeOptional params when server root is not configured" do
|
||||
resource = MockLoader.new(:ubuntu1504).load_resource("apache_conf", "/etc/apache2/apache2.conf")
|
||||
_(resource.params).must_be_kind_of Hash
|
||||
_(resource.content).must_be_kind_of String
|
||||
_(resource.params("ServerAlias")).must_equal ["inspec.test www.inspec.test io.inspec.test"]
|
||||
assert_nil(resource.params("ServerRoot"))
|
||||
assert_nil(resource.params("Listen"))
|
||||
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",
|
||||
|
|
Loading…
Reference in a new issue