Search in sources :

Example 96 with GetObjectRequest

use of com.amazonaws.s3.model.GetObjectRequest in project aws-sdk-java-v2 by aws.

the class SyncServerSideEncryptionIntegrationTest method sse_AWSKMS_succeeds.

@Test
public void sse_AWSKMS_succeeds() throws Exception {
    String key = UUID.randomUUID().toString();
    PutObjectRequest request = PutObjectRequest.builder().key(key).bucket(BUCKET).serverSideEncryption(ServerSideEncryption.AWS_KMS).build();
    s3.putObject(request, file.toPath());
    GetObjectRequest getObjectRequest = GetObjectRequest.builder().key(key).bucket(BUCKET).build();
    String response = s3.getObject(getObjectRequest, ResponseTransformer.toBytes()).asUtf8String();
    SdkAsserts.assertStringEqualsStream(response, new FileInputStream(file));
}
Also used : GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest) PutObjectRequest(software.amazon.awssdk.services.s3.model.PutObjectRequest) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 97 with GetObjectRequest

use of com.amazonaws.s3.model.GetObjectRequest in project aws-sdk-java-v2 by aws.

the class SyncServerSideEncryptionIntegrationTest method sse_onBucket_succeeds.

@Test
public void sse_onBucket_succeeds() throws FileNotFoundException {
    String key = UUID.randomUUID().toString();
    PutObjectRequest request = PutObjectRequest.builder().key(key).bucket(BUCKET_WITH_SSE).build();
    s3.putObject(request, file.toPath());
    GetObjectRequest getObjectRequest = GetObjectRequest.builder().key(key).bucket(BUCKET_WITH_SSE).build();
    String response = s3.getObject(getObjectRequest, ResponseTransformer.toBytes()).asUtf8String();
    SdkAsserts.assertStringEqualsStream(response, new FileInputStream(file));
}
Also used : GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest) PutObjectRequest(software.amazon.awssdk.services.s3.model.PutObjectRequest) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 98 with GetObjectRequest

use of com.amazonaws.s3.model.GetObjectRequest in project aws-sdk-java-v2 by aws.

the class AsyncServerSideEncryptionIntegrationTest method sse_onBucket_succeeds.

@Test
public void sse_onBucket_succeeds() throws FileNotFoundException {
    String key = UUID.randomUUID().toString();
    PutObjectRequest request = PutObjectRequest.builder().key(key).bucket(BUCKET_WITH_SSE).build();
    s3Async.putObject(request, file.toPath()).join();
    GetObjectRequest getObjectRequest = GetObjectRequest.builder().key(key).bucket(BUCKET_WITH_SSE).build();
    verifyGetResponse(getObjectRequest);
}
Also used : GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest) PutObjectRequest(software.amazon.awssdk.services.s3.model.PutObjectRequest) Test(org.junit.Test)

Example 99 with GetObjectRequest

use of com.amazonaws.s3.model.GetObjectRequest in project aws-sdk-java-v2 by aws.

the class GetBucketPolicyInterceptorTest method nonGetBucketPolicyResponse_ShouldNotModifyResponse.

@Test
public void nonGetBucketPolicyResponse_ShouldNotModifyResponse() {
    GetObjectRequest request = GetObjectRequest.builder().build();
    Context.ModifyHttpResponse context = modifyHttpResponseContent(request, SdkHttpResponse.builder().statusCode(200).build());
    Optional<InputStream> inputStream = interceptor.modifyHttpResponseContent(context, new ExecutionAttributes());
    assertThat(inputStream).isEqualTo(context.responseBody());
}
Also used : Context(software.amazon.awssdk.core.interceptor.Context) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) InputStream(java.io.InputStream) GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest) Test(org.junit.jupiter.api.Test)

Example 100 with GetObjectRequest

use of com.amazonaws.s3.model.GetObjectRequest in project aws-sdk-java-v2 by aws.

the class GetObjectPresignRequestTest method equalsAndHashCode_differentProperty_getObjectRequest.

@Test
public void equalsAndHashCode_differentProperty_getObjectRequest() {
    GetObjectRequest otherGetObjectRequest = GetObjectRequest.builder().bucket("other-bucket").key("other-key").build();
    GetObjectPresignRequest getObjectPresignRequest = GetObjectPresignRequest.builder().getObjectRequest(GET_OBJECT_REQUEST).signatureDuration(Duration.ofSeconds(123L)).build();
    GetObjectPresignRequest otherGetObjectPresignRequest = GetObjectPresignRequest.builder().getObjectRequest(otherGetObjectRequest).signatureDuration(Duration.ofSeconds(123L)).build();
    assertThat(otherGetObjectPresignRequest).isNotEqualTo(getObjectPresignRequest);
    assertThat(otherGetObjectPresignRequest.hashCode()).isNotEqualTo(getObjectPresignRequest.hashCode());
}
Also used : GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest) Test(org.junit.jupiter.api.Test)

Aggregations

GetObjectRequest (com.amazonaws.services.s3.model.GetObjectRequest)139 GetObjectRequest (software.amazon.awssdk.services.s3.model.GetObjectRequest)123 S3Object (com.amazonaws.services.s3.model.S3Object)80 Test (org.junit.Test)77 IOException (java.io.IOException)63 GetObjectResponse (software.amazon.awssdk.services.s3.model.GetObjectResponse)56 File (java.io.File)40 Instant (java.time.Instant)33 InputStream (java.io.InputStream)32 PresignedGetObjectRequest (software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest)31 URI (java.net.URI)30 Region (software.amazon.awssdk.regions.Region)30 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)29 Duration (java.time.Duration)26 ExecutionAttributes (software.amazon.awssdk.core.interceptor.ExecutionAttributes)25 S3Presigner (software.amazon.awssdk.services.s3.presigner.S3Presigner)25 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)23 Mockito (org.mockito.Mockito)23 RunWith (org.junit.runner.RunWith)22 AwsBasicCredentials (software.amazon.awssdk.auth.credentials.AwsBasicCredentials)22