Merge pull request #4443 from ramereth/fix-postfix_conf-other-file

Fix for postfix_conf when using a non-standard config location
This commit is contained in:
Miah Johnson 2019-09-06 11:57:51 -07:00 committed by GitHub
commit f11d6bcfba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 2 deletions

View file

@ -11,7 +11,7 @@ module Inspec::Resources
def initialize(*opts)
@params = {}
if opts.length == 1
@raw_content = load_raw_content(opts)
@raw_content = load_raw_content(opts[0])
else
@raw_content = load_raw_content("/etc/postfix/main.cf")
end
@ -25,7 +25,7 @@ module Inspec::Resources
private
def resource_base_name
"POSTFIX_CONF"
"Postfix Config"
end
end
end

View file

@ -160,6 +160,7 @@ class MockLoader
"C:/fakepath/fakefile" => emptyfile.call,
"/etc/cron.d/crondotd" => mockfile.call("crondotd"),
"/etc/postfix/main.cf" => mockfile.call("main.cf"),
"/etc/postfix/other.cf" => mockfile.call("other.cf"),
}
# create all mock commands

View file

@ -0,0 +1,4 @@
# Test other configuration for Postfix
test_parameter_other = value
other_test_param_other = $value

View file

@ -10,4 +10,11 @@ describe "Inspec::Resources::Postfix_Conf" do
_(resource.params).must_equal result
_(resource.value(%w{test_parameter})).must_equal "value"
end
it "Test default parsing of other.cf on Centos 7" do
resource = MockLoader.new(:centos7).load_resource("postfix_conf", "/etc/postfix/other.cf")
result = { "test_parameter_other" => "value", "other_test_param_other" => "$value" }
_(resource.params).must_equal result
_(resource.value(%w{test_parameter_other})).must_equal "value"
end
end