Merge "object storage: fix and cleanup header checks"
This commit is contained in:
commit
c5e33135a9
@ -16,7 +16,6 @@ import tarfile
|
||||
import tempfile
|
||||
|
||||
from tempest.api.object_storage import base
|
||||
from tempest.common import custom_matchers
|
||||
from tempest.common import utils
|
||||
from tempest.lib import decorators
|
||||
|
||||
@ -76,17 +75,7 @@ class BulkTest(base.BaseObjectTest):
|
||||
resp = self._upload_archive(filepath)
|
||||
self.containers.append(container_name)
|
||||
|
||||
# When uploading an archived file with the bulk operation, the response
|
||||
# does not contain 'content-length' header. This is the special case,
|
||||
# therefore the existence of response headers is checked without
|
||||
# custom matcher.
|
||||
self.assertIn('transfer-encoding', resp.response)
|
||||
self.assertIn('content-type', resp.response)
|
||||
self.assertIn('x-trans-id', resp.response)
|
||||
self.assertIn('date', resp.response)
|
||||
|
||||
# Check only the format of common headers with custom matcher
|
||||
self.assertThat(resp.response, custom_matchers.AreAllWellFormatted())
|
||||
self.assertHeaders(resp.response, 'Account', 'PUT')
|
||||
|
||||
param = {'format': 'json'}
|
||||
resp, body = self.account_client.list_account_containers(param)
|
||||
@ -113,17 +102,7 @@ class BulkTest(base.BaseObjectTest):
|
||||
data = '%s/%s\n%s' % (container_name, object_name, container_name)
|
||||
resp = self.bulk_client.delete_bulk_data(data=data)
|
||||
|
||||
# When deleting multiple files using the bulk operation, the response
|
||||
# does not contain 'content-length' header. This is the special case,
|
||||
# therefore the existence of response headers is checked without
|
||||
# custom matcher.
|
||||
self.assertIn('transfer-encoding', resp.response)
|
||||
self.assertIn('content-type', resp.response)
|
||||
self.assertIn('x-trans-id', resp.response)
|
||||
self.assertIn('date', resp.response)
|
||||
|
||||
# Check only the format of common headers with custom matcher
|
||||
self.assertThat(resp.response, custom_matchers.AreAllWellFormatted())
|
||||
self.assertHeaders(resp.response, 'Account', 'DELETE')
|
||||
|
||||
# Check if uploaded contents are completely deleted
|
||||
self._check_contents_deleted(container_name)
|
||||
@ -139,17 +118,7 @@ class BulkTest(base.BaseObjectTest):
|
||||
|
||||
resp = self.bulk_client.delete_bulk_data_with_post(data=data)
|
||||
|
||||
# When deleting multiple files using the bulk operation, the response
|
||||
# does not contain 'content-length' header. This is the special case,
|
||||
# therefore the existence of response headers is checked without
|
||||
# custom matcher.
|
||||
self.assertIn('transfer-encoding', resp.response)
|
||||
self.assertIn('content-type', resp.response)
|
||||
self.assertIn('x-trans-id', resp.response)
|
||||
self.assertIn('date', resp.response)
|
||||
|
||||
# Check only the format of common headers with custom matcher
|
||||
self.assertThat(resp.response, custom_matchers.AreAllWellFormatted())
|
||||
self.assertHeaders(resp.response, 'Account', 'POST')
|
||||
|
||||
# Check if uploaded contents are completely deleted
|
||||
self._check_contents_deleted(container_name)
|
||||
|
@ -17,7 +17,6 @@ import hashlib
|
||||
from oslo_serialization import jsonutils as json
|
||||
|
||||
from tempest.api.object_storage import base
|
||||
from tempest.common import custom_matchers
|
||||
from tempest.common import utils
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib.common.utils import test_utils
|
||||
@ -160,17 +159,7 @@ class ObjectSloTest(base.BaseObjectTest):
|
||||
object_name,
|
||||
params=params_del)
|
||||
|
||||
# When deleting SLO using multipart manifest, the response contains
|
||||
# not 'content-length' but 'transfer-encoding' header. This is the
|
||||
# special case, therefore the existence of response headers is checked
|
||||
# outside of custom matcher.
|
||||
self.assertIn('transfer-encoding', resp)
|
||||
self.assertIn('content-type', resp)
|
||||
self.assertIn('x-trans-id', resp)
|
||||
self.assertIn('date', resp)
|
||||
|
||||
# Check only the format of common headers with custom matcher
|
||||
self.assertThat(resp, custom_matchers.AreAllWellFormatted())
|
||||
self.assertHeaders(resp, 'Object', 'DELETE')
|
||||
|
||||
resp, body = self.container_client.list_container_objects(
|
||||
self.container_name)
|
||||
|
@ -62,8 +62,9 @@ class ExistsAllResponseHeaders(object):
|
||||
# [1] https://bugs.launchpad.net/swift/+bug/1537811
|
||||
# [2] http://tracker.ceph.com/issues/13582
|
||||
if ('content-length' not in actual and
|
||||
'transfer-encoding' not in actual and
|
||||
self._content_length_required(actual)):
|
||||
return NonExistentHeader('content-length')
|
||||
return NonExistentHeaders(['content-length', 'transfer-encoding'])
|
||||
if 'content-type' not in actual:
|
||||
return NonExistentHeader('content-type')
|
||||
if 'x-trans-id' not in actual:
|
||||
@ -192,6 +193,19 @@ class NonExistentHeader(object):
|
||||
return {}
|
||||
|
||||
|
||||
class NonExistentHeaders(object):
|
||||
"""Informs an error message in the case of missing certain headers"""
|
||||
|
||||
def __init__(self, headers):
|
||||
self.headers = headers
|
||||
|
||||
def describe(self):
|
||||
return "none of these headers exist: %s" % self.headers
|
||||
|
||||
def get_details(self):
|
||||
return {}
|
||||
|
||||
|
||||
class InvalidHeaderValue(object):
|
||||
"""Informs an error message when a header contains a bad value"""
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user