diff options
Diffstat (limited to 'tests/test_nsjail.py')
-rw-r--r-- | tests/test_nsjail.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py index 456046b..c701d3a 100644 --- a/tests/test_nsjail.py +++ b/tests/test_nsjail.py @@ -227,6 +227,29 @@ class NsJailTests(unittest.TestCase): ) self.assertEqual(result.stderr, None) + def test_file_parsing_depth_limit(self): + code = dedent( + """ + import os + + x = "" + for _ in range(1000): + x += "a/" + os.mkdir(x) + + open(f"{x}test.txt", "w").write("test") + """ + ).strip() + + nsjail = NsJail(memfs_instance_size=32 * Size.MiB, files_timeout=5) + result = nsjail.python3(["-c", code]) + self.assertEqual(result.returncode, None) + self.assertEqual( + result.stdout, + "FileParsingError: Exceeded directory depth limit while parsing attachments", + ) + self.assertEqual(result.stderr, None) + def test_file_write_error(self): """Test errors during file write.""" result = self.nsjail.python3( |