Revision 2560c061
b/snf-pithos-app/pithos/api/functions.py | ||
---|---|---|
564 | 564 |
if (content_type |
565 | 565 |
and content_type == 'application/octet-stream' |
566 | 566 |
and content_length != 0): |
567 |
|
|
568 |
try: |
|
569 |
request.backend.can_write_container(request.user_uniq, v_account, |
|
570 |
v_container) |
|
571 |
except NotAllowedError: |
|
572 |
raise faults.Forbidden('Not allowed') |
|
573 |
|
|
567 | 574 |
for data in socket_read_iterator(request, content_length, |
568 | 575 |
request.backend.block_size): |
569 | 576 |
# TODO: Raise 408 (Request Timeout) if this takes too long. |
b/snf-pithos-app/pithos/api/test/containers.py | ||
---|---|---|
943 | 943 |
|
944 | 944 |
r = self.upload_object('c1', length=1) |
945 | 945 |
|
946 |
def test_upload_blocks(self): |
|
947 |
cname = self.create_container()[0] |
|
948 |
|
|
949 |
url = join_urls(self.pithos_path, self.user, cname) |
|
950 |
r = self.post(url, data=get_random_data()) |
|
951 |
self.assertEqual(r.status_code, 202) |
|
952 |
|
|
953 |
url = join_urls(self.pithos_path, 'chuck', cname) |
|
954 |
r = self.post(url, data=get_random_data()) |
|
955 |
self.assertEqual(r.status_code, 403) |
|
956 |
|
|
957 |
# share object for read only |
|
958 |
oname = self.upload_object(cname)[0] |
|
959 |
url = join_urls(self.pithos_path, self.user, cname, oname) |
|
960 |
self.post(url, content_type='', HTTP_CONTENT_RANGE='bytes */*', |
|
961 |
HTTP_X_OBJECT_SHARING='read=*') |
|
962 |
url = join_urls(self.pithos_path, 'chuck', cname) |
|
963 |
r = self.post(url, data=get_random_data()) |
|
964 |
self.assertEqual(r.status_code, 403) |
|
965 |
|
|
966 |
# share object for write only |
|
967 |
oname = self.upload_object(cname)[0] |
|
968 |
url = join_urls(self.pithos_path, self.user, cname, oname) |
|
969 |
self.post(url, content_type='', HTTP_CONTENT_RANGE='bytes */*', |
|
970 |
HTTP_X_OBJECT_SHARING='write=*') |
|
971 |
url = join_urls(self.pithos_path, 'chuck', cname) |
|
972 |
r = self.post(url, data=get_random_data()) |
|
973 |
self.assertEqual(r.status_code, 403) |
|
974 |
|
|
946 | 975 |
|
947 | 976 |
class ContainerDelete(PithosAPITest): |
948 | 977 |
def setUp(self): |
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
1947 | 1947 |
if user != account: |
1948 | 1948 |
raise NotAllowedError |
1949 | 1949 |
|
1950 |
def can_write_container(self, user, account, container): |
|
1951 |
return self._can_write_container(user, account, container) |
|
1952 |
|
|
1950 | 1953 |
@check_allowed_paths(action=0) |
1951 | 1954 |
def _can_read_object(self, user, account, container, name): |
1952 | 1955 |
if user == account: |
Also available in: Unified diff