Search in sources :

Example 1 with PollyPresigner

use of software.amazon.awssdk.services.polly.presigner.PollyPresigner in project aws-sdk-java-v2 by aws.

the class DefaultPollyPresignerTest method presign_includesRequestLevelHeaders_notBrowserCompatible.

@Test
public void presign_includesRequestLevelHeaders_notBrowserCompatible() {
    PollyPresigner presigner = DefaultPollyPresigner.builder().region(Region.US_EAST_1).credentialsProvider(credentialsProvider).build();
    SynthesizeSpeechRequest synthesizeSpeechRequest = BASIC_SYNTHESIZE_SPEECH_REQUEST.toBuilder().overrideConfiguration(AwsRequestOverrideConfiguration.builder().putHeader("Header1", "Header1Value").putHeader("Header2", "Header2Value").build()).build();
    SynthesizeSpeechPresignRequest presignRequest = SynthesizeSpeechPresignRequest.builder().synthesizeSpeechRequest(synthesizeSpeechRequest).signatureDuration(Duration.ofHours(3)).build();
    PresignedSynthesizeSpeechRequest presignedSynthesizeSpeechRequest = presigner.presignSynthesizeSpeech(presignRequest);
    assertThat(presignedSynthesizeSpeechRequest.isBrowserExecutable()).isFalse();
}
Also used : PresignedSynthesizeSpeechRequest(software.amazon.awssdk.services.polly.presigner.model.PresignedSynthesizeSpeechRequest) SynthesizeSpeechRequest(software.amazon.awssdk.services.polly.model.SynthesizeSpeechRequest) SynthesizeSpeechPresignRequest(software.amazon.awssdk.services.polly.presigner.model.SynthesizeSpeechPresignRequest) PollyPresigner(software.amazon.awssdk.services.polly.presigner.PollyPresigner) PresignedSynthesizeSpeechRequest(software.amazon.awssdk.services.polly.presigner.model.PresignedSynthesizeSpeechRequest) Test(org.junit.jupiter.api.Test)

Example 2 with PollyPresigner

use of software.amazon.awssdk.services.polly.presigner.PollyPresigner in project aws-sdk-java-v2 by aws.

the class DefaultPollyPresignerTest method presign_requestLevelHeaders_included.

@Test
public void presign_requestLevelHeaders_included() {
    PollyPresigner presigner = DefaultPollyPresigner.builder().region(Region.US_EAST_1).credentialsProvider(credentialsProvider).build();
    SynthesizeSpeechRequest synthesizeSpeechRequest = BASIC_SYNTHESIZE_SPEECH_REQUEST.toBuilder().overrideConfiguration(AwsRequestOverrideConfiguration.builder().putHeader("Header1", "Header1Value").putHeader("Header2", "Header2Value").build()).build();
    SynthesizeSpeechPresignRequest presignRequest = SynthesizeSpeechPresignRequest.builder().synthesizeSpeechRequest(synthesizeSpeechRequest).signatureDuration(Duration.ofHours(3)).build();
    PresignedSynthesizeSpeechRequest presignedSynthesizeSpeechRequest = presigner.presignSynthesizeSpeech(presignRequest);
    assertThat(presignedSynthesizeSpeechRequest.httpRequest().headers().keySet()).contains("Header1", "Header2");
}
Also used : PresignedSynthesizeSpeechRequest(software.amazon.awssdk.services.polly.presigner.model.PresignedSynthesizeSpeechRequest) SynthesizeSpeechRequest(software.amazon.awssdk.services.polly.model.SynthesizeSpeechRequest) SynthesizeSpeechPresignRequest(software.amazon.awssdk.services.polly.presigner.model.SynthesizeSpeechPresignRequest) PollyPresigner(software.amazon.awssdk.services.polly.presigner.PollyPresigner) PresignedSynthesizeSpeechRequest(software.amazon.awssdk.services.polly.presigner.model.PresignedSynthesizeSpeechRequest) Test(org.junit.jupiter.api.Test)

Example 3 with PollyPresigner

use of software.amazon.awssdk.services.polly.presigner.PollyPresigner in project aws-sdk-java-v2 by aws.

the class DefaultPollyPresignerTest method presign_endpointOverriden.

