Search in sources :

Example 6 with DefaultKeycloakSessionFactory

use of org.keycloak.services.DefaultKeycloakSessionFactory in project keycloak by keycloak.

the class DefaultHttpClientFactoryTest method createHttpClientProviderWithUnvailableURL.

@Test(expected = SSLPeerUnverifiedException.class)
public void createHttpClientProviderWithUnvailableURL() throws IOException {
    DefaultHttpClientFactory factory = new DefaultHttpClientFactory();
    factory.init(scope(new HashMap<>()));
    KeycloakSession session = new DefaultKeycloakSession(new DefaultKeycloakSessionFactory());
    HttpClientProvider provider = factory.create(session);
    try (CloseableHttpClient httpClient = (CloseableHttpClient) provider.getHttpClient()) {
        Optional<String> testURL = getTestURL();
        Assume.assumeTrue("Could not get test url for domain", testURL.isPresent());
        httpClient.execute(new HttpGet(testURL.get()));
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) DefaultKeycloakSessionFactory(org.keycloak.services.DefaultKeycloakSessionFactory) HashMap(java.util.HashMap) DefaultKeycloakSession(org.keycloak.services.DefaultKeycloakSession) KeycloakSession(org.keycloak.models.KeycloakSession) HttpGet(org.apache.http.client.methods.HttpGet) DefaultKeycloakSession(org.keycloak.services.DefaultKeycloakSession) Test(org.junit.Test)

Aggregations

DefaultKeycloakSessionFactory (org.keycloak.services.DefaultKeycloakSessionFactory)6 Test (org.junit.Test)3 KeycloakSession (org.keycloak.models.KeycloakSession)3 DefaultKeycloakSession (org.keycloak.services.DefaultKeycloakSession)3 HashMap (java.util.HashMap)2 HttpGet (org.apache.http.client.methods.HttpGet)2 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2 Map (java.util.Map)1 CustomChangeException (liquibase.exception.CustomChangeException)1 SetupException (liquibase.exception.SetupException)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 BeforeClass (org.junit.BeforeClass)1 Scope (org.keycloak.Config.Scope)1 AuthorizationSpi (org.keycloak.authorization.AuthorizationSpi)1 DefaultAuthorizationProviderFactory (org.keycloak.authorization.DefaultAuthorizationProviderFactory)1 StoreFactorySpi (org.keycloak.authorization.store.StoreFactorySpi)1 ClusterSpi (org.keycloak.cluster.ClusterSpi)1 ComponentFactoryProviderFactory (org.keycloak.component.ComponentFactoryProviderFactory)1 ComponentFactorySpi (org.keycloak.component.ComponentFactorySpi)1 EventStoreSpi (org.keycloak.events.EventStoreSpi)1