summaryrefslogtreecommitdiff
path: root/testing/tests/blobs/test_fs_backend.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/tests/blobs/test_fs_backend.py')
-rw-r--r--testing/tests/blobs/test_fs_backend.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/testing/tests/blobs/test_fs_backend.py b/testing/tests/blobs/test_fs_backend.py
index 0d7e9789..f6f2db2d 100644
--- a/testing/tests/blobs/test_fs_backend.py
+++ b/testing/tests/blobs/test_fs_backend.py
@@ -99,9 +99,24 @@ class FilesystemBackendTestCase(unittest.TestCase):
self.assertEquals(result, ['blob_0', 'blob_1'])
@pytest.mark.usefixtures("method_tmpdir")
- def test_path_validation_for_subdirectories(self):
+ def test_path_validation_on_read_blob(self):
blobs_path = self.tempdir
backend = _blobs.FilesystemBlobsBackend(blobs_path)
- self.assertFalse(backend._valid_subdir('/'))
- self.assertFalse(backend._valid_subdir(blobs_path + '../../../../../'))
- self.assertTrue(backend._valid_subdir(os.path.join(blobs_path, 'x')))
+ with pytest.raises(Exception):
+ backend.read_blob('..', '..', DummyRequest(['']))
+ with pytest.raises(Exception):
+ backend.read_blob('valid', '../../../', DummyRequest(['']))
+ with pytest.raises(Exception):
+ backend.read_blob('../../../', 'valid', DummyRequest(['']))
+
+ @pytest.mark.usefixtures("method_tmpdir")
+ @defer.inlineCallbacks
+ def test_path_validation_on_write_blob(self):
+ blobs_path = self.tempdir
+ backend = _blobs.FilesystemBlobsBackend(blobs_path)
+ with pytest.raises(Exception):
+ yield backend.write_blob('..', '..', DummyRequest(['']))
+ with pytest.raises(Exception):
+ yield backend.write_blob('valid', '../../../', DummyRequest(['']))
+ with pytest.raises(Exception):
+ yield backend.write_blob('../../../', 'valid', DummyRequest(['']))