Skip to content

Commit

Permalink
KEYCLOAK-15910 Rename "cluster.enabled" to "clustered". Fix test and …
Browse files Browse the repository at this point in the history
…minor cleanup. Adding GH action for quarkus unit test
  • Loading branch information
mposolda authored and pedroigor committed Oct 9, 2020
1 parent ff05072 commit 4fd1950
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
- name: Extract Maven Repo
shell: bash
run: tar -xzvf maven-repo.tgz -C ~
- name: Run Quarkus unit tests
run: mvn clean install -B -Pquarkus -f quarkus/pom.xml
- name: Build testsuite
run: mvn clean install -B -Pquarkus,auth-server-quarkus -DskipTests -f testsuite/pom.xml
- name: Run base tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private static void configureDatabasePropertyMappers() {
}

private static void configureClustering() {
createWithDefault("cluster.enabled", "kc.spi.connections-infinispan.default.clustered", "placeholder", (value, context) -> {
createWithDefault("clustered", "kc.spi.connections-infinispan.default.clustered", "placeholder", (value, context) -> {
if ("true".equals(value) || "false".equals(value)) {
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ConfigValue getValue(ConfigSourceInterceptorContext context, String name)
}

return value.withValue(
StringPropertyReplacer.replaceProperties(PropertyMappers.getValue(context, name).getValue(),
StringPropertyReplacer.replaceProperties(value.getValue(),
property -> {
ConfigValue prop = context.proceed(property);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ public static String getProfile() {
}

public static String getProfileOrDefault(String defaultProfile) {
String profile = System.getProperty("kc.profile");

if (profile == null) {
profile = System.getenv("KC_PROFILE");
}
String profile = getProfile();

if (profile == null) {
profile = defaultProfile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ public void testEnvVarPriorityOverPropertiesFile() {

@Test
public void testSysPropPriorityOverEnvVar() {
putEnvVar("KC_HOSTNAME_DEFAULT_FRONTEND_URL", "http://envvar.com");
putEnvVar("KC_SPI_HOSTNAME_DEFAULT_FRONTEND_URL", "http://envvar.com");
System.setProperty("kc.spi.hostname.default.frontend-url", "http://propvar.com");
assertEquals("http://propvar.com", initConfig("hostname", "default").get("frontendUrl"));
}

@Test
public void testCLIPriorityOverSysVar() {
System.setProperty("kc.hostname.frontend-url", "http://propvar.com");
public void testCLIPriorityOverSysProp() {
System.setProperty("kc.spi.hostname.default.frontend-url", "http://propvar.com");
System.setProperty("kc.config.args", "--spi-hostname-default-frontend-url=http://cli.com");
assertEquals("http://cli.com", initConfig("hostname", "default").get("frontendUrl"));
}
Expand Down Expand Up @@ -165,25 +165,19 @@ public void testSpiConfigurationUsingCommandLineArguments() {
System.setProperty("kc.config.args", "--spi-action-token-handler-verify-email-some-property=test");
assertEquals("test", initConfig("action-token-handler", "verify-email").get("some-property"));
System.setProperty("kc.config.args", "--spi-action-token-handler-verify-email-some-property=test");
assertEquals("test", initConfig("action-token-handler", "verify-email").get("some-property"));
assertEquals("test", initConfig("actionTokenHandler", "verifyEmail").get("someProperty"));

// test multi-word SPI names using slashes
System.setProperty("kc.config.args", "--spi-client-registration-openid-connect-static-jwk-url=http://c.jwk.url");
assertEquals("http://c.jwk.url", initConfig("client-registration", "openid-connect").get("static-jwk-url"));
}

@Test
public void testSpiConfigurationUsingProperties() {
System.setProperty("kc.spi.hostname.default.frontend-url", "http://spifull.com");
assertEquals("http://spifull.com", initConfig("hostname", "default").get("frontendUrl"));
}

@Test
public void testPropertyMapping() {
System.setProperty("kc.config.args", "--db=mariadb,--db-url=jdbc:mariadb://localhost/keycloak");
SmallRyeConfig config = createConfig();
assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
assertEquals("jdbc:mariadb://localhost/keycloak", config.getConfigValue("quarkus.datasource.url").getValue());
assertEquals("jdbc:mariadb://localhost/keycloak", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
}

@Test
Expand All @@ -196,7 +190,7 @@ public void testDatabaseDefaults() {
System.setProperty("kc.config.args", "--db=h2-mem");
config = createConfig();
assertEquals(QuarkusH2Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
assertEquals("jdbc:h2:mem:keycloakdb", config.getConfigValue("quarkus.datasource.url").getValue());
assertEquals("jdbc:h2:mem:keycloakdb", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
}

@Test
Expand All @@ -206,12 +200,12 @@ public void testDatabaseProperties() {
System.setProperty("kc.config.args", "--db=h2-file");
SmallRyeConfig config = createConfig();
assertEquals(QuarkusH2Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
assertEquals("jdbc:h2:file:test-dir/data/keycloakdb;;test=test;test1=test1", config.getConfigValue("quarkus.datasource.url").getValue());
assertEquals("jdbc:h2:file:test-dir/data/keycloakdb;;test=test;test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());

System.setProperty("kc.db.url.properties", "?test=test&test1=test1");
System.setProperty("kc.config.args", "--db=mariadb");
config = createConfig();
assertEquals("jdbc:mariadb://localhost/keycloak?test=test&test1=test1", config.getConfigValue("quarkus.datasource.url").getValue());
assertEquals("jdbc:mariadb://localhost/keycloak?test=test&test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
}

// KEYCLOAK-15632
Expand Down Expand Up @@ -245,7 +239,7 @@ public void testClusterConfig() {

// If explicitly set, then it is always used regardless of the profile
System.clearProperty("kc.profile");
System.setProperty("kc.config.args", "--cluster-enabled=true");
System.setProperty("kc.config.args", "--clustered=true");

Assert.assertTrue(initConfig("connectionsInfinispan", "default").getBoolean("clustered"));
System.setProperty("kc.profile", "dev");
Expand Down

0 comments on commit 4fd1950

Please sign in to comment.