Search in sources :

Example 1 with ProxyMapping

use of org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping in project keycloak by keycloak.

the class ProxyMappingsTest method shouldReturnProxy1ForConfiguredProxyMappingAlternative.

@Test
public void shouldReturnProxy1ForConfiguredProxyMappingAlternative() {
    ProxyMapping proxy = proxyMappings.getProxyFor("www.googleapis.com");
    assertThat(proxy.getProxyHost(), is(notNullValue()));
    assertThat(proxy.getProxyHost().getHostName(), is("proxy1"));
}
Also used : ProxyMapping(org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping) Test(org.junit.Test)

Example 2 with ProxyMapping

use of org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping in project keycloak by keycloak.

the class ProxyMappingsTest method shouldReturnMappingForHttpProxy.

@Test
public void shouldReturnMappingForHttpProxy() {
    ProxyMappings proxyMappings = ProxyMappings.withFixedProxyMapping("https://some-proxy.redhat.com:8080", null);
    ProxyMapping forGoogle = proxyMappings.getProxyFor("login.google.com");
    assertEquals("some-proxy.redhat.com", forGoogle.getProxyHost().getHostName());
}
Also used : ProxyMapping(org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping) Test(org.junit.Test)

Example 3 with ProxyMapping

use of org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping in project keycloak by keycloak.

the class ProxyMappingsTest method shouldReturnProxy2ForConfiguredProxyMapping.

@Test
public void shouldReturnProxy2ForConfiguredProxyMapping() {
    ProxyMapping proxy = proxyMappings.getProxyFor("login.facebook.com");
    assertThat(proxy.getProxyHost(), is(notNullValue()));
    assertThat(proxy.getProxyHost().getHostName(), is("proxy2"));
}
Also used : ProxyMapping(org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping) Test(org.junit.Test)

Example 4 with ProxyMapping

use of org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping in project keycloak by keycloak.

the class ProxyMappingsTest method shouldReturnFallbackForNotExplicitlyMappedHostname.

@Test
public void shouldReturnFallbackForNotExplicitlyMappedHostname() {
    ProxyMappings proxyMappingsWithFallback = ProxyMappings.valueOf(MAPPINGS_WITH_FALLBACK);
    ProxyMapping proxy = proxyMappingsWithFallback.getProxyFor("login.salesforce.com");
    assertThat(proxy.getProxyHost().getHostName(), is("fallback"));
}
Also used : ProxyMapping(org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping) Test(org.junit.Test)

Example 5 with ProxyMapping

use of org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping in project keycloak by keycloak.

the class ProxyMappingsTest method shouldReturnFallbackForNotExplicitlyMappedHostnameAndHonorProxyExceptions.

@Test
public void shouldReturnFallbackForNotExplicitlyMappedHostnameAndHonorProxyExceptions() {
    ProxyMappings proxyMappingsWithFallbackAndProxyException = ProxyMappings.valueOf(MAPPINGS_WITH_FALLBACK_AND_PROXY_EXCEPTION);
    ProxyMapping forGoogle = proxyMappingsWithFallbackAndProxyException.getProxyFor("login.google.com");
    assertThat(forGoogle.getProxyHost().getHostName(), is("proxy1"));
    ProxyMapping forFacebook = proxyMappingsWithFallbackAndProxyException.getProxyFor("login.facebook.com");
    assertThat(forFacebook.getProxyHost().getHostName(), is("proxy2"));
    ProxyMapping forAcmeCorp = proxyMappingsWithFallbackAndProxyException.getProxyFor("myapp.acme.corp.com");
    assertThat(forAcmeCorp.getProxyHost(), is(nullValue()));
    ProxyMapping forMicrosoft = proxyMappingsWithFallbackAndProxyException.getProxyFor("login.microsoft.com");
    assertThat(forMicrosoft.getProxyHost().getHostName(), is("fallback"));
    ProxyMapping forSalesForce = proxyMappingsWithFallbackAndProxyException.getProxyFor("login.salesforce.com");
    assertThat(forSalesForce.getProxyHost().getHostName(), is("fallback"));
}
Also used : ProxyMapping(org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping) Test(org.junit.Test)

Aggregations

ProxyMapping (org.keycloak.connections.httpclient.ProxyMappings.ProxyMapping)11 Test (org.junit.Test)10 HttpHost (org.apache.http.HttpHost)1 AuthScope (org.apache.http.auth.AuthScope)1 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)1 CredentialsProvider (org.apache.http.client.CredentialsProvider)1 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)1