diff --git a/test-framework/bom/pom.xml b/test-framework/bom/pom.xml
new file mode 100755
index 0000000000..890effeb19
--- /dev/null
+++ b/test-framework/bom/pom.xml
@@ -0,0 +1,80 @@
+
+
+
+
+
+ keycloak-test-framework-parent
+ org.keycloak.test
+ 999.0.0-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+
+ keycloak-test-framework-bom
+ Keycloak Test Framework - BOM
+ pom
+ BOM for Keycloak Test Framework
+
+
+
+
+ org.keycloak.test
+ keycloak-test-framework-core
+ ${project.version}
+ test
+
+
+ org.keycloak.test
+ keycloak-test-framework-ui
+ ${project.version}
+ test
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-mariadb
+ ${project.version}
+ test
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-mssql
+ ${project.version}
+ test
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-mysql
+ ${project.version}
+ test
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-oracle
+ ${project.version}
+ test
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-postgres
+ ${project.version}
+ test
+
+
+
+
diff --git a/test-framework/core/pom.xml b/test-framework/core/pom.xml
index 00648afd07..37aa9a86ec 100755
--- a/test-framework/core/pom.xml
+++ b/test-framework/core/pom.xml
@@ -44,30 +44,6 @@
org.keycloak
keycloak-junit5
-
- org.testcontainers
- junit-jupiter
-
-
- org.testcontainers
- postgresql
-
-
- org.testcontainers
- mariadb
-
-
- org.testcontainers
- mysql
-
-
- org.testcontainers
- mssqlserver
-
-
- org.testcontainers
- oracle-free
-
com.nimbusds
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/CoreTestFrameworkExtension.java b/test-framework/core/src/main/java/org/keycloak/test/framework/CoreTestFrameworkExtension.java
index 859723dba5..5c12fa543c 100644
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/CoreTestFrameworkExtension.java
+++ b/test-framework/core/src/main/java/org/keycloak/test/framework/CoreTestFrameworkExtension.java
@@ -3,11 +3,6 @@ package org.keycloak.test.framework;
import org.keycloak.test.framework.admin.KeycloakAdminClientSupplier;
import org.keycloak.test.framework.database.DevFileDatabaseSupplier;
import org.keycloak.test.framework.database.DevMemDatabaseSupplier;
-import org.keycloak.test.framework.database.MSSQLServerDatabaseSupplier;
-import org.keycloak.test.framework.database.MariaDBDatabaseSupplier;
-import org.keycloak.test.framework.database.MySQLDatabaseSupplier;
-import org.keycloak.test.framework.database.OracleDatabaseSupplier;
-import org.keycloak.test.framework.database.PostgresDatabaseSupplier;
import org.keycloak.test.framework.database.TestDatabase;
import org.keycloak.test.framework.events.EventsSupplier;
import org.keycloak.test.framework.events.SysLogServerSupplier;
@@ -38,11 +33,6 @@ public class CoreTestFrameworkExtension implements TestFrameworkExtension {
new RemoteKeycloakTestServerSupplier(),
new DevMemDatabaseSupplier(),
new DevFileDatabaseSupplier(),
- new MySQLDatabaseSupplier(),
- new PostgresDatabaseSupplier(),
- new MariaDBDatabaseSupplier(),
- new MSSQLServerDatabaseSupplier(),
- new OracleDatabaseSupplier(),
new OAuthClientSupplier(),
new SysLogServerSupplier(),
new EventsSupplier()
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/database/AbstractContainerTestDatabase.java b/test-framework/core/src/main/java/org/keycloak/test/framework/database/AbstractContainerTestDatabase.java
new file mode 100644
index 0000000000..a949043de8
--- /dev/null
+++ b/test-framework/core/src/main/java/org/keycloak/test/framework/database/AbstractContainerTestDatabase.java
@@ -0,0 +1,58 @@
+package org.keycloak.test.framework.database;
+
+import org.jboss.logging.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.JdbcDatabaseContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+
+import java.io.IOException;
+import java.time.Duration;
+import java.util.Map;
+
+public abstract class AbstractContainerTestDatabase implements TestDatabase {
+
+ private static final Logger LOGGER = Logger.getLogger(AbstractContainerTestDatabase.class);
+
+ private JdbcDatabaseContainer> container;
+
+ @SuppressWarnings("resource")
+ public void start() {
+ container = createContainer();
+ container.withStartupTimeout(Duration.ofMinutes(30))
+ .withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(AbstractContainerTestDatabase.class)))
+ .start();
+ try {
+ String postStartCommand = getPostStartCommand();
+ if (postStartCommand != null) {
+ LOGGER.tracev("Running post start command: {0}", postStartCommand);
+ String result = container.execInContainer("bash", "-c", postStartCommand).getStdout();
+ LOGGER.tracev(result);
+ }
+ } catch (IOException | InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stop() {
+ container.stop();
+ }
+
+ @Override
+ public Map serverConfig() {
+ return Map.of(
+ "db", getKeycloakDatabaseName(),
+ "db-url", container.getJdbcUrl(),
+ "db-username", container.getUsername(),
+ "db-password", container.getPassword()
+ );
+ }
+
+ public abstract JdbcDatabaseContainer> createContainer();
+
+ public String getPostStartCommand() {
+ return null;
+ }
+
+ public abstract String getKeycloakDatabaseName();
+
+}
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/database/AbstractDatabaseSupplier.java b/test-framework/core/src/main/java/org/keycloak/test/framework/database/AbstractDatabaseSupplier.java
index 4b7f7ce1cf..9c2f130ff4 100644
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/database/AbstractDatabaseSupplier.java
+++ b/test-framework/core/src/main/java/org/keycloak/test/framework/database/AbstractDatabaseSupplier.java
@@ -8,9 +8,6 @@ import org.keycloak.test.framework.injection.Supplier;
public abstract class AbstractDatabaseSupplier implements Supplier {
- protected static final String DEFAULT_DB_USERNAME = "keycloak";
- protected static final String DEFAULT_DB_PASSWORD = "Password1!";
-
@Override
public Class getAnnotationClass() {
return InjectTestDatabase.class;
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/database/DevFileDatabaseSupplier.java b/test-framework/core/src/main/java/org/keycloak/test/framework/database/DevFileDatabaseSupplier.java
index 5ac8ac6540..45108dcd97 100644
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/database/DevFileDatabaseSupplier.java
+++ b/test-framework/core/src/main/java/org/keycloak/test/framework/database/DevFileDatabaseSupplier.java
@@ -1,17 +1,34 @@
package org.keycloak.test.framework.database;
+import java.util.Map;
+
public class DevFileDatabaseSupplier extends AbstractDatabaseSupplier {
- public static final String VENDOR = "dev-file";
+ @Override
+ public String getAlias() {
+ return "dev-file";
+ }
@Override
TestDatabase getTestDatabase() {
- DatabaseConfig databaseConfig = new DatabaseConfig().vendor(VENDOR);
- return new TestDatabase(databaseConfig);
+ return new DevFileTestDatabase();
}
- @Override
- public String getAlias() {
- return VENDOR;
+ private static class DevFileTestDatabase implements TestDatabase {
+
+ @Override
+ public void start() {
+ }
+
+ @Override
+ public void stop() {
+ // TODO Should we clean-up H2 database here?
+ }
+
+ @Override
+ public Map serverConfig() {
+ return Map.of("db", "dev-file");
+ }
}
+
}
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/database/DevMemDatabaseSupplier.java b/test-framework/core/src/main/java/org/keycloak/test/framework/database/DevMemDatabaseSupplier.java
index 063f7cb319..6e5c489246 100644
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/database/DevMemDatabaseSupplier.java
+++ b/test-framework/core/src/main/java/org/keycloak/test/framework/database/DevMemDatabaseSupplier.java
@@ -1,17 +1,33 @@
package org.keycloak.test.framework.database;
+import java.util.Map;
+
public class DevMemDatabaseSupplier extends AbstractDatabaseSupplier {
- public static final String VENDOR = "dev-mem";
+ @Override
+ public String getAlias() {
+ return "dev-mem";
+ }
@Override
TestDatabase getTestDatabase() {
- DatabaseConfig databaseConfig = new DatabaseConfig().vendor(VENDOR);
- return new TestDatabase(databaseConfig);
+ return new DevMemTestDatabase();
}
- @Override
- public String getAlias() {
- return VENDOR;
+ private static class DevMemTestDatabase implements TestDatabase {
+
+ @Override
+ public void start() {
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ @Override
+ public Map serverConfig() {
+ return Map.of("db", "dev-mem");
+ }
}
+
}
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/database/MSSQLServerDatabaseSupplier.java b/test-framework/core/src/main/java/org/keycloak/test/framework/database/MSSQLServerDatabaseSupplier.java
deleted file mode 100644
index 18da13e97c..0000000000
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/database/MSSQLServerDatabaseSupplier.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.keycloak.test.framework.database;
-
-public class MSSQLServerDatabaseSupplier extends AbstractDatabaseSupplier {
- public static final String VENDOR = "mssql";
-
- @Override
- TestDatabase getTestDatabase() {
- DatabaseConfig databaseConfig = new DatabaseConfig()
- .vendor(VENDOR)
- .containerImage("mcr.microsoft.com/mssql/server:latest");
- return new TestDatabase(databaseConfig);
- }
-
- @Override
- public String getAlias() {
- return VENDOR;
- }
-}
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/database/MariaDBDatabaseSupplier.java b/test-framework/core/src/main/java/org/keycloak/test/framework/database/MariaDBDatabaseSupplier.java
deleted file mode 100644
index 95c929a536..0000000000
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/database/MariaDBDatabaseSupplier.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.keycloak.test.framework.database;
-
-public class MariaDBDatabaseSupplier extends AbstractDatabaseSupplier {
- public static final String VENDOR = "mariadb";
-
- @Override
- TestDatabase getTestDatabase() {
- DatabaseConfig databaseConfig = new DatabaseConfig()
- .vendor(VENDOR)
- .username(DEFAULT_DB_USERNAME)
- .password(DEFAULT_DB_PASSWORD)
- .containerImage("mariadb:latest");
- return new TestDatabase(databaseConfig);
- }
-
- @Override
- public String getAlias() {
- return VENDOR;
- }
-}
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/database/MySQLDatabaseSupplier.java b/test-framework/core/src/main/java/org/keycloak/test/framework/database/MySQLDatabaseSupplier.java
deleted file mode 100644
index 94b81f7f78..0000000000
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/database/MySQLDatabaseSupplier.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.keycloak.test.framework.database;
-
-public class MySQLDatabaseSupplier extends AbstractDatabaseSupplier {
-
- public static final String VENDOR = "mysql";
-
- @Override
- TestDatabase getTestDatabase() {
- DatabaseConfig databaseConfig = new DatabaseConfig()
- .vendor(VENDOR)
- .username(DEFAULT_DB_USERNAME)
- .password(DEFAULT_DB_PASSWORD)
- .containerImage("mysql:latest");
- return new TestDatabase(databaseConfig);
- }
-
- @Override
- public String getAlias() {
- return VENDOR;
- }
-}
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/database/OracleDatabaseSupplier.java b/test-framework/core/src/main/java/org/keycloak/test/framework/database/OracleDatabaseSupplier.java
deleted file mode 100644
index 35726b9321..0000000000
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/database/OracleDatabaseSupplier.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.keycloak.test.framework.database;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class OracleDatabaseSupplier extends AbstractDatabaseSupplier {
-
- public static final String VENDOR = "oracle";
- private static final String CONTAINER_IMAGE = "docker.io/miquelsi/oracle-19c:19.3";
-
- @Override
- TestDatabase getTestDatabase() {
- Map env = new HashMap<>();
- env.put("ORACLE_SID", "keycloak");
- env.put("ORACLE_PWD", "sa");
- DatabaseConfig databaseConfig = new DatabaseConfig()
- .vendor(VENDOR)
- .username(DEFAULT_DB_USERNAME)
- .password(DEFAULT_DB_PASSWORD)
- .postStartCommand("(echo 'alter session set \"_ORACLE_SCRIPT\"=true;' && echo 'CREATE USER " +
- DEFAULT_DB_USERNAME + " IDENTIFIED BY \"" +
- DEFAULT_DB_PASSWORD + "\";' && echo 'GRANT CONNECT,RESOURCE,DBA,GRANT ANY PRIVILEGE,UNLIMITED TABLESPACE TO " +
- DEFAULT_DB_USERNAME + ";') | sqlplus -L SYS/" + env.get("ORACLE_PWD") + "@localhost/" + env.get("ORACLE_SID") + " AS SYSDBA")
- .containerImage(CONTAINER_IMAGE)
- .env(env);
-
- return new TestDatabase(databaseConfig);
- }
-
- @Override
- public String getAlias() {
- return VENDOR;
- }
-}
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/database/PostgresDatabaseSupplier.java b/test-framework/core/src/main/java/org/keycloak/test/framework/database/PostgresDatabaseSupplier.java
deleted file mode 100644
index 0fe21f26ed..0000000000
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/database/PostgresDatabaseSupplier.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.keycloak.test.framework.database;
-
-public class PostgresDatabaseSupplier extends AbstractDatabaseSupplier {
-
- public static final String VENDOR = "postgres";
-
- @Override
- TestDatabase getTestDatabase() {
- DatabaseConfig databaseConfig = new DatabaseConfig()
- .vendor(VENDOR)
- .username(DEFAULT_DB_USERNAME)
- .password(DEFAULT_DB_PASSWORD)
- .containerImage("postgres:latest");
- return new TestDatabase(databaseConfig);
- }
-
- @Override
- public String getAlias() {
- return VENDOR;
- }
-}
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/database/TestDatabase.java b/test-framework/core/src/main/java/org/keycloak/test/framework/database/TestDatabase.java
index 659e6d3077..7af4a79763 100644
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/database/TestDatabase.java
+++ b/test-framework/core/src/main/java/org/keycloak/test/framework/database/TestDatabase.java
@@ -1,109 +1,13 @@
package org.keycloak.test.framework.database;
-import org.jboss.logging.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.JdbcDatabaseContainer;
-import org.testcontainers.containers.MSSQLServerContainer;
-import org.testcontainers.containers.MariaDBContainer;
-import org.testcontainers.containers.MySQLContainer;
-import org.testcontainers.containers.PostgreSQLContainer;
-import org.testcontainers.containers.output.Slf4jLogConsumer;
-import org.testcontainers.oracle.OracleContainer;
-import org.testcontainers.utility.DockerImageName;
-
-import java.io.IOException;
-import java.time.Duration;
import java.util.Map;
-public class TestDatabase {
+public interface TestDatabase {
- private static final Logger LOGGER = Logger.getLogger(TestDatabase.class);
+ void start();
- private final DatabaseConfig databaseConfig;
+ void stop();
- private GenericContainer> container;
-
- public TestDatabase(DatabaseConfig databaseConfig) {
- this.databaseConfig = databaseConfig;
- }
-
- public void start() {
- if (databaseConfig.getContainerImage() != null) {
- container = createContainer();
- container.withStartupTimeout(Duration.ofMinutes(30))
- .withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger(TestDatabase.class)))
- .withEnv(databaseConfig.getEnv())
- .start();
- try {
- if (databaseConfig.getPostStartCommand() != null) {
- LOGGER.tracev("Running post start command: " + databaseConfig.getPostStartCommand());
- String result = container.execInContainer("bash", "-c", databaseConfig.getPostStartCommand()).getStdout();
- LOGGER.tracev(result);
- }
- } catch (IOException | InterruptedException e) {
- throw new RuntimeException(e);
- }
- databaseConfig.url(getJdbcUrl());
- if (container instanceof MSSQLServerContainer) {
- databaseConfig.username(((JdbcDatabaseContainer>) container).getUsername());
- databaseConfig.password(((JdbcDatabaseContainer>) container).getPassword());
- }
- }
- }
-
- public void stop() {
- if (databaseConfig.getContainerImage() != null) {
- container.stop();
- container = null;
- } else if ("dev-mem".equals(databaseConfig.getVendor())) {
- // TODO Stop in-mem H2 database
- }
- }
-
- public Map getServerConfig() {
- return databaseConfig.toConfig();
- }
-
- public String getJdbcUrl() {
- return ((JdbcDatabaseContainer>)container).getJdbcUrl();
- }
-
- private JdbcDatabaseContainer> configureJdbcContainer(JdbcDatabaseContainer> jdbcDatabaseContainer) {
- if (jdbcDatabaseContainer instanceof MSSQLServerContainer) {
- return jdbcDatabaseContainer;
- }
-
- return jdbcDatabaseContainer
- .withDatabaseName("keycloak")
- .withUsername(databaseConfig.getUsername())
- .withPassword(databaseConfig.getPassword());
- }
-
- private GenericContainer> createContainer() {
- return switch (databaseConfig.getVendor()) {
- case PostgresDatabaseSupplier.VENDOR -> {
- DockerImageName POSTGRES = DockerImageName.parse(databaseConfig.getContainerImage());
- yield configureJdbcContainer(new PostgreSQLContainer<>(POSTGRES));
- }
- case MariaDBDatabaseSupplier.VENDOR -> {
- DockerImageName MARIADB = DockerImageName.parse(databaseConfig.getContainerImage());
- yield configureJdbcContainer(new MariaDBContainer<>(MARIADB));
- }
- case MySQLDatabaseSupplier.VENDOR -> {
- DockerImageName MYSQL = DockerImageName.parse(databaseConfig.getContainerImage());
- yield configureJdbcContainer(new MySQLContainer<>(MYSQL));
- }
- case MSSQLServerDatabaseSupplier.VENDOR -> {
- DockerImageName MSSQL = DockerImageName.parse(databaseConfig.getContainerImage());
- yield configureJdbcContainer(new MSSQLServerContainer<>(MSSQL));
- }
- case OracleDatabaseSupplier.VENDOR -> {
- DockerImageName ORACLE = DockerImageName.parse(databaseConfig.getContainerImage());
- yield configureJdbcContainer(new OracleContainer(ORACLE));
- }
- default -> throw new RuntimeException("Unsupported database: " + databaseConfig.getVendor());
- };
- }
+ Map serverConfig();
}
diff --git a/test-framework/core/src/main/java/org/keycloak/test/framework/server/AbstractKeycloakTestServerSupplier.java b/test-framework/core/src/main/java/org/keycloak/test/framework/server/AbstractKeycloakTestServerSupplier.java
index 9ff78d1b39..5f804eee43 100644
--- a/test-framework/core/src/main/java/org/keycloak/test/framework/server/AbstractKeycloakTestServerSupplier.java
+++ b/test-framework/core/src/main/java/org/keycloak/test/framework/server/AbstractKeycloakTestServerSupplier.java
@@ -2,6 +2,7 @@ package org.keycloak.test.framework.server;
import org.keycloak.test.framework.annotations.KeycloakIntegrationTest;
import org.keycloak.test.framework.config.Config;
+import org.keycloak.test.framework.database.AbstractContainerTestDatabase;
import org.keycloak.test.framework.database.TestDatabase;
import org.keycloak.test.framework.events.SysLogServer;
import org.keycloak.test.framework.injection.InstanceContext;
@@ -53,7 +54,7 @@ public abstract class AbstractKeycloakTestServerSupplier implements Supplier rawOptions.add("--" + key + "=" + value));
+ testDatabase.serverConfig().forEach((key, value) -> rawOptions.add("--" + key + "=" + value));
}
KeycloakTestServer server = getServer();
diff --git a/test-framework/db-mariadb/pom.xml b/test-framework/db-mariadb/pom.xml
new file mode 100755
index 0000000000..3e09ab03da
--- /dev/null
+++ b/test-framework/db-mariadb/pom.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+ keycloak-test-framework-parent
+ org.keycloak.test
+ 999.0.0-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+
+ keycloak-test-framework-db-mariadb
+ Keycloak Test Framework - MariaDB support
+ jar
+ MariaDB support for Keycloak Test Framework
+
+
+
+ org.keycloak.test
+ keycloak-test-framework-core
+ ${project.version}
+
+
+ org.testcontainers
+ mariadb
+
+
+
diff --git a/test-framework/db-mariadb/src/main/java/org/keycloak/test/framework/database/MariaDBDatabaseSupplier.java b/test-framework/db-mariadb/src/main/java/org/keycloak/test/framework/database/MariaDBDatabaseSupplier.java
new file mode 100644
index 0000000000..3c19972d48
--- /dev/null
+++ b/test-framework/db-mariadb/src/main/java/org/keycloak/test/framework/database/MariaDBDatabaseSupplier.java
@@ -0,0 +1,15 @@
+package org.keycloak.test.framework.database;
+
+public class MariaDBDatabaseSupplier extends AbstractDatabaseSupplier {
+
+ @Override
+ public String getAlias() {
+ return "mariadb";
+ }
+
+ @Override
+ TestDatabase getTestDatabase() {
+ return new MariaDBTestDatabase();
+ }
+
+}
diff --git a/test-framework/db-mariadb/src/main/java/org/keycloak/test/framework/database/MariaDBTestDatabase.java b/test-framework/db-mariadb/src/main/java/org/keycloak/test/framework/database/MariaDBTestDatabase.java
new file mode 100644
index 0000000000..ad4fa75fb7
--- /dev/null
+++ b/test-framework/db-mariadb/src/main/java/org/keycloak/test/framework/database/MariaDBTestDatabase.java
@@ -0,0 +1,19 @@
+package org.keycloak.test.framework.database;
+
+import org.testcontainers.containers.JdbcDatabaseContainer;
+import org.testcontainers.containers.MariaDBContainer;
+
+class MariaDBTestDatabase extends AbstractContainerTestDatabase {
+
+ private static final String IMAGE_NAME = "mariadb:latest";
+
+ @Override
+ public JdbcDatabaseContainer> createContainer() {
+ return new MariaDBContainer<>(IMAGE_NAME);
+ }
+
+ @Override
+ public String getKeycloakDatabaseName() {
+ return "mariadb";
+ }
+}
diff --git a/test-framework/db-mariadb/src/main/java/org/keycloak/test/framework/database/MariaDBTestFrameworkExtension.java b/test-framework/db-mariadb/src/main/java/org/keycloak/test/framework/database/MariaDBTestFrameworkExtension.java
new file mode 100644
index 0000000000..f88852fd67
--- /dev/null
+++ b/test-framework/db-mariadb/src/main/java/org/keycloak/test/framework/database/MariaDBTestFrameworkExtension.java
@@ -0,0 +1,14 @@
+package org.keycloak.test.framework.database;
+
+import org.keycloak.test.framework.TestFrameworkExtension;
+import org.keycloak.test.framework.injection.Supplier;
+
+import java.util.List;
+
+public class MariaDBTestFrameworkExtension implements TestFrameworkExtension {
+
+ @Override
+ public List> suppliers() {
+ return List.of(new MariaDBDatabaseSupplier());
+ }
+}
diff --git a/test-framework/db-mariadb/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension b/test-framework/db-mariadb/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension
new file mode 100644
index 0000000000..938dd84bbd
--- /dev/null
+++ b/test-framework/db-mariadb/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension
@@ -0,0 +1 @@
+org.keycloak.test.framework.database.MariaDBTestFrameworkExtension
\ No newline at end of file
diff --git a/test-framework/db-mssql/pom.xml b/test-framework/db-mssql/pom.xml
new file mode 100755
index 0000000000..a26ed1d0a4
--- /dev/null
+++ b/test-framework/db-mssql/pom.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+ keycloak-test-framework-parent
+ org.keycloak.test
+ 999.0.0-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+
+ keycloak-test-framework-db-mssql
+ Keycloak Test Framework - SQL Server support
+ jar
+ SQL Server support for Keycloak Test Framework
+
+
+
+ org.keycloak.test
+ keycloak-test-framework-core
+ ${project.version}
+
+
+ org.testcontainers
+ mssqlserver
+
+
+ com.microsoft.sqlserver
+ mssql-jdbc
+
+
+
diff --git a/test-framework/db-mssql/src/main/java/org/keycloak/test/framework/database/MSSQLServerDatabaseSupplier.java b/test-framework/db-mssql/src/main/java/org/keycloak/test/framework/database/MSSQLServerDatabaseSupplier.java
new file mode 100644
index 0000000000..58d0647582
--- /dev/null
+++ b/test-framework/db-mssql/src/main/java/org/keycloak/test/framework/database/MSSQLServerDatabaseSupplier.java
@@ -0,0 +1,15 @@
+package org.keycloak.test.framework.database;
+
+public class MSSQLServerDatabaseSupplier extends AbstractDatabaseSupplier {
+
+ @Override
+ public String getAlias() {
+ return "mssql";
+ }
+
+ @Override
+ TestDatabase getTestDatabase() {
+ return new MSSQLServerTestDatabase();
+ }
+
+}
diff --git a/test-framework/db-mssql/src/main/java/org/keycloak/test/framework/database/MSSQLServerTestDatabase.java b/test-framework/db-mssql/src/main/java/org/keycloak/test/framework/database/MSSQLServerTestDatabase.java
new file mode 100644
index 0000000000..e5d10456bb
--- /dev/null
+++ b/test-framework/db-mssql/src/main/java/org/keycloak/test/framework/database/MSSQLServerTestDatabase.java
@@ -0,0 +1,19 @@
+package org.keycloak.test.framework.database;
+
+import org.testcontainers.containers.JdbcDatabaseContainer;
+import org.testcontainers.containers.MSSQLServerContainer;
+
+class MSSQLServerTestDatabase extends AbstractContainerTestDatabase {
+
+ private static final String IMAGE_NAME = "mcr.microsoft.com/mssql/server:latest";
+
+ @Override
+ public JdbcDatabaseContainer> createContainer() {
+ return new MSSQLServerContainer<>(IMAGE_NAME);
+ }
+
+ @Override
+ public String getKeycloakDatabaseName() {
+ return "mssql";
+ }
+}
diff --git a/test-framework/db-mssql/src/main/java/org/keycloak/test/framework/database/MSSQLServerTestFrameworkExtension.java b/test-framework/db-mssql/src/main/java/org/keycloak/test/framework/database/MSSQLServerTestFrameworkExtension.java
new file mode 100644
index 0000000000..94995f982d
--- /dev/null
+++ b/test-framework/db-mssql/src/main/java/org/keycloak/test/framework/database/MSSQLServerTestFrameworkExtension.java
@@ -0,0 +1,14 @@
+package org.keycloak.test.framework.database;
+
+import org.keycloak.test.framework.TestFrameworkExtension;
+import org.keycloak.test.framework.injection.Supplier;
+
+import java.util.List;
+
+public class MSSQLServerTestFrameworkExtension implements TestFrameworkExtension {
+
+ @Override
+ public List> suppliers() {
+ return List.of(new MSSQLServerDatabaseSupplier());
+ }
+}
diff --git a/test-framework/db-mssql/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension b/test-framework/db-mssql/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension
new file mode 100644
index 0000000000..43deddaf50
--- /dev/null
+++ b/test-framework/db-mssql/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension
@@ -0,0 +1 @@
+org.keycloak.test.framework.database.MSSQLServerTestFrameworkExtension
\ No newline at end of file
diff --git a/test-framework/db-mysql/pom.xml b/test-framework/db-mysql/pom.xml
new file mode 100755
index 0000000000..2fbc04bce1
--- /dev/null
+++ b/test-framework/db-mysql/pom.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+ keycloak-test-framework-parent
+ org.keycloak.test
+ 999.0.0-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+
+ keycloak-test-framework-db-mysql
+ Keycloak Test Framework - MySQL support
+ jar
+ MySQL support for Keycloak Test Framework
+
+
+
+ org.keycloak.test
+ keycloak-test-framework-core
+ ${project.version}
+
+
+ org.testcontainers
+ mysql
+
+
+
diff --git a/test-framework/db-mysql/src/main/java/org/keycloak/test/framework/database/MySQLDatabaseSupplier.java b/test-framework/db-mysql/src/main/java/org/keycloak/test/framework/database/MySQLDatabaseSupplier.java
new file mode 100644
index 0000000000..35c10465d1
--- /dev/null
+++ b/test-framework/db-mysql/src/main/java/org/keycloak/test/framework/database/MySQLDatabaseSupplier.java
@@ -0,0 +1,15 @@
+package org.keycloak.test.framework.database;
+
+public class MySQLDatabaseSupplier extends AbstractDatabaseSupplier {
+
+ @Override
+ public String getAlias() {
+ return "mysql";
+ }
+
+ @Override
+ TestDatabase getTestDatabase() {
+ return new MySQLTestDatabase();
+ }
+
+}
diff --git a/test-framework/db-mysql/src/main/java/org/keycloak/test/framework/database/MySQLTestDatabase.java b/test-framework/db-mysql/src/main/java/org/keycloak/test/framework/database/MySQLTestDatabase.java
new file mode 100644
index 0000000000..ce064de357
--- /dev/null
+++ b/test-framework/db-mysql/src/main/java/org/keycloak/test/framework/database/MySQLTestDatabase.java
@@ -0,0 +1,19 @@
+package org.keycloak.test.framework.database;
+
+import org.testcontainers.containers.JdbcDatabaseContainer;
+import org.testcontainers.containers.MySQLContainer;
+
+class MySQLTestDatabase extends AbstractContainerTestDatabase {
+
+ private static final String IMAGE_NAME = "mysql:latest";
+
+ @Override
+ public JdbcDatabaseContainer> createContainer() {
+ return new MySQLContainer<>(IMAGE_NAME);
+ }
+
+ @Override
+ public String getKeycloakDatabaseName() {
+ return "mysql";
+ }
+}
diff --git a/test-framework/db-mysql/src/main/java/org/keycloak/test/framework/database/MySQLTestFrameworkExtension.java b/test-framework/db-mysql/src/main/java/org/keycloak/test/framework/database/MySQLTestFrameworkExtension.java
new file mode 100644
index 0000000000..ecea118cf1
--- /dev/null
+++ b/test-framework/db-mysql/src/main/java/org/keycloak/test/framework/database/MySQLTestFrameworkExtension.java
@@ -0,0 +1,14 @@
+package org.keycloak.test.framework.database;
+
+import org.keycloak.test.framework.TestFrameworkExtension;
+import org.keycloak.test.framework.injection.Supplier;
+
+import java.util.List;
+
+public class MySQLTestFrameworkExtension implements TestFrameworkExtension {
+
+ @Override
+ public List> suppliers() {
+ return List.of(new MySQLDatabaseSupplier());
+ }
+}
diff --git a/test-framework/db-mysql/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension b/test-framework/db-mysql/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension
new file mode 100644
index 0000000000..78df05aa37
--- /dev/null
+++ b/test-framework/db-mysql/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension
@@ -0,0 +1 @@
+org.keycloak.test.framework.database.MySQLTestFrameworkExtension
\ No newline at end of file
diff --git a/test-framework/db-oracle/pom.xml b/test-framework/db-oracle/pom.xml
new file mode 100755
index 0000000000..6eb4442f25
--- /dev/null
+++ b/test-framework/db-oracle/pom.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+ keycloak-test-framework-parent
+ org.keycloak.test
+ 999.0.0-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+
+ keycloak-test-framework-db-oracle
+ Keycloak Test Framework - Oracle support
+ jar
+ Oracle support for Keycloak Test Framework
+
+
+
+ org.keycloak.test
+ keycloak-test-framework-core
+ ${project.version}
+
+
+ org.testcontainers
+ oracle-free
+
+
+ com.oracle.database.jdbc
+ ojdbc11
+
+
+
diff --git a/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/Oracle19DatabaseSupplier.java b/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/Oracle19DatabaseSupplier.java
new file mode 100644
index 0000000000..649897893b
--- /dev/null
+++ b/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/Oracle19DatabaseSupplier.java
@@ -0,0 +1,16 @@
+package org.keycloak.test.framework.database;
+
+public class Oracle19DatabaseSupplier extends AbstractDatabaseSupplier {
+
+ @Override
+ public String getAlias() {
+ return "oracle19";
+ }
+
+ @Override
+ TestDatabase getTestDatabase() {
+ return new Oracle19TestDatabase();
+ }
+
+
+}
diff --git a/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/Oracle19TestDatabase.java b/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/Oracle19TestDatabase.java
new file mode 100644
index 0000000000..e5fba062c3
--- /dev/null
+++ b/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/Oracle19TestDatabase.java
@@ -0,0 +1,31 @@
+package org.keycloak.test.framework.database;
+
+import org.testcontainers.containers.JdbcDatabaseContainer;
+import org.testcontainers.oracle.OracleContainer;
+import org.testcontainers.utility.DockerImageName;
+
+import java.util.Map;
+
+class Oracle19TestDatabase extends AbstractContainerTestDatabase {
+
+ private static final DockerImageName IMAGE_NAME = DockerImageName.parse("docker.io/miquelsi/oracle-19c:19.3").asCompatibleSubstituteFor("gvenzl/oracle-free");
+
+ @SuppressWarnings("resource")
+ @Override
+ public JdbcDatabaseContainer> createContainer() {
+ return new OracleContainer(IMAGE_NAME)
+ .withEnv(Map.of("ORACLE_SID", "keycloak", "ORACLE_PWD", "sa"));
+ }
+
+ @Override
+ public String getPostStartCommand() {
+ return "(echo 'alter session set \"_ORACLE_SCRIPT\"=true;' && " +
+ "echo 'GRANT CONNECT,RESOURCE,DBA,GRANT ANY PRIVILEGE,UNLIMITED TABLESPACE TO test;')" +
+ " | sqlplus -L SYS/sa" + "@localhost/keycloak AS SYSDBA";
+ }
+
+ @Override
+ public String getKeycloakDatabaseName() {
+ return "oracle";
+ }
+}
diff --git a/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/OracleDatabaseSupplier.java b/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/OracleDatabaseSupplier.java
new file mode 100644
index 0000000000..226fd013a7
--- /dev/null
+++ b/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/OracleDatabaseSupplier.java
@@ -0,0 +1,15 @@
+package org.keycloak.test.framework.database;
+
+public class OracleDatabaseSupplier extends AbstractDatabaseSupplier {
+
+ @Override
+ public String getAlias() {
+ return "oracle";
+ }
+
+ @Override
+ TestDatabase getTestDatabase() {
+ return new OracleTestDatabase();
+ }
+
+}
diff --git a/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/OracleTestDatabase.java b/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/OracleTestDatabase.java
new file mode 100644
index 0000000000..0c542799cc
--- /dev/null
+++ b/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/OracleTestDatabase.java
@@ -0,0 +1,20 @@
+package org.keycloak.test.framework.database;
+
+import org.testcontainers.containers.JdbcDatabaseContainer;
+import org.testcontainers.oracle.OracleContainer;
+
+class OracleTestDatabase extends AbstractContainerTestDatabase {
+
+ private static final String IMAGE_NAME = "gvenzl/oracle-free:slim-faststart";
+
+ @SuppressWarnings("resource")
+ @Override
+ public JdbcDatabaseContainer> createContainer() {
+ return new OracleContainer(IMAGE_NAME);
+ }
+
+ @Override
+ public String getKeycloakDatabaseName() {
+ return "oracle";
+ }
+}
diff --git a/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/OracleTestFrameworkExtension.java b/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/OracleTestFrameworkExtension.java
new file mode 100644
index 0000000000..249016c7ba
--- /dev/null
+++ b/test-framework/db-oracle/src/main/java/org/keycloak/test/framework/database/OracleTestFrameworkExtension.java
@@ -0,0 +1,14 @@
+package org.keycloak.test.framework.database;
+
+import org.keycloak.test.framework.TestFrameworkExtension;
+import org.keycloak.test.framework.injection.Supplier;
+
+import java.util.List;
+
+public class OracleTestFrameworkExtension implements TestFrameworkExtension {
+
+ @Override
+ public List> suppliers() {
+ return List.of(new OracleDatabaseSupplier(), new Oracle19DatabaseSupplier());
+ }
+}
diff --git a/test-framework/db-oracle/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension b/test-framework/db-oracle/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension
new file mode 100644
index 0000000000..5fdf36fcd0
--- /dev/null
+++ b/test-framework/db-oracle/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension
@@ -0,0 +1 @@
+org.keycloak.test.framework.database.OracleTestFrameworkExtension
\ No newline at end of file
diff --git a/test-framework/db-postgres/pom.xml b/test-framework/db-postgres/pom.xml
new file mode 100755
index 0000000000..78e09439e9
--- /dev/null
+++ b/test-framework/db-postgres/pom.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+ keycloak-test-framework-parent
+ org.keycloak.test
+ 999.0.0-SNAPSHOT
+ ../pom.xml
+
+ 4.0.0
+
+ keycloak-test-framework-db-postgres
+ Keycloak Test Framework - PostgreSQL support
+ jar
+ PostgreSQL support for Keycloak Test Framework
+
+
+
+ org.keycloak.test
+ keycloak-test-framework-core
+ ${project.version}
+
+
+ org.testcontainers
+ postgresql
+
+
+
diff --git a/test-framework/db-postgres/src/main/java/org/keycloak/test/framework/database/PostgresDatabaseSupplier.java b/test-framework/db-postgres/src/main/java/org/keycloak/test/framework/database/PostgresDatabaseSupplier.java
new file mode 100644
index 0000000000..375cebec0b
--- /dev/null
+++ b/test-framework/db-postgres/src/main/java/org/keycloak/test/framework/database/PostgresDatabaseSupplier.java
@@ -0,0 +1,15 @@
+package org.keycloak.test.framework.database;
+
+public class PostgresDatabaseSupplier extends AbstractDatabaseSupplier {
+
+ @Override
+ public String getAlias() {
+ return "postgres";
+ }
+
+ @Override
+ TestDatabase getTestDatabase() {
+ return new PostgresTestDatabase();
+ }
+
+}
diff --git a/test-framework/db-postgres/src/main/java/org/keycloak/test/framework/database/PostgresTestDatabase.java b/test-framework/db-postgres/src/main/java/org/keycloak/test/framework/database/PostgresTestDatabase.java
new file mode 100644
index 0000000000..51ca46bfc0
--- /dev/null
+++ b/test-framework/db-postgres/src/main/java/org/keycloak/test/framework/database/PostgresTestDatabase.java
@@ -0,0 +1,19 @@
+package org.keycloak.test.framework.database;
+
+import org.testcontainers.containers.JdbcDatabaseContainer;
+import org.testcontainers.containers.PostgreSQLContainer;
+
+class PostgresTestDatabase extends AbstractContainerTestDatabase {
+
+ private static final String IMAGE_NAME = "postgres:latest";
+
+ @Override
+ public JdbcDatabaseContainer> createContainer() {
+ return new PostgreSQLContainer<>(IMAGE_NAME);
+ }
+
+ @Override
+ public String getKeycloakDatabaseName() {
+ return "postgres";
+ }
+}
diff --git a/test-framework/db-postgres/src/main/java/org/keycloak/test/framework/database/PostgresTestFrameworkExtension.java b/test-framework/db-postgres/src/main/java/org/keycloak/test/framework/database/PostgresTestFrameworkExtension.java
new file mode 100644
index 0000000000..4a7cbe010b
--- /dev/null
+++ b/test-framework/db-postgres/src/main/java/org/keycloak/test/framework/database/PostgresTestFrameworkExtension.java
@@ -0,0 +1,14 @@
+package org.keycloak.test.framework.database;
+
+import org.keycloak.test.framework.TestFrameworkExtension;
+import org.keycloak.test.framework.injection.Supplier;
+
+import java.util.List;
+
+public class PostgresTestFrameworkExtension implements TestFrameworkExtension {
+
+ @Override
+ public List> suppliers() {
+ return List.of(new PostgresDatabaseSupplier());
+ }
+}
diff --git a/test-framework/db-postgres/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension b/test-framework/db-postgres/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension
new file mode 100644
index 0000000000..72ccf10c8f
--- /dev/null
+++ b/test-framework/db-postgres/src/main/resources/META-INF/services/org.keycloak.test.framework.TestFrameworkExtension
@@ -0,0 +1 @@
+org.keycloak.test.framework.database.PostgresTestFrameworkExtension
\ No newline at end of file
diff --git a/test-framework/examples/pom.xml b/test-framework/examples/pom.xml
index c7d0fb29c1..e5de429d85 100755
--- a/test-framework/examples/pom.xml
+++ b/test-framework/examples/pom.xml
@@ -31,37 +31,51 @@
jar
Example tests to demonstrate the new testing framework
+
+
+
+ org.keycloak.test
+ keycloak-test-framework-bom
+ ${project.version}
+ import
+ pom
+
+
+
+
org.keycloak.test
keycloak-test-framework-core
- ${project.version}
- test
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-mariadb
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-mssql
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-mysql
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-oracle
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-postgres
org.keycloak.test
keycloak-test-framework-ui
- ${project.version}
- test
-
-
- org.junit.platform
- junit-platform-suite
- 1.10.2
- test
org.jboss.logmanager
jboss-logmanager
-
-
-
- com.microsoft.sqlserver
- mssql-jdbc
-
-
- com.oracle.database.jdbc
- ojdbc11
+ test
diff --git a/test-framework/pom.xml b/test-framework/pom.xml
index 8fda850c97..52a50b75d9 100755
--- a/test-framework/pom.xml
+++ b/test-framework/pom.xml
@@ -33,7 +33,13 @@
Keycloak Test Framework Parent
+ bom
core
+ db-mariadb
+ db-mssql
+ db-mysql
+ db-oracle
+ db-postgres
ui
examples
diff --git a/tests/base/pom.xml b/tests/base/pom.xml
index e143c8140f..893737e18c 100755
--- a/tests/base/pom.xml
+++ b/tests/base/pom.xml
@@ -31,33 +31,51 @@
jar
New Keycloak Base Testsuite
+
+
+
+ org.keycloak.test
+ keycloak-test-framework-bom
+ ${project.version}
+ import
+ pom
+
+
+
+
org.keycloak.test
keycloak-test-framework-core
- ${project.version}
- test
org.keycloak.test
keycloak-test-framework-ui
- ${project.version}
- test
- org.junit.platform
- junit-platform-suite
- 1.10.2
- test
+ org.keycloak.test
+ keycloak-test-framework-db-mariadb
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-mssql
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-mysql
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-oracle
+
+
+ org.keycloak.test
+ keycloak-test-framework-db-postgres
org.jboss.logmanager
jboss-logmanager
-
-
-
- com.microsoft.sqlserver
- mssql-jdbc
+ test