use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class AwsCrtS3V4aSignerTest method testS3ChunkedSigning.
@Test
public void testS3ChunkedSigning() {
SigningTestCase testCase = SignerTestUtils.createBasicChunkedSigningTestCase();
ExecutionAttributes executionAttributes = SignerTestUtils.buildBasicExecutionAttributes(testCase);
SdkHttpFullRequest.Builder requestBuilder = testCase.requestBuilder;
requestBuilder.uri(URI.create("http://demo.us-east-1.amazonaws.com"));
SdkHttpFullRequest request = requestBuilder.build();
SdkHttpFullRequest signedRequest = s3V4aSigner.sign(request, executionAttributes);
assertThat(signedRequest.firstMatchingHeader("Authorization")).isPresent();
assertThat(signedRequest.contentStreamProvider()).isPresent();
assertThat(signedRequest.contentStreamProvider().get().newStream()).isInstanceOf(AwsSignedChunkedEncodingInputStream.class);
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class AwsCrtS3V4aSignerSigningScopeTest method signRequestWithScope.
protected SdkHttpFullRequest signRequestWithScope(SigningTestCase testCase, RegionScope defaultRegionScope, RegionScope regionScope) {
ExecutionAttributes executionAttributes = SignerTestUtils.buildBasicExecutionAttributes(testCase);
if (regionScope != null) {
executionAttributes.putAttribute(AwsSignerExecutionAttribute.SIGNING_REGION_SCOPE, regionScope);
}
SdkHttpFullRequest request = testCase.requestBuilder.build();
return AwsCrtS3V4aSigner.builder().defaultRegionScope(defaultRegionScope).build().sign(request, executionAttributes);
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class DefaultAwsCrtS3V4aSignerTest method when_credentials_are_anonymous_return_request.
@Test
public void when_credentials_are_anonymous_return_request() {
SigningTestCase testCase = SignerTestUtils.createBasicHeaderSigningTestCase();
ExecutionAttributes executionAttributes = SignerTestUtils.buildBasicExecutionAttributes(testCase);
executionAttributes.putAttribute(AwsSignerExecutionAttribute.AWS_CREDENTIALS, AnonymousCredentialsProvider.create().resolveCredentials());
SdkHttpFullRequest request = testCase.requestBuilder.build();
SdkHttpFullRequest signedRequest = s3V4aSigner.sign(request, executionAttributes);
assertThat(signedRequest).isEqualTo(request);
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class DefaultAwsCrtS3V4aSignerTest method payloadSigning_and_chunked_disabled_does_not_sign_payload.
@Test
public void payloadSigning_and_chunked_disabled_does_not_sign_payload() {
SigningTestCase testCase = SignerTestUtils.createBasicHeaderSigningTestCase();
ExecutionAttributes executionAttributes = SignerTestUtils.buildBasicExecutionAttributes(testCase);
executionAttributes.putAttribute(S3SignerExecutionAttribute.ENABLE_PAYLOAD_SIGNING, true);
executionAttributes.putAttribute(S3SignerExecutionAttribute.ENABLE_CHUNKED_ENCODING, false);
SdkHttpFullRequest signedRequest = s3V4aSigner.sign(testCase.requestBuilder.build(), executionAttributes);
verifyUnsignedPayload(signedRequest);
}
use of software.amazon.awssdk.http.SdkHttpFullRequest in project aws-sdk-java-v2 by aws.
the class DefaultAwsCrtS3V4aSignerTest method setup.
@Before
public void setup() {
configProvider = new SigningConfigProvider();
s3V4aSigner = new DefaultAwsCrtS3V4aSigner(signerAdapter, configProvider);
SdkHttpFullRequest unsignedPayloadSignedRequest = SignerTestUtils.createSignedHttpRequest("data");
SdkHttpFullRequest signedPayloadSignedRequest = SignerTestUtils.createSignedPayloadHttpRequest("data");
String signedPayloadSignature = SignerTestUtils.extractSignatureFromAuthHeader(signedPayloadSignedRequest);
// when(configProvider.createS3CrtSigningConfig(any())).thenReturn(new AwsSigningConfig());
when(signerAdapter.sign(any(), any())).thenReturn(new SdkSigningResult(signedPayloadSignature.getBytes(StandardCharsets.UTF_8), signedPayloadSignedRequest));
when(signerAdapter.signRequest(any(), any())).thenReturn(unsignedPayloadSignedRequest);
}
Aggregations