Commit 4bb5d14f by Ned Batchelder

Test that we can't write files

parent 9cc43f1d
"""Test jailpy.py"""
import textwrap import textwrap
import unittest import unittest
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
...@@ -53,6 +55,18 @@ class TestLimits(unittest.TestCase): ...@@ -53,6 +55,18 @@ class TestLimits(unittest.TestCase):
self.assertNotEqual(res.status, 0) self.assertNotEqual(res.status, 0)
self.assertEqual(res.stdout, "") self.assertEqual(res.stdout, "")
def test_cant_write_files(self):
res = jailpy(dedent("""\
print "Trying"
with open("mydata.txt", "w") as f:
f.write("hello")
with open("mydata.txt") as f2:
print "Got this:", f2.read()
"""))
self.assertNotEqual(res.status, 0)
self.assertEqual(res.stdout, "Trying\n")
self.assertIn("ermission denied", res.stderr)
# TODO: write files # TODO: write files
# TODO: read network # TODO: read network
# TODO: fork # TODO: fork
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment