summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-02-13 13:53:25 +0000
committerseki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-02-13 13:53:25 +0000
commit2847325f99ccc35a2c94785fb12be3726be6983f (patch)
treea774e89647dde64803437a42b4e26d6a3e5b86c1 /test
parentf19caf73002a24347cdd43f5287f060596363fbf (diff)
add safe_level, default_safe_level
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/drb/test_drb.rb15
-rw-r--r--test/drb/ut_eval.rb10
-rw-r--r--test/drb/ut_safe1.rb5
3 files changed, 25 insertions, 5 deletions
diff --git a/test/drb/test_drb.rb b/test/drb/test_drb.rb
index 6764e91..ae8ba42 100644
--- a/test/drb/test_drb.rb
+++ b/test/drb/test_drb.rb
@@ -217,7 +217,7 @@ class TestDRbEval < Test::Unit::TestCase
@ext.stop_service
end
- def test_01_safe1_eval
+ def test_01_safe1_safe4_eval
assert_raises(SecurityError) do
@there.method_missing(:instance_eval, 'ENV.inspect')
end
@@ -235,6 +235,19 @@ class TestDRbEval < Test::Unit::TestCase
assert_raises(SecurityError) do
remote_class.module_eval('ENV.inspect')
end
+
+ four = @there.four
+ assert_equal(1, four.method_missing(:send, :eval, '1'))
+
+ remote_class = four.remote_class
+
+ assert_raises(SecurityError) do
+ remote_class.class_eval('ENV.inspect')
+ end
+
+ assert_raises(SecurityError) do
+ remote_class.module_eval('ENV.inspect')
+ end
end
end
diff --git a/test/drb/ut_eval.rb b/test/drb/ut_eval.rb
index 6a81e17..4df963e 100644
--- a/test/drb/ut_eval.rb
+++ b/test/drb/ut_eval.rb
@@ -2,6 +2,14 @@ require 'drb/drb'
require 'drb/extserv'
class EvalAttack
+ def initialize
+ @four = DRb::DRbServer.new('druby://localhost:0', self, {:safe_level => 4})
+ end
+
+ def four
+ DRbObject.new_with_uri(@four.uri)
+ end
+
def remote_class
DRbObject.new(self.class)
end
@@ -17,7 +25,7 @@ if __FILE__ == $0
$SAFE = 1
- DRb.start_service('druby://localhost:0', EvalAttack.new)
+ DRb.start_service('druby://localhost:0', EvalAttack.new, {:safe_level => 2})
es = DRb::ExtServ.new(ARGV.shift, ARGV.shift)
DRb.thread.join
end
diff --git a/test/drb/ut_safe1.rb b/test/drb/ut_safe1.rb
index 761bdff..4df8e1e 100644
--- a/test/drb/ut_safe1.rb
+++ b/test/drb/ut_safe1.rb
@@ -8,9 +8,8 @@ if __FILE__ == $0
it
end
- $SAFE = 1
-
- DRb.start_service('druby://localhost:0', [1, 2, 'III', 4, "five", 6])
+ DRb.start_service('druby://localhost:0', [1, 2, 'III', 4, "five", 6],
+ {:safe_level => 1})
es = DRb::ExtServ.new(ARGV.shift, ARGV.shift)
DRb.thread.join
end