Add more testcases
This commit is contained in:
parent
ecf0395a2f
commit
05a5f3c8af
4 changed files with 45 additions and 5 deletions
|
@ -2,10 +2,11 @@
|
|||
set -e
|
||||
if [ $(id -u) = 0 ]; then
|
||||
rake clean clobber compile
|
||||
rm -rf tmp/
|
||||
for file in test/superuser/*_test.rb; do
|
||||
ruby -Ilib ${file} --no-use-color
|
||||
done
|
||||
else
|
||||
echo "You must be root to run superuser tests."
|
||||
echo "You must be the root user to run these tests."
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
rake clean clobber compile
|
||||
for file in test/unprivileged/*_test.rb; do
|
||||
ruby -Ilib ${file} --no-use-color
|
||||
done
|
||||
else
|
||||
echo "You must be an unprivileged user to run these tests."
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -12,6 +12,15 @@ module BSD::Control
|
|||
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)
|
||||
|
|
25
test/unprivileged/enable_feature_test.rb
Normal file
25
test/unprivileged/enable_feature_test.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require_relative "../setup"
|
||||
module BSD::Control
|
||||
class EnableFeatureTest < Test::Unit::TestCase
|
||||
require "fileutils"
|
||||
include FileUtils
|
||||
|
||||
def test_enable_feature_lacks_privileges
|
||||
touch(file)
|
||||
assert_raises(
|
||||
BSD::Control::Error,
|
||||
"This operation requires root privileges."
|
||||
) do
|
||||
BSD::Control.feature!(:mprotect).enable!(file)
|
||||
end
|
||||
ensure
|
||||
rm(file)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def file
|
||||
File.join(__dir__, "file")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue