Search in sources :

Example 6 with NoOpSigner

use of software.amazon.awssdk.core.signer.NoOpSigner in project aws-sdk-java-v2 by aws.

the class AsyncHttpClientApiCallTimeoutTests method errorResponse_SlowAfterErrorRequestHandler_ThrowsApiCallTimeoutException.

@Test
public void errorResponse_SlowAfterErrorRequestHandler_ThrowsApiCallTimeoutException() {
    stubFor(get(anyUrl()).willReturn(aResponse().withStatus(500).withBody("{}")));
    ExecutionInterceptorChain interceptors = new ExecutionInterceptorChain(Collections.singletonList(new SlowExecutionInterceptor().onExecutionFailureWaitInSeconds(SLOW_REQUEST_HANDLER_TIMEOUT)));
    SdkHttpFullRequest request = generateRequest();
    InterceptorContext incerceptorContext = InterceptorContext.builder().request(NoopTestRequest.builder().build()).httpRequest(request).build();
    ExecutionContext executionContext = ExecutionContext.builder().signer(new NoOpSigner()).interceptorChain(interceptors).executionAttributes(new ExecutionAttributes()).interceptorContext(incerceptorContext).metricCollector(MetricCollector.create("ApiCall")).build();
    CompletableFuture future = httpClient.requestExecutionBuilder().originalRequest(NoopTestRequest.builder().build()).request(request).executionContext(executionContext).execute(combinedAsyncResponseHandler(noOpResponseHandler(), noOpResponseHandler(SdkServiceException.builder().build())));
    assertThatThrownBy(future::join).hasCauseInstanceOf(ApiCallTimeoutException.class);
}
Also used : NoOpSigner(software.amazon.awssdk.core.signer.NoOpSigner) CompletableFuture(java.util.concurrent.CompletableFuture) ExecutionContext(software.amazon.awssdk.core.http.ExecutionContext) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) SlowExecutionInterceptor(software.amazon.awssdk.core.internal.http.request.SlowExecutionInterceptor) ExecutionInterceptorChain(software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain) InterceptorContext(software.amazon.awssdk.core.interceptor.InterceptorContext) Test(org.junit.Test)

Example 7 with NoOpSigner

use of software.amazon.awssdk.core.signer.NoOpSigner in project aws-sdk-java-v2 by aws.

the class S3PresignerTest method getObject_NonSigV4SignersRaisesException.

@Test
public void getObject_NonSigV4SignersRaisesException() {
    AwsRequestOverrideConfiguration override = AwsRequestOverrideConfiguration.builder().signer(new NoOpSigner()).build();
    assertThatThrownBy(() -> presigner.presignGetObject(r -> r.signatureDuration(Duration.ofMinutes(5)).getObjectRequest(go -> go.bucket("foo34343434").key("bar").overrideConfiguration(override)))).isInstanceOf(IllegalStateException.class).hasMessageContaining("NoOpSigner");
}
Also used : Offset(org.assertj.core.data.Offset) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ZonedDateTime(java.time.ZonedDateTime) LocalDateTime(java.time.LocalDateTime) RunWith(org.junit.runner.RunWith) AbstractAwsS3V4Signer(software.amazon.awssdk.auth.signer.internal.AbstractAwsS3V4Signer) StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) AwsS3V4SignerParams(software.amazon.awssdk.auth.signer.params.AwsS3V4SignerParams) ChecksumConstant(software.amazon.awssdk.services.s3.checksums.ChecksumConstant) NoOpSigner(software.amazon.awssdk.core.signer.NoOpSigner) RequestPayer(software.amazon.awssdk.services.s3.model.RequestPayer) S3Presigner(software.amazon.awssdk.services.s3.presigner.S3Presigner) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) SignerConstant(software.amazon.awssdk.auth.signer.internal.SignerConstant) Duration(java.time.Duration) After(org.junit.After) PresignedPutObjectRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedPutObjectRequest) Aws4SignerRequestParams(software.amazon.awssdk.auth.signer.internal.Aws4SignerRequestParams) GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) URI(java.net.URI) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) Region(software.amazon.awssdk.regions.Region) Aws4PresignerParams(software.amazon.awssdk.auth.signer.params.Aws4PresignerParams) Before(org.junit.Before) PresignedGetObjectRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest) AwsCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials) Test(org.junit.Test) AwsS3V4Signer(software.amazon.awssdk.auth.signer.AwsS3V4Signer) Instant(java.time.Instant) ZoneId(java.time.ZoneId) AbstractAws4Signer(software.amazon.awssdk.auth.signer.internal.AbstractAws4Signer) Mockito(org.mockito.Mockito) LocalDate(java.time.LocalDate) Clock(java.time.Clock) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) DateUtils(software.amazon.awssdk.utils.DateUtils) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) AwsRequestOverrideConfiguration(software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration) NoOpSigner(software.amazon.awssdk.core.signer.NoOpSigner) AwsRequestOverrideConfiguration(software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration) Test(org.junit.Test)

