bsdcontrol.rb/test/superuser/sysdef_feature_test.rb

40 lines
928 B
Ruby
Raw Normal View History

2024-05-12 05:59:38 +02:00
# frozen_string_literal: true
2024-03-20 22:34:15 +01:00
require_relative "../setup"
module BSD::Control
class SysDefFeatureTest < Test::Unit::TestCase
2024-05-12 05:59:38 +02:00
require "fileutils"
2024-03-20 22:34:15 +01:00
include FileUtils
def test_sysdef_pageexec
touch(file)
assert BSD::Control.feature(:pageexec).enable!(file),
"The enable! method should have returned true"
assert_equal(
:enabled,
BSD::Control.feature(:pageexec).status(file)
2024-03-20 22:34:15 +01:00
)
assert BSD::Control.feature(:pageexec).sysdef!(file),
"The sysdef! method should have returned true"
assert_equal(
:sysdef,
BSD::Control.feature(:pageexec).status(file)
2024-03-20 22:34:15 +01:00
)
ensure
rm(file)
end
def test_enable_pageexec_nonexistent_file
assert_raises(Errno::ENOENT) do
BSD::Control.feature(:pageexec).sysdef!(file)
end
end
private
def file
File.join(__dir__, "file")
end
end
end