Search in sources :

Example 21 with SdkHttpFullRequest

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

the class BaseSigningScopeTest method presigning_withSigningRegionAndRegionScope_usesRegionScope.

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

Example 22 with SdkHttpFullRequest

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

the class BaseSigningScopeTest method presigning_withDefaultScopeAndExplicitScope_usesExplicitScope.

@Test
public void presigning_withDefaultScopeAndExplicitScope_usesExplicitScope() {
    SigningTestCase testCase = SignerTestUtils.createBasicHeaderSigningTestCase();
    String expectdScope = "us-west-2";
    SdkHttpFullRequest signedRequest = presignRequestWithScope(testCase, RegionScope.GLOBAL, RegionScope.create(expectdScope));
    assertThat(signedRequest.rawQueryParameters().get("X-Amz-Region-Set")).containsExactly(expectdScope);
}
Also used : SigningTestCase(software.amazon.awssdk.authcrt.signer.SigningTestCase) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) Test(org.junit.jupiter.api.Test)

Example 23 with SdkHttpFullRequest

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

the class CrtHttpRequestConverterTest method request_withQueryParams_isConvertedToCrtFormat.

@Test
public void request_withQueryParams_isConvertedToCrtFormat() {
    SdkHttpFullRequest request = SdkHttpFullRequest.builder().method(SdkHttpMethod.GET).putRawQueryParameter("param1", "value1").putRawQueryParameter("param2", Arrays.asList("value2-1", "value2-2")).putHeader("Host", "demo.us-east-1.amazonaws.com").encodedPath("/path").uri(URI.create("https://demo.us-east-1.amazonaws.com")).build();
    HttpRequest crtHttpRequest = converter.requestToCrt(request);
    assertThat(crtHttpRequest.getMethod()).isEqualTo("GET");
    assertThat(crtHttpRequest.getEncodedPath()).isEqualTo("/path?param1=value1&param2=value2-1&param2=value2-2");
    assertHttpRequestSame(request, crtHttpRequest);
}
Also used : HttpRequest(software.amazon.awssdk.crt.http.HttpRequest) SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest) Test(org.junit.jupiter.api.Test)

Example 24 with SdkHttpFullRequest

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

the class CrtHttpRequestConverterTest method assertHttpRequestSame.

private void assertHttpRequestSame(SdkHttpFullRequest originalRequest, HttpRequest crtRequest) {
    SdkHttpFullRequest sdkRequest = converter.crtRequestToHttp(originalRequest, crtRequest);
    assertThat(sdkRequest.method()).isEqualTo(originalRequest.method());
    assertThat(sdkRequest.protocol()).isEqualTo(originalRequest.protocol());
    assertThat(sdkRequest.host()).isEqualTo(originalRequest.host());
    assertThat(sdkRequest.encodedPath()).isEqualTo(originalRequest.encodedPath());
    assertThat(sdkRequest.headers()).isEqualTo(originalRequest.headers());
    assertThat(sdkRequest.rawQueryParameters()).isEqualTo(originalRequest.rawQueryParameters());
}
Also used : SdkHttpFullRequest(software.amazon.awssdk.http.SdkHttpFullRequest)

Example 25 with SdkHttpFullRequest

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

the class CrtHttpRequestConverterTest method request_withEmptyPath_isConvertedToCrtFormat.

@Test
public void request_withEmptyPath_isConvertedToCrtFormat() {
    SdkHttpFullRequest request = SdkHttpFullRequest.builder().method(SdkHttpMethod.GET).putHeader("Host", "demo.us-east-1.amazonaws.com").encodedPath("").uri(URI.create("https://demo.us-east-1.amazonaws.com")).build();
    HttpRequest crtHttpRequest = converter.requestToCrt(request);
    assertThat(crtHttpRequest.getEncodedPath()).isEqualTo("/");
    assertHttpRequestSame(request, crtHttpRequest);
}
Also used : HttpRequest(software.amazon.awssdk.crt.http.HttpRequest) 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