Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import software.amazon.awssdk.services.s3.S3AsyncClientBuilder;
import software.amazon.awssdk.services.s3.S3Configuration;
import software.amazon.awssdk.services.s3.internal.crt.S3CrtAsyncClient;
import software.amazon.awssdk.services.s3.model.CompleteMultipartUploadRequest;
import software.amazon.awssdk.services.s3.model.CompleteMultipartUploadResponse;
import software.amazon.awssdk.services.s3.model.CreateMultipartUploadRequest;
import software.amazon.awssdk.services.s3.model.CreateMultipartUploadResponse;
import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
import software.amazon.awssdk.services.s3.model.DeleteObjectResponse;
import software.amazon.awssdk.services.s3.model.DeleteObjectsRequest;
Expand All @@ -30,6 +34,8 @@
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
import software.amazon.awssdk.services.s3.model.PutObjectResponse;
import software.amazon.awssdk.services.s3.model.S3Request;
import software.amazon.awssdk.services.s3.model.UploadPartRequest;
import software.amazon.awssdk.services.s3.model.UploadPartResponse;
import software.amazon.awssdk.services.s3.multipart.MultipartConfiguration;
import software.amazon.encryption.s3.internal.GetEncryptedObjectPipeline;
import software.amazon.encryption.s3.internal.InstructionFileConfig;
Expand Down Expand Up @@ -256,6 +262,24 @@ public CompletableFuture<DeleteObjectsResponse> deleteObjects(DeleteObjectsReque
.build());
}

@Override
public CompletableFuture<CreateMultipartUploadResponse> createMultipartUpload(CreateMultipartUploadRequest createMultipartUploadRequest) {
throw new UnsupportedOperationException("The S3 Async Encryption Client does not support low-level multipart uploads. " +
"Please use Multipart PutObject or the default (synchronous) client to use this API.");
}

@Override
public CompletableFuture<UploadPartResponse> uploadPart(UploadPartRequest uploadPartRequest, AsyncRequestBody asyncRequestBody) {
throw new UnsupportedOperationException("The S3 Async Encryption Client does not support low-level multipart uploads. " +
"Please use Multipart PutObject or the default (synchronous) client to use this API.");
}

@Override
public CompletableFuture<CompleteMultipartUploadResponse> completeMultipartUpload(CompleteMultipartUploadRequest completeMultipartUploadRequest) {
throw new UnsupportedOperationException("The S3 Async Encryption Client does not support low-level multipart uploads. " +
"Please use Multipart PutObject or the default (synchronous) client to use this API.");
}

/**
* Closes the wrapped {@link S3AsyncClient} instance.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -910,16 +910,46 @@ public void wrappedClientMultipartUploadThrowsException() throws IOException {
}

@Test
public void S3AsyncClientBuilderForbidsMultipartEnabled() throws IOException {
public void s3AsyncClientBuilderForbidsMultipartEnabled() {
assertThrows(
UnsupportedOperationException.class,
() -> S3AsyncEncryptionClient.builder().multipartEnabled(Boolean.TRUE));
}

@Test
public void S3AsyncClientBuilderForbidsMultipartConfiguration() throws IOException {
public void s3AsyncClientBuilderForbidsMultipartConfiguration() {
assertThrows(
UnsupportedOperationException.class,
() -> S3AsyncEncryptionClient.builder().multipartConfiguration(MultipartConfiguration.builder().build()));
}

@Test
public void s3AsyncClientForbidsCreateMultipartUpload() {
S3AsyncClient s3AsyncClient = S3AsyncEncryptionClient.builder()
.kmsKeyId("fails")
.build();

assertThrows(UnsupportedOperationException.class, () -> s3AsyncClient.createMultipartUpload(builder -> builder.bucket(BUCKET).key("expected-fail").build()).join());
s3AsyncClient.close();
}

@Test
public void s3AsyncClientForbidsUploadPart() {
S3AsyncClient s3AsyncClient = S3AsyncEncryptionClient.builder()
.kmsKeyId("fails")
.build();

assertThrows(UnsupportedOperationException.class, () -> s3AsyncClient.uploadPart(builder -> builder.uploadId("fail").build(), AsyncRequestBody.fromString("fail")).join());
s3AsyncClient.close();
}

@Test
public void s3AsyncClientForbidsCompleteMultipartUpload() {
S3AsyncClient s3AsyncClient = S3AsyncEncryptionClient.builder()
.kmsKeyId("fails")
.build();

assertThrows(UnsupportedOperationException.class, () -> s3AsyncClient.completeMultipartUpload(builder -> builder.uploadId("fail").build()).join());
s3AsyncClient.close();
}
}