use of software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration 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");
}
use of software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration in project aws-sdk-java-v2 by aws.
the class S3PresignerTest method getObject_Sigv4PresignerHonorsSignatureDuration.
@Test
public void getObject_Sigv4PresignerHonorsSignatureDuration() {
AwsRequestOverrideConfiguration override = AwsRequestOverrideConfiguration.builder().signer(AwsS3V4Signer.create()).build();
PresignedGetObjectRequest presigned = presigner.presignGetObject(r -> r.signatureDuration(Duration.ofSeconds(1234)).getObjectRequest(gor -> gor.bucket("a").key("b").overrideConfiguration(override)));
assertThat(presigned.httpRequest().rawQueryParameters().get("X-Amz-Expires").get(0)).satisfies(expires -> {
assertThat(expires).containsOnlyDigits();
assertThat(Integer.parseInt(expires)).isCloseTo(1234, Offset.offset(2));
});
}
use of software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration in project aws-sdk-java-v2 by aws.
the class S3PresignerTest method getObject_AdditionalHeadersAndQueryStringsCanBeAdded.
@Test
public void getObject_AdditionalHeadersAndQueryStringsCanBeAdded() {
AwsRequestOverrideConfiguration override = AwsRequestOverrideConfiguration.builder().putHeader("X-Amz-AdditionalHeader", "foo1").putRawQueryParameter("additionalQueryParam", "foo2").build();
PresignedGetObjectRequest presigned = presigner.presignGetObject(r -> r.signatureDuration(Duration.ofMinutes(5)).getObjectRequest(go -> go.bucket("foo34343434").key("bar").overrideConfiguration(override)));
assertThat(presigned.isBrowserExecutable()).isFalse();
assertThat(presigned.signedHeaders()).containsOnlyKeys("host", "x-amz-additionalheader");
assertThat(presigned.signedHeaders().get("x-amz-additionalheader")).containsExactly("foo1");
assertThat(presigned.httpRequest().headers()).containsKeys("x-amz-additionalheader");
assertThat(presigned.httpRequest().rawQueryParameters().get("additionalQueryParam").get(0)).isEqualTo("foo2");
}
Aggregations