Search in sources :

Example 16 with SdkHttpFullRequest

use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.

the class DefaultAwsCrtS3V4aSignerTest method no_payloadSigning_and_chunkedEnabled_does_not_sign_payload.

@Test
public void no_payloadSigning_and_chunkedEnabled_does_not_sign_payload() {
    SigningTestCase testCase = SignerTestUtils.createBasicHeaderSigningTestCase();
    ExecutionAttributes executionAttributes = SignerTestUtils.buildBasicExecutionAttributes(testCase);
    executionAttributes.putAttribute(S3SignerExecutionAttribute.ENABLE_PAYLOAD_SIGNING, false);
    executionAttributes.putAttribute(S3SignerExecutionAttribute.ENABLE_CHUNKED_ENCODING, true);
    SdkHttpFullRequest signedRequest = s3V4aSigner.sign(testCase.requestBuilder.build(), executionAttributes);
    verifyUnsignedPayload(signedRequest);
}
Also used : SigningTestCase(software.amazon.awssdk.authcrt.signer.SigningTestCase) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) Test(org.junit.Test)

Example 17 with SdkHttpFullRequest

use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.

the class DefaultAwsCrtS3V4aSignerTest method no_special_configuration_does_not_sign_payload.

@Test
public void no_special_configuration_does_not_sign_payload() {
    SigningTestCase testCase = SignerTestUtils.createBasicHeaderSigningTestCase();
    ExecutionAttributes executionAttributes = SignerTestUtils.buildBasicExecutionAttributes(testCase);
    SdkHttpFullRequest request = testCase.requestBuilder.build();
    SdkHttpFullRequest signedRequest = s3V4aSigner.sign(request, executionAttributes);
    verifyUnsignedPayload(signedRequest);
}
Also used : SigningTestCase(software.amazon.awssdk.authcrt.signer.SigningTestCase) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) Test(org.junit.Test)

Example 18 with SdkHttpFullRequest

use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.

the class DefaultAwsCrtS3V4aSignerTest method unsigned_payload_signing_with_trailer_checksums.

@Test
public void unsigned_payload_signing_with_trailer_checksums() {
    SigningTestCase testCase = SignerTestUtils.createBasicHeaderSigningTestCase();
    ExecutionAttributes executionAttributes = SignerTestUtils.buildBasicExecutionAttributes(testCase);
    executionAttributes.putAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM, HTTP_CRC32_CHECKSUM);
    SdkHttpFullRequest request = testCase.requestBuilder.build();
    SdkHttpFullRequest signedRequest = s3V4aSigner.sign(request, executionAttributes);
    verifyUnsignedPayloadWithTrailerChecksum(signedRequest);
}
Also used : SigningTestCase(software.amazon.awssdk.authcrt.signer.SigningTestCase) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) Test(org.junit.Test)

Example 19 with SdkHttpFullRequest

use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.

the class BaseSigningScopeTest method signing_withSigningRegionOnly_usesSigningRegion.

@Test
public void signing_withSigningRegionOnly_usesSigningRegion() {
    SigningTestCase testCase = SignerTestUtils.createBasicHeaderSigningTestCase();
    SdkHttpFullRequest signedRequest = signRequestWithScope(testCase, null, null);
    String regionHeader = signedRequest.firstMatchingHeader("X-Amz-Region-Set").get();
    assertThat(regionHeader).isEqualTo(Region.AWS_GLOBAL.id());
}
Also used : SigningTestCase(software.amazon.awssdk.authcrt.signer.SigningTestCase) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) Test(org.junit.jupiter.api.Test)

Example 20 with SdkHttpFullRequest

use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.

the class BaseSigningScopeTest method signing_withSigningRegionAndRegionScope_usesRegionScope.

@Test
public void signing_withSigningRegionAndRegionScope_usesRegionScope() {
    SigningTestCase testCase = SignerTestUtils.createBasicHeaderSigningTestCase();
    SdkHttpFullRequest signedRequest = signRequestWithScope(testCase, null, RegionScope.GLOBAL);
    String regionHeader = signedRequest.firstMatchingHeader("X-Amz-Region-Set").get();
    assertThat(regionHeader).isEqualTo(RegionScope.GLOBAL.id());
}
Also used : SigningTestCase(software.amazon.awssdk.authcrt.signer.SigningTestCase) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) Test(org.junit.jupiter.api.Test)

Aggregations

SdkHttpFullRequest (software.amazon.awssdk.http.SdkHttpFullRequest)178 Test (org.junit.Test)70 Test (org.junit.jupiter.api.Test)50 ExecutionAttributes (software.amazon.awssdk.core.interceptor.ExecutionAttributes)43 URI (java.net.URI)25 SigningTestCase (software.amazon.awssdk.authcrt.signer.SigningTestCase)23 ByteArrayInputStream (java.io.ByteArrayInputStream)18 SdkHttpRequest (software.amazon.awssdk.http.SdkHttpRequest)16 List (java.util.List)13 AwsCredentials (software.amazon.awssdk.auth.credentials.AwsCredentials)13 RequestExecutionContext (software.amazon.awssdk.core.internal.http.RequestExecutionContext)12 ByteBuffer (java.nio.ByteBuffer)11 AsyncRequestBody (software.amazon.awssdk.core.async.AsyncRequestBody)11 Map (java.util.Map)10 ContentStreamProvider (software.amazon.awssdk.http.ContentStreamProvider)10 Instant (java.time.Instant)9 AwsBasicCredentials (software.amazon.awssdk.auth.credentials.AwsBasicCredentials)9 Aws4SignerParams (software.amazon.awssdk.auth.signer.params.Aws4SignerParams)9 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8