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();
}
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");
}
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);
}
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();
}
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");
}
Aggregations