2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/aide_conf"
|
2017-08-25 20:13:43 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "Inspec::Resources::AideConf" do
|
|
|
|
describe "AideConf Parameters" do
|
|
|
|
resource = load_resource("aide_conf")
|
|
|
|
it "Verify aide_conf all_have_rule property - true case" do
|
|
|
|
_(resource.all_have_rule("p")).must_equal true
|
2017-08-25 20:13:43 +00:00
|
|
|
end
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify aide_conf all_have_rule property - false case" do
|
|
|
|
_(resource.all_have_rule("x")).must_equal false
|
2017-08-25 20:13:43 +00:00
|
|
|
end
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify aide_conf filtering by selection_line for single rule" do
|
|
|
|
entries = resource.where { selection_line == "/bin" }
|
|
|
|
_(entries.rules.flatten).must_include "sha512"
|
2017-08-25 20:13:43 +00:00
|
|
|
end
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify handle_multi_rule properly expands rules based on macro" do
|
|
|
|
entries = resource.where { selection_line == "/sbin" }
|
2017-08-25 20:13:43 +00:00
|
|
|
_(entries.rules).must_include %w{p i l n u g s m c md5 sha512}
|
|
|
|
end
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify parse_rule_line properly expands rules based on macro" do
|
|
|
|
entries = resource.where { selection_line == "/bin" }
|
2017-08-25 20:13:43 +00:00
|
|
|
_(entries.rules).must_include %w{b t p i l n u g s m c md5 sha512}
|
|
|
|
end
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify parse_selection_line normalizes directories ending in /" do
|
|
|
|
_(resource.selection_lines).must_include "/boot"
|
2017-08-25 20:13:43 +00:00
|
|
|
end
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify aide_conf finds all selection_line dirs" do
|
|
|
|
_(resource.selection_lines).must_equal ["/boot", "/bin", "/sbin", "/etc/hosts"]
|
2017-08-25 20:13:43 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|