Skip to content

Commit

Permalink
Testsuite PoC - distribution server run mode. (keycloak#31186)
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Hanusovsky <[email protected]>
  • Loading branch information
lhanusov authored Jul 15, 2024
1 parent 17af757 commit 72fb64f
Showing 1 changed file with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@
package org.keycloak.test.framework.server;

import org.keycloak.it.utils.RawKeycloakDistribution;

import java.util.LinkedList;
import java.util.List;

public class DistributionKeycloakTestServer implements KeycloakTestServer {

private boolean debug = false;
private boolean manualStop = true;
private boolean enableTls = false;
private boolean reCreate = false;
private boolean removeBuildOptionsAfterBuild = false;
private int requestPort = 8080;
private RawKeycloakDistribution keycloak;

@Override
public void start(KeycloakTestServerConfig serverConfig) {
throw new RuntimeException("Method not implemented!");
keycloak = new RawKeycloakDistribution(debug, manualStop, enableTls, reCreate, removeBuildOptionsAfterBuild, requestPort);

// Set environment variables user and password for Keycloak Admin used by Keycloak instance.
keycloak.setEnvVar("KC_BOOTSTRAP_ADMIN_USERNAME", serverConfig.adminUserName().get());
keycloak.setEnvVar("KC_BOOTSTRAP_ADMIN_PASSWORD", serverConfig.adminUserPassword().get());

List<String> rawOptions = new LinkedList<>();
rawOptions.add("start-dev");

//rawOptions.add("--db=dev-mem"); // TODO With dev-mem there's an issue as the H2 DB isn't stopped when restarting embedded server
rawOptions.add("--cache=local");

if (!serverConfig.features().isEmpty()) {
rawOptions.add("--features=" + String.join(",", serverConfig.features()));
}

serverConfig.options().forEach((key, value) -> rawOptions.add("--" + key + "=" + value));

keycloak.run(rawOptions).assertStartedDevMode();
}

@Override
public void stop() {
throw new RuntimeException("Method not implemented!");
keycloak.stop();
}

@Override
Expand Down

0 comments on commit 72fb64f

Please sign in to comment.