Search in sources :

Example 1 with ProxyConfiguration

use of software.amazon.awssdk.http.apache.ProxyConfiguration in project beam by apache.

the class ClientBuilderFactoryTest method testSyncProxyConfiguration.

@Test
public void testSyncProxyConfiguration() {
    ProxyConfiguration proxy = ProxyConfiguration.builder().endpoint(URI.create("http://localhost:7777")).username("user").password("secret").build();
    builder = mock(AwsSyncBuilder.class);
    when(awsOptions.getProxyConfiguration()).thenReturn(proxy);
    getFactory(awsOptions).create(builder, awsOptions);
    ArgumentCaptor<ApacheHttpClient.Builder> httpClientBuilder = ArgumentCaptor.forClass(ApacheHttpClient.Builder.class);
    verify((AwsSyncBuilder) builder).httpClientBuilder(httpClientBuilder.capture());
    verify(httpClientBuilder.getValue()).proxyConfiguration(proxy);
    verifyNoMoreInteractions(httpClientBuilder.getValue());
}
Also used : ProxyConfiguration(software.amazon.awssdk.http.apache.ProxyConfiguration) SdkSyncClientBuilder(software.amazon.awssdk.core.client.builder.SdkSyncClientBuilder) SdkAsyncClientBuilder(software.amazon.awssdk.core.client.builder.SdkAsyncClientBuilder) DefaultClientBuilder(org.apache.beam.sdk.io.aws2.common.ClientBuilderFactory.DefaultClientBuilder) AwsClientBuilder(software.amazon.awssdk.awscore.client.builder.AwsClientBuilder) ApacheHttpClient(software.amazon.awssdk.http.apache.ApacheHttpClient) Test(org.junit.Test)

Example 2 with ProxyConfiguration

use of software.amazon.awssdk.http.apache.ProxyConfiguration in project beam by apache.

the class ClientBuilderFactoryTest method testAsyncProxyConfiguration.

@Test
public void testAsyncProxyConfiguration() {
    ProxyConfiguration proxy = ProxyConfiguration.builder().endpoint(URI.create("http://localhost:7777")).username("user").password("secret").build();
    software.amazon.awssdk.http.nio.netty.ProxyConfiguration nettyProxy = software.amazon.awssdk.http.nio.netty.ProxyConfiguration.builder().scheme(proxy.scheme()).host(proxy.host()).port(proxy.port()).username(proxy.username()).password(proxy.password()).nonProxyHosts(proxy.nonProxyHosts()).build();
    builder = mock(AwsAsyncBuilder.class);
    when(awsOptions.getProxyConfiguration()).thenReturn(proxy);
    getFactory(awsOptions).create(builder, awsOptions);
    ArgumentCaptor<NettyNioAsyncHttpClient.Builder> httpClientBuilder = ArgumentCaptor.forClass(NettyNioAsyncHttpClient.Builder.class);
    verify((AwsAsyncBuilder) builder).httpClientBuilder(httpClientBuilder.capture());
    verify(httpClientBuilder.getValue()).proxyConfiguration(nettyProxy);
    verifyNoMoreInteractions(httpClientBuilder.getValue());
}
Also used : ProxyConfiguration(software.amazon.awssdk.http.apache.ProxyConfiguration) SdkSyncClientBuilder(software.amazon.awssdk.core.client.builder.SdkSyncClientBuilder) SdkAsyncClientBuilder(software.amazon.awssdk.core.client.builder.SdkAsyncClientBuilder) DefaultClientBuilder(org.apache.beam.sdk.io.aws2.common.ClientBuilderFactory.DefaultClientBuilder) AwsClientBuilder(software.amazon.awssdk.awscore.client.builder.AwsClientBuilder) NettyNioAsyncHttpClient(software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient) Test(org.junit.Test)

Example 3 with ProxyConfiguration

use of software.amazon.awssdk.http.apache.ProxyConfiguration in project beam by apache.

the class AwsModuleTest method testProxyConfigurationSerializationDeserialization.

@Test
public void testProxyConfigurationSerializationDeserialization() throws Exception {
    ProxyConfiguration proxyConfiguration = ProxyConfiguration.builder().endpoint(URI.create("http://localhost:8080")).username("username").password("password").build();
    ProxyConfiguration deserializedProxyConfiguration = serializeAndDeserialize(proxyConfiguration);
    assertEquals("localhost", deserializedProxyConfiguration.host());
    assertEquals(8080, deserializedProxyConfiguration.port());
    assertEquals("username", deserializedProxyConfiguration.username());
    assertEquals("password", deserializedProxyConfiguration.password());
}
Also used : ProxyConfiguration(software.amazon.awssdk.http.apache.ProxyConfiguration) Test(org.junit.Test)

Example 4 with ProxyConfiguration

use of software.amazon.awssdk.http.apache.ProxyConfiguration in project beam by apache.

the class AwsOptionsTest method testSetProxyConfiguration.

@Test
public void testSetProxyConfiguration() {
    AwsOptions options = create("--proxyConfiguration={\"endpoint\":\"https://localhost:8080\", \"username\":\"user\", \"password\":\"pw\"}");
    ProxyConfiguration expected = ProxyConfiguration.builder().endpoint(URI.create("https://localhost:8080")).username("user").password("pw").build();
    assertThat(options.getProxyConfiguration()).isEqualToIgnoringGivenFields(expected, "useSystemPropertyValues");
    assertThat(serializeDeserialize(options).getProxyConfiguration()).isEqualToIgnoringGivenFields(expected, "useSystemPropertyValues");
}
Also used : ProxyConfiguration(software.amazon.awssdk.http.apache.ProxyConfiguration) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ProxyConfiguration (software.amazon.awssdk.http.apache.ProxyConfiguration)4 DefaultClientBuilder (org.apache.beam.sdk.io.aws2.common.ClientBuilderFactory.DefaultClientBuilder)2 AwsClientBuilder (software.amazon.awssdk.awscore.client.builder.AwsClientBuilder)2 SdkAsyncClientBuilder (software.amazon.awssdk.core.client.builder.SdkAsyncClientBuilder)2 SdkSyncClientBuilder (software.amazon.awssdk.core.client.builder.SdkSyncClientBuilder)2 ApacheHttpClient (software.amazon.awssdk.http.apache.ApacheHttpClient)1 NettyNioAsyncHttpClient (software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient)1