Skip to content

Commit 8549bb3

Browse files
committed
add integration test
1 parent c2ab2b4 commit 8549bb3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/test/java/software/amazon/encryption/s3/S3EncryptionClientMultipartUploadTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import software.amazon.awssdk.services.s3.model.SdkPartType;
2121
import software.amazon.awssdk.services.s3.model.UploadPartRequest;
2222
import software.amazon.awssdk.services.s3.model.UploadPartResponse;
23+
import software.amazon.awssdk.services.s3.model.StorageClass;
2324
import software.amazon.awssdk.utils.IoUtils;
2425
import software.amazon.encryption.s3.utils.BoundedInputStream;
2526

@@ -522,4 +523,43 @@ public void multipartUploadV3OutputStreamPartSizeMismatch() throws IOException {
522523
v3Client.close();
523524
}
524525

526+
@Test
527+
public void multipartPutObjectWithOptions() throws IOException {
528+
final String objectKey = appendTestSuffix("multipart-put-object-with-options");
529+
530+
final long fileSizeLimit = 1024 * 1024 * 10;
531+
final InputStream inputStream = new BoundedInputStream(fileSizeLimit);
532+
final InputStream objectStreamForResult = new BoundedInputStream(fileSizeLimit);
533+
534+
final S3Client v3Client = S3EncryptionClient.builder()
535+
.kmsKeyId(KMS_KEY_ID)
536+
.enableMultipartPutObject(true)
537+
.enableDelayedAuthenticationMode(true)
538+
.cryptoProvider(PROVIDER)
539+
.build();
540+
541+
final Map<String, String> encryptionContext = new HashMap<>();
542+
encryptionContext.put("user-metadata-key", "user-metadata-value-v3-to-v3");
543+
544+
final StorageClass storageClass = StorageClass.INTELLIGENT_TIERING;
545+
546+
v3Client.putObject(builder -> builder
547+
.bucket(BUCKET)
548+
.overrideConfiguration(withAdditionalConfiguration(encryptionContext))
549+
.storageClass(storageClass)
550+
.key(objectKey), RequestBody.fromInputStream(inputStream, fileSizeLimit));
551+
552+
// Asserts
553+
final ResponseInputStream<GetObjectResponse> output = v3Client.getObject(builder -> builder
554+
.bucket(BUCKET)
555+
.overrideConfiguration(S3EncryptionClient.withAdditionalConfiguration(encryptionContext))
556+
.key(objectKey));
557+
558+
assertTrue(IOUtils.contentEquals(objectStreamForResult, output));
559+
assertEquals(storageClass, output.response().storageClass());
560+
561+
v3Client.deleteObject(builder -> builder.bucket(BUCKET).key(objectKey));
562+
v3Client.close();
563+
}
564+
525565
}

0 commit comments

Comments
 (0)