def test_not_allowed(self): self.view_path = join_urls( get_service_path(pithos_settings.pithos_services, 'pithos_ui'), 'view') self.view_url = join_urls(self.view_path, self.user, get_random_name(), get_random_name()) r = self.delete(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.post(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.put(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.copy(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.move(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD'])
def test_not_allowed(self): self.view_path = join_urls(get_service_path( pithos_settings.pithos_services, 'pithos_ui'), 'view') self.view_url = join_urls(self.view_path, self.user, get_random_name(), get_random_name()) r = self.delete(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.post(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.put(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.copy(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.move(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD'])
def update_object_meta(self, container, object, meta=None, user=None, verify_status=True): user = user or self.user meta = meta or {get_random_name(): get_random_name()} kwargs = dict( ('HTTP_X_OBJECT_META_%s' % k, str(v)) for k, v in meta.items()) url = join_urls(self.pithos_path, user, container, object) r = self.post('%s?update=' % url, user=user, content_type='', **kwargs) if verify_status: self.assertEqual(r.status_code, 202) object_meta = self.get_object_meta(container, object, user=user) (self.assertTrue('X-Objecr-Meta-%s' % k in object_meta) for k in meta.keys()) (self.assertEqual(object_meta['X-Object-Meta-%s' % k], v) for k, v in meta.items()) return r
def test_public_manifest(self): cname = self.create_container()[0] prefix = 'myobject/' data = '' for i in range(random.randint(2, 10)): part = '%s%d' % (prefix, i) data += self.upload_object(cname, oname=part)[1] manifest = '%s/%s' % (cname, prefix) oname = get_random_name() url = join_urls(self.pithos_path, self.user, cname, oname) r = self.put(url, data='', HTTP_X_OBJECT_MANIFEST=manifest, HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 201) r = self.head(url) self.assertTrue('X-Object-Manifest' in r) self.assertEqual(r['X-Object-Manifest'], manifest) self.assertTrue('X-Object-Public' in r) public = r['X-Object-Public'] r = self.get(public) self.assertTrue(r.content, data)
def test_public_if_modified_sinse(self): cname = get_random_name() self.create_container(cname) oname, odata = self.upload_object(cname)[:-1] self._assert_not_public_object(cname, oname) # set public url = join_urls(self.pithos_path, self.user, cname, oname) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) info = self.get_object_info(cname, oname) public = info['X-Object-Public'] object_info = self.get_object_info(cname, oname) last_modified = object_info['Last-Modified'] t1 = datetime.datetime.strptime(last_modified, DATE_FORMATS[-1]) t1_formats = map(t1.strftime, DATE_FORMATS) for t in t1_formats: r = self.get(public, user='******', HTTP_IF_MODIFIED_SINCE=t, token=None) self.assertEqual(r.status_code, 304) _time.sleep(1) # update object data appended_data = self.append_object_data(cname, oname)[1] # Check modified since for t in t1_formats: r = self.get(public, user='******', HTTP_IF_MODIFIED_SINCE=t, token=None) self.assertEqual(r.status_code, 200) self.assertEqual(r.content, odata + appended_data)
def update_object_data(self, cname, oname=None, length=None, content_type=None, content_range=None, verify_status=True, user=None, **meta): oname = oname or get_random_name() length = length or random.randint(TEST_BLOCK_SIZE, 2 * TEST_BLOCK_SIZE) content_type = content_type or 'application/octet-stream' user = user or self.user data = get_random_data(length=length) headers = dict(('HTTP_X_OBJECT_META_%s' % k.upper(), v) for k, v in meta.iteritems()) if content_range: headers['HTTP_CONTENT_RANGE'] = content_range url = join_urls(self.pithos_path, user, cname, oname) r = self.post(url, user=user, data=data, content_type=content_type, **headers) if verify_status: self.assertEqual(r.status_code, 204) return oname, data, r
def update_container_meta(self, container, meta=None, user=None, verify_status=True): user = user or self.user meta = meta or {get_random_name(): get_random_name()} kwargs = dict( ('HTTP_X_CONTAINER_META_%s' % k, str(v)) for k, v in meta.items()) url = join_urls(self.pithos_path, user, container) r = self.post('%s?update=' % url, user=user, **kwargs) if verify_status: self.assertEqual(r.status_code, 202) container_meta = self.get_container_meta(container, user=user) (self.assertTrue('X-Container-Meta-%s' % k in container_meta) for k in meta.keys()) (self.assertEqual(container_meta['X-Container-Meta-%s' % k], v) for k, v in meta.items()) return r
def test_set_unset_set(self): cname = get_random_name() self.create_container(cname) oname, odata = self.upload_object(cname)[:-1] self._assert_not_public_object(cname, oname) # set public url = join_urls(self.pithos_path, self.user, cname, oname) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) public = self._assert_public_object(cname, oname, odata) # unset public url = join_urls(self.pithos_path, self.user, cname, oname) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='false') self.assertEqual(r.status_code, 202) self._assert_not_public_object(cname, oname) # set public url = join_urls(self.pithos_path, self.user, cname, oname) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) public2 = self._assert_public_object(cname, oname, odata) self.assertTrue(public != public2) # unset public url = join_urls(self.pithos_path, self.user, cname, oname) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='false') self.assertEqual(r.status_code, 202) self._assert_not_public_object(cname, oname)
def test_multiple_inheritance(self): cname = self.container folder = self.create_folder(cname, HTTP_X_OBJECT_SHARING='write=*')[0] subfolder = self.create_folder(cname, '%s/%s' % (folder, get_random_name()))[0] self.upload_object(cname, '%s/%s' % (subfolder, get_random_name())) self._assert_read(subfolder, self.users) self._assert_write(subfolder, self.users) # share object for read only url = join_urls(self.pithos_path, self.user, cname, subfolder) self.post(url, content_type='', HTTP_CONTENT_RANGE='bytes */*', HTTP_X_OBJECT_SHARING='read=*') self._assert_read(subfolder, self.users) self._assert_write(subfolder, [])
def create_container(self, cname=None, user=None, verify_status=True): cname = cname or get_random_name() user = user or self.user url = join_urls(self.pithos_path, user, cname) r = self.put(url, user=user, data='') if verify_status: self.assertTrue(r.status_code in (202, 201)) return cname, r
def create_folder(self, cname, oname=None, user=None, verify_status=True, **headers): user = user or self.user oname = oname or get_random_name() url = join_urls(self.pithos_path, user, cname, oname) r = self.put(url, user=user, data='', content_type='application/directory', **headers) if verify_status: self.assertEqual(r.status_code, 201) return oname, r
def create_container(self, cname=None, user=None, verify_status=True, meta=None): meta = meta or {} cname = cname or get_random_name() user = user or self.user url = join_urls(self.pithos_path, user, cname) kwargs = dict( ('HTTP_X_CONTAINER_META_%s' % k, str(v)) for k, v in meta.items()) r = self.put(url, user=user, data='', **kwargs) if verify_status: self.assertTrue(r.status_code in (202, 201)) return cname, r
def upload_object(self, cname, oname=None, length=None, verify_status=True, user=None, **meta): oname = oname or get_random_name() length = length or random.randint(TEST_BLOCK_SIZE, 2 * TEST_BLOCK_SIZE) user = user or self.user data = get_random_data(length=length) headers = dict(('HTTP_X_OBJECT_META_%s' % k.upper(), v) for k, v in meta.iteritems()) url = join_urls(self.pithos_path, user, cname, oname) r = self.put(url, user=user, data=data, **headers) if verify_status: self.assertEqual(r.status_code, 201) return oname, data, r
def test_public_if_match_precondition_failed(self): cname = self.create_container()[0] oname, odata = self.upload_object(cname)[:-1] # set public url = join_urls(self.pithos_path, self.user, cname, oname) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) info = self.get_object_info(cname, oname) public_url = info['X-Object-Public'] # perform get with If-Match r = self.get(public_url, HTTP_IF_MATCH=get_random_name()) self.assertEqual(r.status_code, 412)
def test_delete_public_object(self): cname = get_random_name() self.create_container(cname) oname, odata = self.upload_object(cname)[:-1] self._assert_not_public_object(cname, oname) # set public url = join_urls(self.pithos_path, self.user, cname, oname) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) public = self._assert_public_object(cname, oname, odata) # delete object r = self.delete(url) self.assertEqual(r.status_code, 204) r = self.get(url) self.assertEqual(r.status_code, 404) r = self.get(public) self.assertEqual(r.status_code, 404)
def setUp(self): PithosAPITest.setUp(self) # create a group self.users = ['alice', 'bob', 'chuck', 'dan', 'mallory', 'oscar'] self.groups = {'group1': self.users[:2]} kwargs = dict(('HTTP_X_ACCOUNT_GROUP_%s' % k.upper(), ','.join(v)) for k, v in self.groups.items()) url = join_urls(self.pithos_path, self.user) r = self.post(url, **kwargs) self.assertEqual(r.status_code, 202) self.container = get_random_name() self.create_container(self.container) self.object = self.upload_object(self.container)[0] l = [self.object + '/', self.object + '/a', self.object + 'a', self.object + 'a/'] for i in l: self.upload_object(self.container, i)
def setUp(self): PithosAPITest.setUp(self) # create a group self.users = ['alice', 'bob', 'chuck', 'dan', 'mallory', 'oscar'] self.groups = {'group1': self.users[:2]} kwargs = dict(('HTTP_X_ACCOUNT_GROUP_%s' % k.upper(), ','.join(v)) for k, v in self.groups.items()) url = join_urls(self.pithos_path, self.user) r = self.post(url, **kwargs) self.assertEqual(r.status_code, 202) self.container = get_random_name() self.create_container(self.container) self.object = self.upload_object(self.container)[0] l = [ self.object + '/', self.object + '/a', self.object + 'a', self.object + 'a/' ] for i in l: self.upload_object(self.container, i)
def test_public_if_modified_sinse(self): cname = get_random_name() self.create_container(cname) oname, odata = self.upload_object(cname)[:-1] self._assert_not_public_object(cname, oname) # set public url = join_urls(self.pithos_path, self.user, cname, oname) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) info = self.get_object_info(cname, oname) public = info['X-Object-Public'] object_info = self.get_object_info(cname, oname) last_modified = object_info['Last-Modified'] t1 = datetime.datetime.strptime(last_modified, DATE_FORMATS[-1]) t1_formats = map(t1.strftime, DATE_FORMATS) for t in t1_formats: r = self.get(public, user='******', HTTP_IF_MODIFIED_SINCE=t, token=None) self.assertEqual(r.status_code, 304) _time.sleep(1) # update object data appended_data = self.append_object_data(cname, oname)[1] # Check modified since for t in t1_formats: r = self.get(public, user='******', HTTP_IF_MODIFIED_SINCE=t, token=None) self.assertEqual(r.status_code, 200) self.assertEqual("".join(r.streaming_content), odata + appended_data)
def test_objects_with_trailing_spaces(self): cname = self.cname r = self.view(quote('%s ' % self.view_url)) self.assertEqual(r.status_code, 404) # delete object self.delete(self.api_url) r = self.view(self.view_url) self.assertEqual(r.status_code, 404) # upload object with trailing space oname = self.upload_object(cname, quote('%s ' % get_random_name()))[0] view_url = join_urls(self.view_path, self.user, cname, oname) r = self.view(view_url) self.assertEqual(r.status_code, 200) view_url = join_urls(self.view_path, self.user, cname, oname[:-1]) r = self.view(view_url) self.assertEqual(r.status_code, 404)
def test_delete_public_object_history(self): cname = get_random_name() self.create_container(cname) oname, odata = self.upload_object(cname)[:-1] self._assert_not_public_object(cname, oname) # set public url = join_urls(self.pithos_path, self.user, cname, oname) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) public = self._assert_public_object(cname, oname, odata) for _ in range(random.randint(1, 10)): odata += self.append_object_data(cname, oname)[1] _time.sleep(1) # get object versions url = join_urls(self.pithos_path, self.user, cname, oname) r = self.get('%s?version=list&format=json' % url) version_list = json.loads(r.content)['versions'] mtime = [int(float(t[1])) for t in version_list] # delete object history i = random.randrange(len(mtime)) self.delete('%s?until=%d' % (url, mtime[i])) public2 = self._assert_public_object(cname, oname, odata) self.assertEqual(public, public2) # delete object history until now _time.sleep(1) t = datetime.datetime.utcnow() now = int(_time.mktime(t.timetuple())) r = self.delete('%s?intil=%d' % (url, now)) self.assertEqual(r.status_code, 204) r = self.get(url) self.assertEqual(r.status_code, 404) r = self.get(public) self.assertEqual(r.status_code, 404)
def test_if_match_precondition_failed(self): r = self.view(self.view_url, HTTP_IF_MATCH=get_random_name()) self.assertEqual(r.status_code, 412)
def test_list_shared_public(self): cname = self.cnames[0] container_url = join_urls(self.pithos_path, self.user, cname) onames = self.objects[cname].keys() r = self.get('%s?shared=&public=&format=json' % container_url) self.assertEqual(r.status_code, 200) objects = json.loads(r.content) self.assertEqual(len(objects), 0) # publish an object public1 = onames.pop() url = join_urls(container_url, public1) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) r = self.get('%s?shared=&public=&format=json' % container_url) self.assertEqual(r.status_code, 200) objects = json.loads(r.content) self.assertEqual(len(objects), 1) self.assertEqual(objects[0]['name'], public1) self.assertEqual(objects[0]['bytes'], len(self.objects[cname][public1])) self.assertTrue('x_object_public' in objects[0]) # publish another public2 = onames.pop() url = join_urls(container_url, public2) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) # share an object shared1 = onames.pop() url = join_urls(container_url, shared1) r = self.post(url, content_type='', HTTP_X_OBJECT_SHARING='read=alice') self.assertEqual(r.status_code, 202) # share another shared2 = onames.pop() url = join_urls(container_url, shared2) r = self.post(url, content_type='', HTTP_X_OBJECT_SHARING='read=alice') self.assertEqual(r.status_code, 202) # list shared and public objects and assert object is listed r = self.get('%s?shared=&public=&format=json' % container_url) self.assertEqual(r.status_code, 200) objects = json.loads(r.content) l = sorted([public1, public2, shared1, shared2]) i = 0 for name in l: self.assertEqual(objects[i]['name'], name) self.assertEqual(objects[i]['bytes'], len(self.objects[cname][name])) self.assertTrue('x_object_sharing' in objects[i] or 'x_object_public' in objects[i]) i += 1 # assert not listing shared and public to a not shared user r = self.get('%s?shared=&public=&format=json' % container_url, user='******') self.assertEqual(r.status_code, 403) # assert not listing public to a shared user r = self.get('%s?shared=&public=&format=json' % container_url, user='******') self.assertEqual(r.status_code, 403) # create child object descendant = strnextling(public1) self.upload_object(cname, descendant) # request public and assert child object is not listed r = self.get('%s?shared=&public=' % container_url) objects = r.content.split('\n') if '' in objects: objects.remove('') self.assertEqual(r.status_code, 200) self.assertEqual(objects, l) # test folder inheritance folder, _ = self.create_folder(cname, HTTP_X_OBJECT_PUBLIC='true') # create child object descendant = '%s/%s' % (folder, get_random_name()) self.upload_object(cname, descendant) # request public r = self.get('%s?shared=&public=' % container_url) self.assertEqual(r.status_code, 200) objects = r.content.split('\n') if '' in objects: objects.remove('') self.assertTrue(folder in objects) self.assertTrue(descendant not in objects) # unpublish public1 url = join_urls(container_url, public1) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='false') self.assertEqual(r.status_code, 202) # unpublish public2 url = join_urls(container_url, public2) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='false') self.assertEqual(r.status_code, 202) # unpublish folder url = join_urls(container_url, folder) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='false') self.assertEqual(r.status_code, 202) r = self.get('%s?shared=&public=' % container_url) self.assertEqual(r.status_code, 200) objects = r.content.split('\n') if '' in objects: objects.remove('') l = sorted([shared1, shared2]) self.assertEqual(objects, l)
def test_list_public(self): cname = self.cnames[0] onames = self.objects[cname].keys() # publish an object public1 = onames.pop() url = join_urls(self.pithos_path, self.user, cname, public1) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) # publish another public2 = onames.pop() url = join_urls(self.pithos_path, self.user, cname, public2) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) # share an object shared1 = onames.pop() url = join_urls(self.pithos_path, self.user, cname, shared1) r = self.post(url, content_type='', HTTP_X_OBJECT_SHARING='read=alice') self.assertEqual(r.status_code, 202) # share another shared2 = onames.pop() url = join_urls(self.pithos_path, self.user, cname, shared2) r = self.post(url, content_type='', HTTP_X_OBJECT_SHARING='read=alice') self.assertEqual(r.status_code, 202) # list public and assert only the public object is returned url = join_urls(self.pithos_path, self.user, cname) r = self.get('%s?public=' % url) self.assertEqual(r.status_code, 200) objects = r.content.split('\n') if '' in objects: objects.remove('') self.assertEqual(sorted([public1, public2]), objects) # list detailed public and assert only the public object is returned url = join_urls(self.pithos_path, self.user, cname) r = self.get('%s?public=&format=json' % url) self.assertEqual(r.status_code, 200) try: objects = json.loads(r.content) except: self.fail('json format expected') l = sorted([public1, public2]) i = 0 for name in l: self.assertEqual(objects[i]['name'], name) self.assertEqual(objects[i]['bytes'], len(self.objects[cname][name])) self.assertTrue('x_object_sharing' not in objects[i]) self.assertTrue('x_object_public' in objects[i]) i += 1 # share the public object and assert it is still listed in the # public objects url = join_urls(self.pithos_path, self.user, cname, public1) r = self.post(url, content_type='', HTTP_X_OBJECT_SHARING='read=alice') self.assertEqual(r.status_code, 202) url = join_urls(self.pithos_path, self.user, cname) r = self.get('%s?public=&format=json' % url) self.assertEqual(r.status_code, 200) try: objects = json.loads(r.content) except: self.fail('json format expected') i = 0 for name in l: self.assertEqual(objects[i]['name'], name) self.assertEqual(objects[i]['bytes'], len(self.objects[cname][name])) if name == public1: self.assertTrue('x_object_sharing' in objects[i]) else: self.assertTrue('x_object_sharing' not in objects[i]) i += 1 url = join_urls(self.pithos_path, self.user, cname) # Assert listing the container public contents is forbidden to not # shared users r = self.get('%s?public=&format=json' % url, user='******') self.assertEqual(r.status_code, 403) # Assert forbidden public object listing to shared users r = self.get('%s?public=&format=json' % url, user='******') self.assertEqual(r.status_code, 403) # create child object descendant = strnextling(public1) self.upload_object(cname, descendant) # request public and assert child obejct is not listed r = self.get('%s?public=' % url) objects = r.content.split('\n') if '' in objects: objects.remove('') self.assertEqual(r.status_code, 200) self.assertTrue(public1 in objects) self.assertTrue(descendant not in objects) # test folder inheritance folder, _ = self.create_folder(cname, HTTP_X_OBJECT_PUBLIC='true') # create child object descendant = '%s/%s' % (folder, get_random_name()) self.upload_object(cname, descendant) # request public r = self.get('%s?public=' % url) self.assertEqual(r.status_code, 200) objects = r.content.split('\n') self.assertTrue(folder in objects) self.assertTrue(descendant not in objects)
def test_list_shared(self): # share an object cname = self.cnames[0] onames = self.objects[cname].keys() shared1 = onames.pop() url = join_urls(self.pithos_path, self.user, cname, shared1) r = self.post(url, content_type='', HTTP_X_OBJECT_SHARING='read=*') self.assertEqual(r.status_code, 202) # share another object shared2 = onames.pop() url = join_urls(self.pithos_path, self.user, cname, shared2) r = self.post(url, content_type='', HTTP_X_OBJECT_SHARING='read=*') self.assertEqual(r.status_code, 202) # publish another object public1 = onames.pop() url = join_urls(self.pithos_path, self.user, cname, public1) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) # publish another object public2 = onames.pop() url = join_urls(self.pithos_path, self.user, cname, public2) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) # list shared and assert only the shared object is returned url = join_urls(self.pithos_path, self.user, cname) r = self.get('%s?shared=' % url) self.assertEqual(r.status_code, 200) objects = r.content.split('\n') if '' in objects: objects.remove('') self.assertEqual(sorted([shared1, shared2]), objects) # list detailed shared and assert only the shared object is returned url = join_urls(self.pithos_path, self.user, cname) r = self.get('%s?shared=&format=json' % url) self.assertEqual(r.status_code, 200) try: objects = json.loads(r.content) except: self.fail('json format expected') l = sorted([shared1, shared2]) i = 0 for name in l: self.assertEqual(objects[i]['name'], name) self.assertEqual(objects[i]['bytes'], len(self.objects[cname][name])) self.assertTrue('x_object_sharing' in objects[i]) self.assertTrue('x_object_public' not in objects[i]) i += 1 # publish the shared object and assert it is still listed in the # shared objects url = join_urls(self.pithos_path, self.user, cname, shared1) r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true') self.assertEqual(r.status_code, 202) url = join_urls(self.pithos_path, self.user, cname) r = self.get('%s?shared=&format=json' % url) self.assertEqual(r.status_code, 200) try: objects = json.loads(r.content) except: self.fail('json format expected') i = 0 for name in l: self.assertEqual(objects[i]['name'], name) self.assertEqual(objects[i]['bytes'], len(self.objects[cname][name])) self.assertTrue('x_object_sharing' in objects[i]) if name == shared1: self.assertTrue('x_object_public' in objects[i]) else: self.assertTrue('x_object_public' not in objects[i]) i += 1 # create child object descendant = strnextling(shared1) self.upload_object(cname, descendant) # request shared and assert child obejct is not listed url = join_urls(self.pithos_path, self.user, cname) r = self.get('%s?shared=' % url) self.assertEqual(r.status_code, 200) objects = r.content.split('\n') if '' in objects: objects.remove('') self.assertTrue(shared1 in objects) self.assertTrue(descendant not in objects) # check folder inheritance folder, _ = self.create_folder(cname, HTTP_X_OBJECT_SHARING='read=*') # create child object descendant = '%s/%s' % (folder, get_random_name()) self.upload_object(cname, descendant) # request shared url = join_urls(self.pithos_path, self.user, cname) r = self.get('%s?shared=' % url) self.assertEqual(r.status_code, 200) objects = r.content.split('\n') if '' in objects: objects.remove('') self.assertTrue(folder in objects) self.assertTrue(descendant in objects)