s3api: Delete all parts when aborting MPU with non-ASCII characters

Change-Id: Idcda76f7a880a18c3bac699e0fb2435e4a54abbd
This commit is contained in:
Aymeric Ducroquetz 2022-03-01 09:16:33 +01:00 committed by Tim Burke
parent 3ff3076ce6
commit 82ca37517d
2 changed files with 12 additions and 3 deletions

View File

@ -609,9 +609,10 @@ class UploadController(Controller):
# must be a multipart upload abort.
# We must delete any uploaded segments for this UploadID and then
# delete the object in the main container as well
object_name = wsgi_to_str(req.object_name)
query = {
'format': 'json',
'prefix': '%s/%s/' % (req.object_name, upload_id),
'prefix': '%s/%s/' % (object_name, upload_id),
'delimiter': '/',
}

View File

@ -29,13 +29,14 @@ from six.moves import zip, zip_longest
import test.functional as tf
from swift.common.middleware.s3api.etree import fromstring, tostring, \
Element, SubElement
from swift.common.middleware.s3api.utils import mktime
from swift.common.middleware.s3api.utils import MULTIUPLOAD_SUFFIX, mktime
from swift.common.utils import md5
from test.functional.s3api import S3ApiBase
from test.functional.s3api.s3_test_client import Connection
from test.functional.s3api.utils import get_error_code, get_error_msg, \
calculate_md5
from test.functional.swift_test_client import Connection as SwiftConnection
def setUpModule():
@ -112,7 +113,7 @@ class TestS3ApiMultiUpload(S3ApiBase):
def test_object_multi_upload(self):
bucket = 'bucket'
keys = [u'obj1\N{SNOWMAN}', 'obj2', 'obj3']
keys = [u'obj1\N{SNOWMAN}', u'obj2\N{SNOWMAN}', 'obj3']
bad_content_md5 = base64.b64encode(b'a' * 16).strip().decode('ascii')
headers = [{'Content-Type': 'foo/bar', 'x-amz-meta-baz': 'quux'},
{'Content-MD5': bad_content_md5},
@ -405,6 +406,8 @@ class TestS3ApiMultiUpload(S3ApiBase):
# Abort Multipart Uploads
# note that uploads[1] has part data while uploads[2] does not
sw_conn = SwiftConnection(tf.config)
sw_conn.authenticate()
for key, upload_id in uploads[1:]:
query = 'uploadId=%s' % upload_id
status, headers, body = \
@ -416,6 +419,11 @@ class TestS3ApiMultiUpload(S3ApiBase):
'text/html; charset=UTF-8')
self.assertTrue('content-length' in headers)
self.assertEqual(headers['content-length'], '0')
# Check if all parts have been deleted
segments = sw_conn.get_account().container(
bucket + MULTIUPLOAD_SUFFIX).files(
parms={'prefix': '%s/%s' % (key, upload_id)})
self.assertFalse(segments)
# Check object
def check_obj(req_headers, exp_status):