8000 Make the HTTP lifecycle bound to the Keycloak instance by ahus1 · Pull Request #54811 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.keycloak.testframework.injection.LifeCycle;
import org.keycloak.testframework.injection.RequestedInstance;
import org.keycloak.testframework.injection.Supplier;
import org.keycloak.testframework.server.KeycloakServer;

import org.apache.http.client.HttpClient;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
Expand All @@ -22,13 +23,17 @@ public class HttpClientSupplier implements Supplier<HttpClient, InjectHttpClient

@Override
public List<Dependency> getDependencies(RequestedInstance<HttpClient, InjectHttpClient> instanceContext) {
return DependenciesBuilder.create(ManagedCertificates.class).build();
// The pooled connections must not outlive the server, as the server can be restarted between test classes
return DependenciesBuilder.create(ManagedCertificates.class).add(KeycloakServer.class).build();
}

@Override
public HttpClient getValue(InstanceContext<HttpClient, InjectHttpClient> instanceContext) {
HttpClientBuilder builder = HttpClientBuilder.create();

// Retrieving the dependency registers this client as its dependent, so it is closed when the server is replaced
instanceContext.getDependency(KeycloakServer.class);

ManagedCertificates managedCerts = instanceContext.getDependency(ManagedCertificates.class);

if (managedCerts.isTlsEnabled()) {
Expand Down
Loading
0