Skip to content

Commit

Permalink
KEYCLOAK-13770 Working FixedHostnameTest for Quarkus
Browse files Browse the repository at this point in the history
  • Loading branch information
DGuhr authored and pedroigor committed Sep 28, 2021
1 parent 12c7bc7 commit 82964f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {

try {
deployArchiveToServer(archive);
restartServer();
restartServer(true);
} catch (Exception e) {
throw new DeploymentException(e.getMessage(),e);
}
Expand All @@ -111,7 +111,7 @@ public void undeploy(Archive<?> archive) throws DeploymentException {
File wrkDir = configuration.getProvidersPath().resolve("providers").toFile();
try {
Files.deleteIfExists(wrkDir.toPath().resolve(archive.getName()));
restartServer();
restartServer(true);
} catch (Exception e) {
throw new DeploymentException(e.getMessage(),e);
}
Expand Down Expand Up @@ -149,7 +149,6 @@ private Process startContainer() throws IOException {
List<String> commands = new ArrayList<>(Arrays.asList("./kc.sh", "config", "-Dquarkus.http.root-path=/auth", "--http-enabled=true"));

addAdditionalCommands(commands);

ProcessBuilder reaugment = new ProcessBuilder(commands);

reaugment.directory(wrkDir).inheritIO();
Expand Down Expand Up @@ -311,8 +310,10 @@ private void deployArchiveToServer(Archive<?> archive) throws IOException {
Files.copy(zipStream, providersDir.toPath().resolve(archive.getName()), StandardCopyOption.REPLACE_EXISTING);
}

private void restartServer() throws Exception {
forceReaugmentation = true;
private void restartServer(boolean isReaugmentation) throws Exception {
if(isReaugmentation) {
forceReaugmentation = true;
}
stop();
start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import org.jboss.arquillian.container.test.api.ContainerController;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.logging.Logger;
import org.keycloak.common.util.SystemEnvProperties;
import org.keycloak.testsuite.AbstractKeycloakTest;
import org.keycloak.testsuite.arquillian.AuthServerTestEnricher;
import org.keycloak.testsuite.arquillian.containers.KeycloakQuarkusServerDeployableContainer;
import org.wildfly.extras.creaper.core.online.ModelNodeResult;
import org.wildfly.extras.creaper.core.online.OnlineManagementClient;
import org.wildfly.extras.creaper.core.online.operations.admin.Administration;

Expand All @@ -18,6 +16,8 @@ public abstract class AbstractHostnameTest extends AbstractKeycloakTest {

private static final Logger LOGGER = Logger.getLogger(AbstractHostnameTest.class);

private boolean isReaugmentationNeeded;

@ArquillianResource
protected ContainerController controller;

Expand All @@ -42,7 +42,7 @@ void reset() throws Exception {
} else if (suiteContext.getAuthServerInfo().isQuarkus()) {
controller.stop(suiteContext.getAuthServerInfo().getQualifier());
KeycloakQuarkusServerDeployableContainer container = (KeycloakQuarkusServerDeployableContainer)suiteContext.getAuthServerInfo().getArquillianContainer().getDeployableContainer();
container.resetConfiguration(false);
container.resetConfiguration(isReaugmentationNeeded);
controller.start(suiteContext.getAuthServerInfo().getQualifier());
} else {
throw new RuntimeException("Don't know how to config");
Expand Down Expand Up @@ -81,6 +81,7 @@ void configureDefault(String frontendUrl, boolean forceBackendUrlToFrontendUrl,
}
container.setRuntimeProperties(runtimeProperties);
controller.start(suiteContext.getAuthServerInfo().getQualifier());
isReaugmentationNeeded = false;
} else {
throw new RuntimeException("Don't know how to config");
}
Expand All @@ -105,13 +106,13 @@ void configureFixed(String hostname, int httpPort, int httpsPort, boolean always
} else if (suiteContext.getAuthServerInfo().isQuarkus()) {
controller.stop(suiteContext.getAuthServerInfo().getQualifier());
KeycloakQuarkusServerDeployableContainer container = (KeycloakQuarkusServerDeployableContainer)suiteContext.getAuthServerInfo().getArquillianContainer().getDeployableContainer();
List<String> runtimeProperties = new ArrayList<>();
runtimeProperties.add("--spi-hostname-fixed-hostname="+hostname);
runtimeProperties.add("--spi-hostname-fixed-http-port="+ httpPort);
runtimeProperties.add("--spi-hostname-fixed-https-port="+ httpsPort);
runtimeProperties.add("--spi-hostname-fixed-always-https="+ alwaysHttps);
container.setRuntimeProperties(runtimeProperties);
container.forceReAugmentation("--spi-hostname-provider=fixed" +
" --spi-hostname-fixed-hostname="+ hostname +
" --spi-hostname-fixed-http-port="+ httpPort +
" --spi-hostname-fixed-https-port="+ httpsPort +
" --spi-hostname-fixed-always-https="+ alwaysHttps);
controller.start(suiteContext.getAuthServerInfo().getQualifier());
isReaugmentationNeeded = true;
} else {
throw new RuntimeException("Don't know how to config");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.QUARKUS;
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.REMOTE;

@AuthServerContainerExclude({REMOTE, QUARKUS})
@AuthServerContainerExclude({REMOTE})
public class FixedHostnameTest extends AbstractHostnameTest {

public static final String SAML_CLIENT_ID = "http://whatever.hostname:8280/app/";
Expand Down

0 comments on commit 82964f7

Please sign in to comment.