Test that the sandbox can't get to the network.

This commit is contained in:
Ned Batchelder
2013-02-21 15:52:37 -05:00
parent 9dbfca129c
commit c04f3e09c0

View File

@@ -96,6 +96,18 @@ class TestLimits(JailPyHelpers, unittest.TestCase):
self.assertEqual(res.stdout, "Trying\n")
self.assertIn("ermission denied", res.stderr)
def test_cant_use_network(self):
res = jailpy(dedent("""\
import urllib
print "Reading google"
u = urllib.urlopen("http://google.com")
google = u.read()
print len(google)
"""))
self.assertNotEqual(res.status, 0)
self.assertEqual(res.stdout, "Reading google\n")
self.assertIn("IOError", res.stderr)
# TODO: write files
# TODO: read network
# TODO: fork