Test and document what happens for non-existent storage index.

This commit is contained in:
Itamar Turner-Trauring 2022-02-01 10:41:12 -05:00
parent 35bbcad4de
commit 70d0bd0597
3 changed files with 11 additions and 2 deletions

View File

@ -635,6 +635,9 @@ indicated storage index. For example::
[1, 5]
An unknown storage index results in empty list, so that lack of existence of
storage index is not leaked.
``GET /v1/immutable/:storage_index/:share_number``
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

View File

@ -266,8 +266,6 @@ class HTTPServer(object):
List shares for the given storage index.
"""
storage_index = si_a2b(storage_index.encode("ascii"))
# TODO in future ticket, handle KeyError as 404
share_numbers = list(self._storage_server.get_buckets(storage_index).keys())
return self._cbor(request, share_numbers)

View File

@ -413,6 +413,14 @@ class ImmutableHTTPAPITests(SyncTestCase):
# Now shares 1 and 3 exist:
self.assertEqual(result_of(im_client.list_shares(storage_index)), {1, 3})
def test_list_shares_unknown_storage_index(self):
"""
Listing unknown storage index's shares results in empty list of shares.
"""
im_client = StorageClientImmutables(self.http.client)
storage_index = b"".join(bytes([i]) for i in range(16))
self.assertEqual(result_of(im_client.list_shares(storage_index)), set())
def test_multiple_shares_uploaded_to_different_place(self):
"""
If a storage index has multiple shares, uploads to different shares are