2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/kernel_module"
|
2015-09-20 16:43:52 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "Inspec::Resources::KernelModule" do
|
2017-07-05 09:41:44 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
# kernel version
|
2017-07-05 09:41:44 +00:00
|
|
|
# 1
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify kernel_module version" do
|
|
|
|
resource = load_resource("kernel_module", "dhcp")
|
|
|
|
_(resource.version).must_equal "3.2.2"
|
2017-07-05 09:41:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# loaded
|
|
|
|
# 2
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify kernel_module parsing `loaded` - true" do
|
|
|
|
resource = load_resource("kernel_module", "bridge")
|
2015-09-21 11:02:17 +00:00
|
|
|
_(resource.loaded?).must_equal true
|
2015-09-20 16:43:52 +00:00
|
|
|
end
|
|
|
|
|
2017-07-05 09:41:44 +00:00
|
|
|
# 3
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify kernel_module parsing `loaded` - false" do
|
|
|
|
resource = load_resource("kernel_module", "bridges")
|
2015-09-21 11:02:17 +00:00
|
|
|
_(resource.loaded?).must_equal false
|
|
|
|
end
|
2015-09-20 16:43:52 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
# disabled
|
2017-07-05 09:41:44 +00:00
|
|
|
# 4
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify kernel_module parsing `disabled` - true " do
|
|
|
|
resource = load_resource("kernel_module", "nvidiafb")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.disabled?).must_equal true
|
|
|
|
end
|
|
|
|
|
|
|
|
# 5
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify kernel_module parsing `disabled` - false" do
|
|
|
|
resource = load_resource("kernel_module", "bridge")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.disabled?).must_equal false
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
# /bin/true
|
2017-07-05 09:41:44 +00:00
|
|
|
# 6
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify a kernel_module is disabled via /bin/true - true" do
|
|
|
|
resource = load_resource("kernel_module", "nvidiafb")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal true
|
|
|
|
end
|
|
|
|
|
|
|
|
# 7
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify a kernel_module is not disabled via /bin/true - false" do
|
|
|
|
resource = load_resource("kernel_module", "ssftb")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal false
|
|
|
|
end
|
|
|
|
|
|
|
|
# 8
|
2019-06-11 22:24:35 +00:00
|
|
|
# /bin/false
|
|
|
|
it "Verify a kernel_module is disabled via /bin/false - true" do
|
|
|
|
resource = load_resource("kernel_module", "sstfb")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal true
|
|
|
|
end
|
|
|
|
|
|
|
|
# 9
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify a kernel_module is not disabled via /bin/false - true " do
|
|
|
|
resource = load_resource("kernel_module", "bridge")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal false
|
|
|
|
end
|
|
|
|
|
|
|
|
# 10
|
|
|
|
# unlisted bin/true,/bin/false
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify an unlisted kernel_module is not disabled via /bin/true - false" do
|
|
|
|
resource = load_resource("kernel_module", "fakemod")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal false
|
|
|
|
end
|
|
|
|
|
|
|
|
# 11
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify an unlisted kernel_module is not disabled via /bin/false - false" do
|
|
|
|
resource = load_resource("kernel_module", "fakemod")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal false
|
|
|
|
end
|
|
|
|
|
|
|
|
# 12
|
2019-06-11 22:24:35 +00:00
|
|
|
# blacklisting
|
|
|
|
it "Verify a kernel_module is blacklisted - true" do
|
|
|
|
resource = load_resource("kernel_module", "floppy")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal true
|
|
|
|
end
|
|
|
|
|
|
|
|
# 13
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify a kernel_module is not blacklisted - false" do
|
|
|
|
resource = load_resource("kernel_module", "ssftb")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal false
|
|
|
|
end
|
|
|
|
|
|
|
|
# 14
|
2019-06-11 22:24:35 +00:00
|
|
|
# unlisted moduled
|
|
|
|
it "Verify an unlisted kernel_module is not `loaded` - false" do
|
|
|
|
resource = load_resource("kernel_module", "not_a_module")
|
2015-09-21 11:02:17 +00:00
|
|
|
_(resource.loaded?).must_equal false
|
2015-09-20 16:43:52 +00:00
|
|
|
end
|
2017-01-25 20:47:39 +00:00
|
|
|
|
2017-07-05 09:41:44 +00:00
|
|
|
# 15
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify an unlisted kernel_module is not `disabled` - false" do
|
|
|
|
resource = load_resource("kernel_module", "not_a_module")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.disabled?).must_equal false
|
|
|
|
end
|
|
|
|
|
|
|
|
# 16
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify an unlisted kernel_module is not blacklisted - false" do
|
|
|
|
resource = load_resource("kernel_module", "not_a_module")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal false
|
|
|
|
end
|
|
|
|
|
|
|
|
# 17
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify an unlisted kernel_module is not disabled_via_bin_true - false" do
|
|
|
|
resource = load_resource("kernel_module", "not_a_module")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal false
|
|
|
|
end
|
|
|
|
|
|
|
|
# 18
|
2019-06-11 22:24:35 +00:00
|
|
|
it "Verify an unlisted kernel_module is not disabled_via_bin_false - false" do
|
|
|
|
resource = load_resource("kernel_module", "not_a_module")
|
2017-07-05 09:41:44 +00:00
|
|
|
_(resource.blacklisted?).must_equal false
|
2017-01-25 20:47:39 +00:00
|
|
|
end
|
2015-09-20 16:43:52 +00:00
|
|
|
end
|