@Test
public void presign_endpointOverriden() {
    PollyPresigner presigner = DefaultPollyPresigner.builder().region(Region.US_EAST_1).credentialsProvider(credentialsProvider).endpointOverride(URI.create("http://some-other-polly-endpoint.aws:1234")).build();
    SynthesizeSpeechPresignRequest presignRequest = SynthesizeSpeechPresignRequest.builder().synthesizeSpeechRequest(BASIC_SYNTHESIZE_SPEECH_REQUEST).signatureDuration(Duration.ofHours(3)).build();
    PresignedSynthesizeSpeechRequest presignedSynthesizeSpeechRequest = presigner.presignSynthesizeSpeech(presignRequest);
    URL presignedUrl = presignedSynthesizeSpeechRequest.url();
    assertThat(presignedUrl.getProtocol()).isEqualTo("http");
    assertThat(presignedUrl.getHost()).isEqualTo("some-other-polly-endpoint.aws");
    assertThat(presignedUrl.getPort()).isEqualTo(1234);
}
Also used : SynthesizeSpeechPresignRequest(software.amazon.awssdk.services.polly.presigner.model.SynthesizeSpeechPresignRequest) PollyPresigner(software.amazon.awssdk.services.polly.presigner.PollyPresigner) PresignedSynthesizeSpeechRequest(software.amazon.awssdk.services.polly.presigner.model.PresignedSynthesizeSpeechRequest) URL(java.net.URL) Test(org.junit.jupiter.api.Test)

Example 4 with PollyPresigner

use of software.amazon.awssdk.services.polly.presigner.PollyPresigner in project aws-sdk-java-v2 by aws.

the class DefaultPollyPresignerTest method close_closesCustomCloseableCredentialsProvider.

@Test
public void close_closesCustomCloseableCredentialsProvider() throws IOException {
    TestCredentialsProvider mockCredentialsProvider = mock(TestCredentialsProvider.class);
    PollyPresigner presigner = DefaultPollyPresigner.builder().region(Region.US_EAST_1).credentialsProvider(mockCredentialsProvider).build();
    presigner.close();
    verify(mockCredentialsProvider).close();
}
Also used : PollyPresigner(software.amazon.awssdk.services.polly.presigner.PollyPresigner) Test(org.junit.jupiter.api.Test)

Example 5 with PollyPresigner

use of software.amazon.awssdk.services.polly.presigner.PollyPresigner in project aws-sdk-java-v2 by aws.

the class DefaultPollyPresignerTest method presign_requestLevelCredentials_honored.

@Test
public void presign_requestLevelCredentials_honored() {
    AwsCredentials requestCredentials = AwsBasicCredentials.create("akid2", "skid2");
    PollyPresigner presigner = DefaultPollyPresigner.builder().region(Region.US_EAST_1).credentialsProvider(credentialsProvider).build();
    SynthesizeSpeechRequest synthesizeSpeechRequest = BASIC_SYNTHESIZE_SPEECH_REQUEST.toBuilder().overrideConfiguration(AwsRequestOverrideConfiguration.builder().credentialsProvider(StaticCredentialsProvider.create(requestCredentials)).build()).build();
    SynthesizeSpeechPresignRequest presignRequest = SynthesizeSpeechPresignRequest.builder().synthesizeSpeechRequest(synthesizeSpeechRequest).signatureDuration(Duration.ofHours(3)).build();
    PresignedSynthesizeSpeechRequest presignedSynthesizeSpeechRequest = presigner.presignSynthesizeSpeech(presignRequest);
    assertThat(presignedSynthesizeSpeechRequest.url().getQuery()).contains("X-Amz-Credential=akid2");
}
Also used : PresignedSynthesizeSpeechRequest(software.amazon.awssdk.services.polly.presigner.model.PresignedSynthesizeSpeechRequest) SynthesizeSpeechRequest(software.amazon.awssdk.services.polly.model.SynthesizeSpeechRequest) SynthesizeSpeechPresignRequest(software.amazon.awssdk.services.polly.presigner.model.SynthesizeSpeechPresignRequest) PollyPresigner(software.amazon.awssdk.services.polly.presigner.PollyPresigner) AwsCredentials(software.amazon.awssdk.auth.credentials.AwsCredentials) PresignedSynthesizeSpeechRequest(software.amazon.awssdk.services.polly.presigner.model.PresignedSynthesizeSpeechRequest) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)6 PollyPresigner (software.amazon.awssdk.services.polly.presigner.PollyPresigner)6 PresignedSynthesizeSpeechRequest (software.amazon.awssdk.services.polly.presigner.model.PresignedSynthesizeSpeechRequest)5 SynthesizeSpeechPresignRequest (software.amazon.awssdk.services.polly.presigner.model.SynthesizeSpeechPresignRequest)5 SynthesizeSpeechRequest (software.amazon.awssdk.services.polly.model.SynthesizeSpeechRequest)4 URL (java.net.URL)1 AwsCredentials (software.amazon.awssdk.auth.credentials.AwsCredentials)1