[KEYCLOAK-11330] - Initial changes to get testsuite working for Quarkus

This commit is contained in:
Pedro Igor 2020-06-02 16:18:22 -03:00
parent ddeaa6b3c4
commit 357982adf6
9 changed files with 27 additions and 12 deletions

View file

@ -73,15 +73,9 @@ class KeycloakProcessor {
Map<Spi, Set<Class<? extends ProviderFactory>>> result = new HashMap<>(); Map<Spi, Set<Class<? extends ProviderFactory>>> result = new HashMap<>();
for (Spi spi : pm.loadSpis()) { for (Spi spi : pm.loadSpis()) {
List<ProviderFactory> loaded = pm.load(spi);
if (loaded.isEmpty()) {
continue;
}
Set<Class<? extends ProviderFactory>> factories = new HashSet<>(); Set<Class<? extends ProviderFactory>> factories = new HashSet<>();
for (ProviderFactory factory : loaded) { for (ProviderFactory factory : pm.load(spi)) {
if (Arrays.asList( if (Arrays.asList(
JBossJtaTransactionManagerLookup.class, JBossJtaTransactionManagerLookup.class,
DefaultJpaConnectionProviderFactory.class, DefaultJpaConnectionProviderFactory.class,

View file

@ -381,8 +381,6 @@ public class QuarkusJpaConnectionProviderFactory implements JpaConnectionProvide
if (createMasterRealm) { if (createMasterRealm) {
applianceBootstrap.createMasterRealm(); applianceBootstrap.createMasterRealm();
//TODO: Remove this to reduce startup time. See https://issues.redhat.com/browse/KEYCLOAK-14308.
DefaultKeyProviders.createProviders(session.getContext().getRealm());
} }
session.getTransactionManager().commit(); session.getTransactionManager().commit();

View file

@ -19,6 +19,8 @@ package org.keycloak.provider.quarkus;
import io.vertx.core.http.HttpServerRequest; import io.vertx.core.http.HttpServerRequest;
import io.vertx.ext.web.RoutingContext; import io.vertx.ext.web.RoutingContext;
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters;
import org.jboss.resteasy.spi.ResteasyDeployment;
import org.keycloak.common.ClientConnection; import org.keycloak.common.ClientConnection;
import org.keycloak.common.util.Resteasy; import org.keycloak.common.util.Resteasy;
import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSession;
@ -47,6 +49,12 @@ public class QuarkusFilter implements javax.ws.rs.container.ContainerRequestFilt
@Inject @Inject
RoutingContext routingContext; RoutingContext routingContext;
public QuarkusFilter() {
//TODO: a temporary hack for https://github.com/quarkusio/quarkus/issues/9647, we need to disable the sanitizer to avoid
// escaping text/html responses from the server
Resteasy.getContextData(ResteasyDeployment.class).setProperty(ResteasyContextParameters.RESTEASY_DISABLE_HTML_SANITIZER, Boolean.TRUE);
}
@Override @Override
public void filter(ContainerRequestContext containerRequestContext) { public void filter(ContainerRequestContext containerRequestContext) {
KeycloakSessionFactory sessionFactory = keycloakApplication.getSessionFactory(); KeycloakSessionFactory sessionFactory = keycloakApplication.getSessionFactory();

View file

@ -1,4 +1,4 @@
#quarkus.log.level = DEBUG #quarkus.log.level = DEBUG
quarkus.http.root-path=/auth quarkus.http.root-path=/auth
quarkus.application.name=Keycloak quarkus.application.name=Keycloak
resteasy.disable.html.sanitizer = true quarkus.banner.enabled=false

View file

@ -159,6 +159,10 @@ public class AuthServerTestEnricher {
return AUTH_SERVER_CONTAINER.equals("auth-server-remote"); return AUTH_SERVER_CONTAINER.equals("auth-server-remote");
} }
public static boolean isAuthServerQuarkus() {
return AUTH_SERVER_CONTAINER.equals("auth-server-quarkus");
}
public static String getAuthServerContextRoot() { public static String getAuthServerContextRoot() {
return getAuthServerContextRoot(0); return getAuthServerContextRoot(0);
} }

View file

@ -41,6 +41,7 @@ public @interface AuthServerContainerExclude {
AuthServer[] value(); AuthServer[] value();
public enum AuthServer { public enum AuthServer {
REMOTE REMOTE,
QUARKUS
} }
} }

View file

@ -131,6 +131,8 @@ public class KeycloakQuarkusServerDeployableContainer implements DeployableConta
} }
try { try {
// wait before checking for opening a new connection
Thread.sleep(1000);
connection = (HttpURLConnection) contextRoot.openConnection(); connection = (HttpURLConnection) contextRoot.openConnection();
connection.setReadTimeout((int) getStartTimeout()); connection.setReadTimeout((int) getStartTimeout());

View file

@ -51,6 +51,10 @@ public class AuthServerExcludeExecutionDecider implements TestExecutionDecider {
if (AuthServerTestEnricher.isAuthServerRemote() && excluded.contains(AuthServer.REMOTE)) { if (AuthServerTestEnricher.isAuthServerRemote() && excluded.contains(AuthServer.REMOTE)) {
return ExecutionDecision.dontExecute("Excluded by @AuthServerContainerExclude."); return ExecutionDecision.dontExecute("Excluded by @AuthServerContainerExclude.");
} }
if (AuthServerTestEnricher.isAuthServerQuarkus() && excluded.contains(AuthServer.QUARKUS)) {
return ExecutionDecision.dontExecute("Excluded by @AuthServerContainerExclude.");
}
} else { //class } else { //class
if (testContext.getTestClass().isAnnotationPresent(AuthServerContainerExclude.class)) { if (testContext.getTestClass().isAnnotationPresent(AuthServerContainerExclude.class)) {
List<AuthServer> excluded = Arrays.asList(((AuthServerContainerExclude) testContext.getTestClass().getAnnotation(AuthServerContainerExclude.class)).value()); List<AuthServer> excluded = Arrays.asList(((AuthServerContainerExclude) testContext.getTestClass().getAnnotation(AuthServerContainerExclude.class)).value());
@ -58,6 +62,10 @@ public class AuthServerExcludeExecutionDecider implements TestExecutionDecider {
if (AuthServerTestEnricher.isAuthServerRemote() && excluded.contains(AuthServer.REMOTE)) { if (AuthServerTestEnricher.isAuthServerRemote() && excluded.contains(AuthServer.REMOTE)) {
return ExecutionDecision.dontExecute("Excluded by @AuthServerContainerExclude."); return ExecutionDecision.dontExecute("Excluded by @AuthServerContainerExclude.");
} }
if (AuthServerTestEnricher.isAuthServerQuarkus() && excluded.contains(AuthServer.QUARKUS)) {
return ExecutionDecision.dontExecute("Excluded by @AuthServerContainerExclude.");
}
} }
} }

View file

@ -66,7 +66,7 @@ import static org.keycloak.testsuite.admin.ApiUtil.findUserByUsername;
* *
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a> * @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
*/ */
@AuthServerContainerExclude(AuthServer.REMOTE) @AuthServerContainerExclude({AuthServer.REMOTE, AuthServer.QUARKUS})
@EnableFeature(value = OPENSHIFT_INTEGRATION, skipRestart = true) @EnableFeature(value = OPENSHIFT_INTEGRATION, skipRestart = true)
public final class OpenshiftClientStorageTest extends AbstractTestRealmKeycloakTest { public final class OpenshiftClientStorageTest extends AbstractTestRealmKeycloakTest {