use of io.dropwizard.client.proxy.ProxyConfiguration in project dropwizard by dropwizard.
the class HttpClientBuilderTest method usesProxyWithAuth.
@Test
public void usesProxyWithAuth() throws Exception {
HttpClientConfiguration config = new HttpClientConfiguration();
AuthConfiguration auth = new AuthConfiguration("secret", "stuff");
ProxyConfiguration proxy = new ProxyConfiguration("192.168.52.11", 8080, "http", auth);
config.setProxyConfiguration(proxy);
CloseableHttpClient httpClient = checkProxy(config, new HttpHost("dropwizard.io", 80), new HttpHost("192.168.52.11", 8080, "http"));
CredentialsProvider credentialsProvider = (CredentialsProvider) FieldUtils.getField(httpClient.getClass(), "credentialsProvider", true).get(httpClient);
assertThat(credentialsProvider.getCredentials(new AuthScope("192.168.52.11", 8080))).isEqualTo(new UsernamePasswordCredentials("secret", "stuff"));
}
use of io.dropwizard.client.proxy.ProxyConfiguration in project dropwizard by dropwizard.
the class HttpClientBuilderTest method usesProxy.
@Test
void usesProxy() throws Exception {
HttpClientConfiguration config = new HttpClientConfiguration();
ProxyConfiguration proxy = new ProxyConfiguration("192.168.52.11", 8080);
config.setProxyConfiguration(proxy);
checkProxy(config, new HttpHost("dropwizard.io", 80), new HttpHost("192.168.52.11", 8080));
}
use of io.dropwizard.client.proxy.ProxyConfiguration in project dropwizard by dropwizard.
the class HttpClientBuilderTest method usesProxyWithoutPort.
@Test
void usesProxyWithoutPort() throws Exception {
HttpClientConfiguration config = new HttpClientConfiguration();
ProxyConfiguration proxy = new ProxyConfiguration("192.168.52.11");
config.setProxyConfiguration(proxy);
checkProxy(config, new HttpHost("dropwizard.io", 80), new HttpHost("192.168.52.11"));
}
use of io.dropwizard.client.proxy.ProxyConfiguration in project dropwizard by dropwizard.
the class HttpClientBuilderTest method usesProxyWithNtlmAuth.
@Test
void usesProxyWithNtlmAuth() throws Exception {
HttpClientConfiguration config = new HttpClientConfiguration();
AuthConfiguration auth = new AuthConfiguration("secret", "stuff", "NTLM", "realm", "host", "domain", "NT");
ProxyConfiguration proxy = new ProxyConfiguration("192.168.52.11", 8080, "http", auth);
config.setProxyConfiguration(proxy);
CloseableHttpClient httpClient = checkProxy(config, new HttpHost("dropwizard.io", 80), new HttpHost("192.168.52.11", 8080, "http"));
CredentialsProvider credentialsProvider = (CredentialsProvider) getInaccessibleField(httpClient.getClass(), "credentialsProvider").get(httpClient);
AuthScope authScope = new AuthScope("192.168.52.11", 8080, "realm", "NTLM");
Credentials credentials = new NTCredentials("secret", "stuff", "host", "domain");
assertThat(credentialsProvider.getCredentials(authScope)).isEqualTo(credentials);
}
use of io.dropwizard.client.proxy.ProxyConfiguration in project dropwizard by dropwizard.
the class HttpClientBuilderTest method usesProxyWithNonProxyHostsAndTargetDoesNotMatch.
@Test
void usesProxyWithNonProxyHostsAndTargetDoesNotMatch() throws Exception {
HttpClientConfiguration config = new HttpClientConfiguration();
ProxyConfiguration proxy = new ProxyConfiguration("192.168.52.11");
proxy.setNonProxyHosts(Collections.singletonList("*.example.com"));
config.setProxyConfiguration(proxy);
checkProxy(config, new HttpHost("dropwizard.io", 80), new HttpHost("192.168.52.11"));
}
Aggregations