Example 8 with NoOpSigner

use of software.amazon.awssdk.core.signer.NoOpSigner in project aws-sdk-java-v2 by aws.

the class S3PresignerTest method putObject_NonSigV4SignersRaisesException.

@Test
public void putObject_NonSigV4SignersRaisesException() {
    AwsRequestOverrideConfiguration override = AwsRequestOverrideConfiguration.builder().signer(new NoOpSigner()).build();
    assertThatThrownBy(() -> presigner.presignPutObject(r -> r.signatureDuration(Duration.ofMinutes(5)).putObjectRequest(go -> go.bucket("foo34343434").key("bar").overrideConfiguration(override)))).isInstanceOf(IllegalStateException.class).hasMessageContaining("NoOpSigner");
}
Also used : Offset(org.assertj.core.data.Offset) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ZonedDateTime(java.time.ZonedDateTime) LocalDateTime(java.time.LocalDateTime) RunWith(org.junit.runner.RunWith) AbstractAwsS3V4Signer(software.amazon.awssdk.auth.signer.internal.AbstractAwsS3V4Signer) StaticCredentialsProvider(software.amazon.awssdk.auth.credentials.StaticCredentialsProvider) AwsS3V4SignerParams(software.amazon.awssdk.auth.signer.params.AwsS3V4SignerParams) ChecksumConstant(software.amazon.awssdk.services.s3.checksums.ChecksumConstant) NoOpSigner(software.amazon.awssdk.core.signer.NoOpSigner) RequestPayer(software.amazon.awssdk.services.s3.model.RequestPayer) S3Presigner(software.amazon.awssdk.services.s3.presigner.S3Presigner) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) SignerConstant(software.amazon.awssdk.auth.signer.internal.SignerConstant) Duration(java.time.Duration) After(org.junit.After) PresignedPutObjectRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedPutObjectRequest) Aws4SignerRequestParams(software.amazon.awssdk.auth.signer.internal.Aws4SignerRequestParams) GetObjectRequest(software.amazon.awssdk.services.s3.model.GetObjectRequest) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) URI(java.net.URI) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) Region(software.amazon.awssdk.regions.Region) Aws4PresignerParams(software.amazon.awssdk.auth.signer.params.Aws4PresignerParams) Before(org.junit.Before) PresignedGetObjectRequest(software.amazon.awssdk.services.s3.presigner.model.PresignedGetObjectRequest) AwsCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials) Test(org.junit.Test) AwsS3V4Signer(software.amazon.awssdk.auth.signer.AwsS3V4Signer) Instant(java.time.Instant) ZoneId(java.time.ZoneId) AbstractAws4Signer(software.amazon.awssdk.auth.signer.internal.AbstractAws4Signer) Mockito(org.mockito.Mockito) LocalDate(java.time.LocalDate) Clock(java.time.Clock) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) DateUtils(software.amazon.awssdk.utils.DateUtils) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) AwsRequestOverrideConfiguration(software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration) NoOpSigner(software.amazon.awssdk.core.signer.NoOpSigner) AwsRequestOverrideConfiguration(software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration) Test(org.junit.Test)

Aggregations

NoOpSigner (software.amazon.awssdk.core.signer.NoOpSigner)8 ExecutionAttributes (software.amazon.awssdk.core.interceptor.ExecutionAttributes)7 ExecutionInterceptorChain (software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain)5 InterceptorContext (software.amazon.awssdk.core.interceptor.InterceptorContext)4 Test (org.junit.Test)3 AwsBasicCredentials (software.amazon.awssdk.auth.credentials.AwsBasicCredentials)3 StaticCredentialsProvider (software.amazon.awssdk.auth.credentials.StaticCredentialsProvider)3 SdkHttpFullRequest (software.amazon.awssdk.http.SdkHttpFullRequest)3 URI (java.net.URI)2 Clock (java.time.Clock)2 Duration (java.time.Duration)2 Instant (java.time.Instant)2 LocalDate (java.time.LocalDate)2 LocalDateTime (java.time.LocalDateTime)2 ZoneId (java.time.ZoneId)2 ZonedDateTime (java.time.ZonedDateTime)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)2 Offset (org.assertj.core.data.Offset)2 After (org.junit.After)2