2024-03-08 03:41:45 +01:00
|
|
|
require_relative "../setup"
|
|
|
|
module BSD::Control
|
2024-03-08 05:14:58 +01:00
|
|
|
class FeatureStatusTest < Test::Unit::TestCase
|
2024-03-08 03:41:45 +01:00
|
|
|
require 'fileutils'
|
|
|
|
include FileUtils
|
|
|
|
|
|
|
|
def test_mprotect_sysdef_status
|
|
|
|
touch(file)
|
|
|
|
assert_equal :sysdef,
|
2024-03-08 05:23:16 +01:00
|
|
|
BSD::Control.feature(:mprotect).status(file)
|
2024-03-08 03:41:45 +01:00
|
|
|
ensure
|
|
|
|
rm(file)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_mprotect_enabled_status
|
|
|
|
touch(file)
|
2024-03-08 05:23:16 +01:00
|
|
|
BSD::Control.feature(:mprotect).enable!(file)
|
2024-03-08 03:41:45 +01:00
|
|
|
assert_equal :enabled,
|
2024-03-08 05:23:16 +01:00
|
|
|
BSD::Control.feature(:mprotect).status(file)
|
2024-03-08 03:41:45 +01:00
|
|
|
ensure
|
|
|
|
rm(file)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def test_mprotect_disabled_status
|
|
|
|
touch(file)
|
2024-03-08 05:23:16 +01:00
|
|
|
BSD::Control.feature(:mprotect).disable!(file)
|
2024-03-08 03:41:45 +01:00
|
|
|
assert_equal :disabled,
|
2024-03-08 05:23:16 +01:00
|
|
|
BSD::Control.feature(:mprotect).status(file)
|
2024-03-08 03:41:45 +01:00
|
|
|
ensure
|
|
|
|
rm(file)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def file
|
|
|
|
File.join(__dir__, "file")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|