mirror of
https://github.com/inspec/inspec
synced 2024-12-12 14:22:38 +00:00
Fix for postfix_conf when using a non-standard config location
Pass the first argument of the opts array instead of the whole array which confuses the SimpleConfig parser. Also added a test which verifies this fixes the issue. In addition, change the base_name to something that matches other resource base names. Signed-off-by: Lance Albertson <lance@osuosl.org>
This commit is contained in:
parent
d1ffce7278
commit
1e94e3503e
4 changed files with 14 additions and 2 deletions
|
@ -11,7 +11,7 @@ module Inspec::Resources
|
||||||
def initialize(*opts)
|
def initialize(*opts)
|
||||||
@params = {}
|
@params = {}
|
||||||
if opts.length == 1
|
if opts.length == 1
|
||||||
@raw_content = load_raw_content(opts)
|
@raw_content = load_raw_content(opts[0])
|
||||||
else
|
else
|
||||||
@raw_content = load_raw_content("/etc/postfix/main.cf")
|
@raw_content = load_raw_content("/etc/postfix/main.cf")
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ module Inspec::Resources
|
||||||
private
|
private
|
||||||
|
|
||||||
def resource_base_name
|
def resource_base_name
|
||||||
"POSTFIX_CONF"
|
"Postfix Config"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -160,6 +160,7 @@ class MockLoader
|
||||||
"C:/fakepath/fakefile" => emptyfile.call,
|
"C:/fakepath/fakefile" => emptyfile.call,
|
||||||
"/etc/cron.d/crondotd" => mockfile.call("crondotd"),
|
"/etc/cron.d/crondotd" => mockfile.call("crondotd"),
|
||||||
"/etc/postfix/main.cf" => mockfile.call("main.cf"),
|
"/etc/postfix/main.cf" => mockfile.call("main.cf"),
|
||||||
|
"/etc/postfix/other.cf" => mockfile.call("other.cf"),
|
||||||
}
|
}
|
||||||
|
|
||||||
# create all mock commands
|
# create all mock commands
|
||||||
|
|
4
test/unit/mock/files/other.cf
Normal file
4
test/unit/mock/files/other.cf
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# Test other configuration for Postfix
|
||||||
|
|
||||||
|
test_parameter_other = value
|
||||||
|
other_test_param_other = $value
|
|
@ -10,4 +10,11 @@ describe "Inspec::Resources::Postfix_Conf" do
|
||||||
_(resource.params).must_equal result
|
_(resource.params).must_equal result
|
||||||
_(resource.value(%w{test_parameter})).must_equal "value"
|
_(resource.value(%w{test_parameter})).must_equal "value"
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue