bsdcapsicum.rb/test/capsicum_test.rb

42 lines
838 B
Ruby
Raw Normal View History

# frozen_string_literal: true
require "test_helper"
2017-05-24 02:18:05 +02:00
2024-06-25 08:25:53 +02:00
class BSD::Capsicum::Test < Minitest::Test
2017-05-24 02:18:05 +02:00
def test_that_it_has_a_version_number
2024-06-25 08:25:53 +02:00
refute_nil BSD::Capsicum::VERSION
2017-05-24 02:18:05 +02:00
end
2024-06-25 08:25:53 +02:00
def test_in_capability_mode_default
assert_equal false, BSD::Capsicum.in_capability_mode?
end
2017-05-24 02:18:47 +02:00
2024-06-25 08:25:53 +02:00
def test_capability_mode_ecapmode
ch = xchan(:marshal)
fork do
BSD::Capsicum.enter!
2024-06-25 03:36:15 +02:00
File.new(File::NULL)
2024-06-25 08:25:53 +02:00
rescue Errno::ECAPMODE => ex
ch.send(ex)
2017-05-24 02:18:47 +02:00
end
2024-06-25 08:25:53 +02:00
Process.wait
assert_equal Errno::ECAPMODE, ch.recv.class
ensure
ch.close
end
2017-05-24 02:18:47 +02:00
2024-06-25 08:25:53 +02:00
def test_capability_mode_with_shell_command
ch = xchan(:marshal)
fork do
BSD::Capsicum.enter!
`ls`
rescue Errno::ENOENT => ex
ch.send(ex)
2017-05-24 02:18:47 +02:00
end
2024-06-25 08:25:53 +02:00
Process.wait
assert_equal Errno::ENOENT, ch.recv.class
ensure
ch.close
2017-05-24 02:18:05 +02:00
end
end