Make sure configuration is loaded with mapped/transformed properties at first (#30101)

* edited Picocli and added a corresponding test for Windows

Closes: #29329

Signed-off-by: Peter Zaoral <pzaoral@redhat.com>
Co-authored-by: Vaclav Muzikar <vmuzikar@redhat.com>
This commit is contained in:
Peter Zaoral 2024-06-06 17:47:28 +02:00 committed by GitHub
parent 859a926597
commit cab3e51c96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -280,6 +280,7 @@ public final class Picocli {
}
try {
getConfig(); // ensure the config is initialized before the interceptor is disabled
PropertyMappingInterceptor.disable(); // we don't want the mapped / transformed properties, we want what the user effectively supplied
List<String> ignoredBuildTime = new ArrayList<>();
List<String> ignoredRunTime = new ArrayList<>();

View File

@ -22,9 +22,16 @@ import io.quarkus.test.junit.main.LaunchResult;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.keycloak.it.junit5.extension.CLIResult;
import org.keycloak.it.junit5.extension.DistributionTest;
import org.keycloak.it.junit5.extension.RawDistOnly;
import org.keycloak.it.utils.KeycloakDistribution;
import java.nio.file.Paths;
import static org.junit.jupiter.api.Assertions.assertTrue;
@DistributionTest
@RawDistOnly(reason = "Containers are immutable")
@ -68,4 +75,15 @@ public class StartDevCommandDistTest {
cliResult.assertStartedDevMode();
}
@Test
@DisabledOnOs(value = { OS.LINUX, OS.MAC }, disabledReason = "A drive letter in URI can cause a problem.")
void testConfigKeystoreAbsolutePath(KeycloakDistribution dist) {
CLIResult cliResult = dist.run("start-dev", "--config-keystore=" + Paths.get("src/test/resources/keystore").toAbsolutePath().normalize(),
"--config-keystore-password=secret");
assertTrue(cliResult.getOutput().contains("DEBUG [org.hibernate"));
assertTrue(cliResult.getOutput().contains("DEBUG [org.keycloak"));
assertTrue(cliResult.getOutput().contains("Listening on:"));
cliResult.assertStartedDevMode();
}
}