def test_list_object_metadata_with_x_object_manifest(self):
        """Test getting object metadata with x_object_manifest"""
        # uploading segments
        object_name, _ = self._upload_segments()
        # creating a manifest file
        object_prefix = '%s/%s' % (self.container_name, object_name)
        metadata = {'X-Object-Manifest': object_prefix}
        data_empty = ''
        resp, _ = self.object_client.create_object(self.container_name,
                                                   object_name,
                                                   data_empty,
                                                   metadata=metadata)

        resp, _ = self.object_client.list_object_metadata(
            self.container_name, object_name)

        # Check only the existence of common headers with custom matcher
        self.assertThat(
            resp, custom_matchers.ExistsAllResponseHeaders('Object', 'HEAD'))
        self.assertIn('x-object-manifest', resp)

        # Etag value of a large object is enclosed in double-quotations.
        # This is a special case, therefore the formats of response headers
        # are checked without a custom matcher.
        self.assertTrue(resp['etag'].startswith('\"'))
        self.assertTrue(resp['etag'].endswith('\"'))
        self.assertTrue(resp['etag'].strip('\"').isalnum())
        self.assertTrue(re.match(r"^\d+\.?\d*\Z", resp['x-timestamp']))
        self.assertNotEmpty(resp['content-type'])
        self.assertTrue(
            re.match("^tx[0-9a-f]{21}-[0-9a-f]{10}.*", resp['x-trans-id']))
        self.assertNotEmpty(resp['date'])
        self.assertEqual(resp['accept-ranges'], 'bytes')
        self.assertEqual(resp['x-object-manifest'],
                         '%s/%s' % (self.container_name, object_name))
示例#2
0
文件: base.py 项目: kakawxy/tempest
    def assertHeaders(self, resp, target, method):
        """Check the existence and the format of response headers"""

        self.assertThat(
            resp,
            custom_matchers.ExistsAllResponseHeaders(target, method,
                                                     self.policies))
        self.assertThat(resp, custom_matchers.AreAllWellFormatted())
示例#3
0
    def test_get_object_with_x_object_manifest(self):
        # get object with x_object_manifest

        # uploading segments
        object_name, data_segments = self._upload_segments()
        # creating a manifest file
        object_prefix = '%s/%s' % (self.container_name, object_name)
        metadata = {'X-Object-Manifest': object_prefix}
        data_empty = ''
        resp, body = self.object_client.create_object(
            self.container_name,
            object_name,
            data_empty,
            metadata=metadata)

        resp, body = self.object_client.get_object(
            self.container_name,
            object_name,
            metadata=None)

        # Check only the existence of common headers with custom matcher
        self.assertThat(resp, custom_matchers.ExistsAllResponseHeaders(
                        'Object', 'GET'))
        self.assertIn('x-object-manifest', resp)

        # Etag value of a large object is enclosed in double-quotations.
        # This is a special case, therefore the formats of response headers
        # are checked without a custom matcher.
        #Bug = 1417462
        #self.assertTrue(resp['etag'].startswith('\"'))
        #self.assertTrue(resp['etag'].endswith('\"'))
        self.assertTrue(resp['etag'].isalnum())
        #self.assertTrue(re.match("^\d+\.?\d*\Z", resp['x-timestamp']))
        self.assertNotEqual(len(resp['content-type']), 0)
        #self.assertTrue(re.match("^tx[0-9a-f]*-[0-9a-f]*$",
        #                         resp['x-trans-id']))
        self.assertNotEqual(len(resp['date']), 0)
        self.assertEqual(resp['accept-ranges'], 'bytes')
        self.assertEqual(resp['x-object-manifest'],
                         '%s/%s' % (self.container_name, object_name))

        self.assertEqual(''.join(data_segments), body)