use of org.keycloak.services.DefaultKeycloakSession in project keycloak by keycloak.
the class PlainTextVaultProviderFactoryTest method shouldInitializeVaultCorrectly.
@Test
public void shouldInitializeVaultCorrectly() {
// given
VaultConfig config = new VaultConfig(Scenario.EXISTING.getAbsolutePathAsString());
KeycloakSession session = new DefaultKeycloakSession(new DefaultKeycloakSessionFactory());
FilesPlainTextVaultProviderFactory factory = new FilesPlainTextVaultProviderFactory() {
@Override
protected String getRealmName(KeycloakSession session) {
return "test";
}
};
// when
factory.init(config);
VaultProvider provider = factory.create(session);
// then
assertNotNull(provider);
}
use of org.keycloak.services.DefaultKeycloakSession in project keycloak by keycloak.
the class DefaultHttpClientFactoryTest method createHttpClientProviderWithDisableTrustManager.
@Test
public void createHttpClientProviderWithDisableTrustManager() throws IOException {
Map<String, String> values = new HashMap<>();
values.put(DISABLE_TRUST_MANAGER_PROPERTY, "true");
DefaultHttpClientFactory factory = new DefaultHttpClientFactory();
factory.init(scope(values));
KeycloakSession session = new DefaultKeycloakSession(new DefaultKeycloakSessionFactory());
HttpClientProvider provider = factory.create(session);
Optional<String> testURL = getTestURL();
Assume.assumeTrue("Could not get test url for domain", testURL.isPresent());
try (CloseableHttpClient httpClient = (CloseableHttpClient) provider.getHttpClient();
CloseableHttpResponse response = httpClient.execute(new HttpGet(testURL.get()))) {
assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatusLine().getStatusCode());
}
}
use of org.keycloak.services.DefaultKeycloakSession 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()));
}
}
Aggregations