bsdcontrol.rb/test/superuser/enable_feature_test.rb

36 lines
826 B
Ruby

require_relative "../setup"
module BSD::Control
class EnableFeatureTest < Test::Unit::TestCase
require 'fileutils'
include FileUtils
def test_enable_mprotect
touch(file)
assert BSD::Control.feature(:mprotect).enable!(file),
"The enable! method should have returned true"
ensure
rm(file)
end
def test_enable_mprotect_zero_permissions
touch(file)
chmod(0, file)
assert BSD::Control.feature(:mprotect).enable!(file),
"The enable! method should have returned true"
ensure
rm(file)
end
def test_enable_mprotect_nonexistent_file
assert_raises(BSD::Control::Error) do
BSD::Control.feature(:mprotect).enable!(file)
end
end
private
def file
File.join(__dir__, "file")
end
end
end