Jimmyweng006 commented on code in PR #8506:
URL: https://github.com/apache/ozone/pull/8506#discussion_r2105879827
##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestMultipartUploadComplete.java:
##########
@@ -266,4 +270,96 @@ public void testMultipartInvalidPartError() throws
Exception {
() -> completeMultipartUpload(key, completeMultipartUploadRequest,
uploadID));
assertEquals(ex.getCode(), S3ErrorTable.INVALID_PART.getCode());
}
+
+ @Test
+ public void testMultipartCompleteWithEtagMismatchShouldAbortAndThrow()
throws Exception {
+ // Arrange
+ String key = UUID.randomUUID().toString();
+ String uploadID = initiateMultipartUpload(key);
+ CompleteMultipartUploadRequest completeMultipartUploadRequest =
+ buildCompleteMultipartUploadRequest(key, uploadID);
+
+ // Mock headers to return a mismatched etag
+ HttpHeaders etagHeaders = mock(HttpHeaders.class);
+ String fakeMd5Hex = "deadbeefdeadbeefdeadbeefdeadbeef";
+ byte[] fakeMd5Bytes = Hex.decodeHex(fakeMd5Hex);
+ String encodedEtag = Base64.getEncoder().encodeToString(fakeMd5Bytes);
+ when(etagHeaders.getHeaderString(CHECKSUM_HEADER)).thenReturn(
+ encodedEtag);
+ rest.setHeaders(etagHeaders);
+
+ // Act & Assert
+ OS3Exception os3Exception = assertThrows(OS3Exception.class,
+ () -> rest.completeMultipartUpload(OzoneConsts.S3_BUCKET, key,
uploadID, completeMultipartUploadRequest));
Review Comment:
Thanks for remind, I should align the behavior for both Put &
MultipartComplete under EtagMismatchShouldAbortAndThrow testing scenario.
I also make MultipartComplete use delete instead of private function
abortMultipartUpload for verify invocation times.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]