mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-28 23:09:55 +00:00
Upload to non-existent place.
This commit is contained in:
parent
72bac785ee
commit
95d7548629
@ -250,8 +250,8 @@ class HTTPServer(object):
|
|||||||
try:
|
try:
|
||||||
bucket = self._uploads[storage_index].shares[share_number]
|
bucket = self._uploads[storage_index].shares[share_number]
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
# TODO return 404
|
request.setResponseCode(http.NOT_FOUND)
|
||||||
raise
|
return b""
|
||||||
|
|
||||||
finished = bucket.write(offset, data)
|
finished = bucket.write(offset, data)
|
||||||
|
|
||||||
|
@ -583,6 +583,39 @@ class ImmutableHTTPAPITests(SyncTestCase):
|
|||||||
storage_index = b"".join(bytes([i]) for i in range(16))
|
storage_index = b"".join(bytes([i]) for i in range(16))
|
||||||
self.assertEqual(result_of(im_client.list_shares(storage_index)), set())
|
self.assertEqual(result_of(im_client.list_shares(storage_index)), set())
|
||||||
|
|
||||||
|
def test_upload_non_existent_storage_index(self):
|
||||||
|
"""
|
||||||
|
Uploading to a non-existent storage index or share number results in
|
||||||
|
404.
|
||||||
|
"""
|
||||||
|
im_client = StorageClientImmutables(self.http.client)
|
||||||
|
upload_secret = urandom(32)
|
||||||
|
lease_secret = urandom(32)
|
||||||
|
storage_index = b"".join(bytes([i]) for i in range(16))
|
||||||
|
result_of(
|
||||||
|
im_client.create(
|
||||||
|
storage_index, {1}, 10, upload_secret, lease_secret, lease_secret
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def unknown_check(storage_index, share_number):
|
||||||
|
with self.assertRaises(ClientException) as e:
|
||||||
|
result_of(
|
||||||
|
im_client.write_share_chunk(
|
||||||
|
storage_index,
|
||||||
|
share_number,
|
||||||
|
upload_secret,
|
||||||
|
0,
|
||||||
|
b"0123456789",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.assertEqual(e.exception.code, http.NOT_FOUND)
|
||||||
|
|
||||||
|
# Wrong share number:
|
||||||
|
unknown_check(storage_index, 7)
|
||||||
|
# Wrong storage index:
|
||||||
|
unknown_check(b"X" * 16, 7)
|
||||||
|
|
||||||
def test_multiple_shares_uploaded_to_different_place(self):
|
def test_multiple_shares_uploaded_to_different_place(self):
|
||||||
"""
|
"""
|
||||||
If a storage index has multiple shares, uploads to different shares are
|
If a storage index has multiple shares, uploads to different shares are
|
||||||
|
Loading…
x
Reference in New Issue
Block a user