task: upgrading to quarkus 3.7.0.CR1 (#26203)
there are several downgrades from the quarkus versions, and some additional logic needed to handle changes with re-creating the configuration Signed-off-by: Steve Hawkins <shawkins@redhat.com>
This commit is contained in:
parent
a43ba73b93
commit
37acb2fd09
16 changed files with 182 additions and 122 deletions
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package org.keycloak.crypto.def;
|
package org.keycloak.crypto.def;
|
||||||
|
|
||||||
|
import org.bouncycastle.asn1.ASN1IA5String;
|
||||||
import org.bouncycastle.asn1.ASN1InputStream;
|
import org.bouncycastle.asn1.ASN1InputStream;
|
||||||
import org.bouncycastle.asn1.ASN1Sequence;
|
import org.bouncycastle.asn1.ASN1Sequence;
|
||||||
import org.bouncycastle.asn1.DERIA5String;
|
import org.bouncycastle.asn1.DERIA5String;
|
||||||
|
@ -338,8 +339,8 @@ public class BCOCSPProvider extends OCSPProvider {
|
||||||
// https://www.ietf.org/rfc/rfc2560.txt, if nextUpdate is not set,
|
// https://www.ietf.org/rfc/rfc2560.txt, if nextUpdate is not set,
|
||||||
// the responder is indicating that newer update is avilable all the time
|
// the responder is indicating that newer update is avilable all the time
|
||||||
long current = date == null ? System.currentTimeMillis() : date.getTime();
|
long current = date == null ? System.currentTimeMillis() : date.getTime();
|
||||||
Date stop = new Date(current + (long) TIME_SKEW);
|
Date stop = new Date(current + TIME_SKEW);
|
||||||
Date start = new Date(current - (long) TIME_SKEW);
|
Date start = new Date(current - TIME_SKEW);
|
||||||
|
|
||||||
Iterator<SingleResp> iter = Arrays.asList(basicOcspResponse.getResponses()).iterator();
|
Iterator<SingleResp> iter = Arrays.asList(basicOcspResponse.getResponses()).iterator();
|
||||||
SingleResp singleRes = null;
|
SingleResp singleRes = null;
|
||||||
|
@ -436,7 +437,7 @@ public class BCOCSPProvider extends OCSPProvider {
|
||||||
if (ad.getAccessMethod().equals(AccessDescription.id_ad_ocsp)) {
|
if (ad.getAccessMethod().equals(AccessDescription.id_ad_ocsp)) {
|
||||||
// See https://www.ietf.org/rfc/rfc2560.txt, 3.1 Certificate Content
|
// See https://www.ietf.org/rfc/rfc2560.txt, 3.1 Certificate Content
|
||||||
if (ad.getAccessLocation().getTagNo() == GeneralName.uniformResourceIdentifier) {
|
if (ad.getAccessLocation().getTagNo() == GeneralName.uniformResourceIdentifier) {
|
||||||
DERIA5String value = DERIA5String.getInstance(ad.getAccessLocation().getName());
|
ASN1IA5String value = DERIA5String.getInstance(ad.getAccessLocation().getName());
|
||||||
responderURIs.add(value.getString());
|
responderURIs.add(value.getString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.bouncycastle.asn1.ASN1InputStream;
|
||||||
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
||||||
import org.bouncycastle.asn1.ASN1Sequence;
|
import org.bouncycastle.asn1.ASN1Sequence;
|
||||||
import org.bouncycastle.asn1.ASN1TaggedObject;
|
import org.bouncycastle.asn1.ASN1TaggedObject;
|
||||||
|
import org.bouncycastle.asn1.ASN1UTF8String;
|
||||||
|
import org.bouncycastle.asn1.BERTags;
|
||||||
import org.bouncycastle.asn1.DERUTF8String;
|
import org.bouncycastle.asn1.DERUTF8String;
|
||||||
import org.bouncycastle.asn1.x500.AttributeTypeAndValue;
|
import org.bouncycastle.asn1.x500.AttributeTypeAndValue;
|
||||||
import org.bouncycastle.asn1.x500.RDN;
|
import org.bouncycastle.asn1.x500.RDN;
|
||||||
|
@ -162,7 +164,7 @@ public class BCUserIdentityExtractorProvider extends UserIdentityExtractorProvi
|
||||||
tempOid = oid.getId();
|
tempOid = oid.getId();
|
||||||
|
|
||||||
ASN1Encodable principalNameEncoded = asn1Sequence.getObjectAt(1);
|
ASN1Encodable principalNameEncoded = asn1Sequence.getObjectAt(1);
|
||||||
DERUTF8String principalName = DERUTF8String.getInstance(unwrap(principalNameEncoded));
|
ASN1UTF8String principalName = DERUTF8String.getInstance(unwrap(principalNameEncoded));
|
||||||
|
|
||||||
tempOtherName = principalName.getString();
|
tempOtherName = principalName.getString();
|
||||||
|
|
||||||
|
@ -195,8 +197,8 @@ public class BCUserIdentityExtractorProvider extends UserIdentityExtractorProvi
|
||||||
|
|
||||||
private ASN1Encodable unwrap(ASN1Encodable encodable) {
|
private ASN1Encodable unwrap(ASN1Encodable encodable) {
|
||||||
while (encodable instanceof ASN1TaggedObject) {
|
while (encodable instanceof ASN1TaggedObject) {
|
||||||
ASN1TaggedObject taggedObj = (ASN1TaggedObject) encodable;
|
ASN1TaggedObject taggedObj = ASN1TaggedObject.getInstance(encodable, BERTags.CONTEXT_SPECIFIC);
|
||||||
encodable = taggedObj.getObject();
|
encodable = taggedObj.getBaseObject().toASN1Primitive();
|
||||||
}
|
}
|
||||||
|
|
||||||
return encodable;
|
return encodable;
|
||||||
|
|
|
@ -67,18 +67,6 @@
|
||||||
<artifactId>quarkus-operator-sdk-bundle-generator</artifactId>
|
<artifactId>quarkus-operator-sdk-bundle-generator</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-resteasy-jackson</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-rest-client</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.quarkus</groupId>
|
|
||||||
<artifactId>quarkus-rest-client-jackson</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-kubernetes-client</artifactId>
|
<artifactId>quarkus-kubernetes-client</artifactId>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.keycloak.operator;
|
package org.keycloak.operator;
|
||||||
|
|
||||||
import io.smallrye.config.ConfigMapping;
|
import io.smallrye.config.ConfigMapping;
|
||||||
|
import io.smallrye.config.WithDefault;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -36,4 +37,17 @@ public interface Config {
|
||||||
|
|
||||||
Map<String, String> podLabels();
|
Map<String, String> podLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// workarounds for OLM env values
|
||||||
|
// to be removed after https://github.com/keycloak/keycloak/issues/12352
|
||||||
|
|
||||||
|
@WithDefault("keycloak-operator")
|
||||||
|
String name();
|
||||||
|
|
||||||
|
interface Condition {
|
||||||
|
@WithDefault("keycloak-operator.v999-SNAPSHOT")
|
||||||
|
String name();
|
||||||
|
}
|
||||||
|
|
||||||
|
Condition condition();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,7 @@ import io.fabric8.kubernetes.api.model.EnvVarBuilder;
|
||||||
import io.fabric8.kubernetes.api.model.EnvVarSource;
|
import io.fabric8.kubernetes.api.model.EnvVarSource;
|
||||||
import io.fabric8.kubernetes.api.model.EnvVarSourceBuilder;
|
import io.fabric8.kubernetes.api.model.EnvVarSourceBuilder;
|
||||||
import io.fabric8.kubernetes.api.model.PodSpec;
|
import io.fabric8.kubernetes.api.model.PodSpec;
|
||||||
import io.fabric8.kubernetes.api.model.PodSpecFluent.ContainersNested;
|
|
||||||
import io.fabric8.kubernetes.api.model.PodTemplateSpec;
|
import io.fabric8.kubernetes.api.model.PodTemplateSpec;
|
||||||
import io.fabric8.kubernetes.api.model.PodTemplateSpecFluent.SpecNested;
|
|
||||||
import io.fabric8.kubernetes.api.model.Secret;
|
import io.fabric8.kubernetes.api.model.Secret;
|
||||||
import io.fabric8.kubernetes.api.model.SecretKeySelector;
|
import io.fabric8.kubernetes.api.model.SecretKeySelector;
|
||||||
import io.fabric8.kubernetes.api.model.VolumeBuilder;
|
import io.fabric8.kubernetes.api.model.VolumeBuilder;
|
||||||
|
@ -33,7 +31,7 @@ import io.fabric8.kubernetes.api.model.VolumeMountBuilder;
|
||||||
import io.fabric8.kubernetes.api.model.apps.StatefulSet;
|
import io.fabric8.kubernetes.api.model.apps.StatefulSet;
|
||||||
import io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder;
|
import io.fabric8.kubernetes.api.model.apps.StatefulSetBuilder;
|
||||||
import io.fabric8.kubernetes.api.model.apps.StatefulSetSpec;
|
import io.fabric8.kubernetes.api.model.apps.StatefulSetSpec;
|
||||||
import io.fabric8.kubernetes.api.model.apps.StatefulSetSpecFluent.TemplateNested;
|
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||||
import io.javaoperatorsdk.operator.api.reconciler.Context;
|
import io.javaoperatorsdk.operator.api.reconciler.Context;
|
||||||
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource;
|
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource;
|
||||||
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent;
|
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent;
|
||||||
|
@ -103,10 +101,10 @@ public class KeycloakDeploymentDependentResource extends CRUDKubernetesDependent
|
||||||
addTruststores(primary, baseDeployment, kcContainer, allSecrets);
|
addTruststores(primary, baseDeployment, kcContainer, allSecrets);
|
||||||
addEnvVars(baseDeployment, primary, allSecrets);
|
addEnvVars(baseDeployment, primary, allSecrets);
|
||||||
Optional.ofNullable(primary.getSpec().getCacheSpec())
|
Optional.ofNullable(primary.getSpec().getCacheSpec())
|
||||||
.ifPresent(c -> configureCache(primary, baseDeployment, kcContainer, c));
|
.ifPresent(c -> configureCache(primary, baseDeployment, kcContainer, c, context.getClient()));
|
||||||
|
|
||||||
if (!allSecrets.isEmpty()) {
|
if (!allSecrets.isEmpty()) {
|
||||||
watchedResources.annotateDeployment(new ArrayList<>(allSecrets), Secret.class, baseDeployment, this.client);
|
watchedResources.annotateDeployment(new ArrayList<>(allSecrets), Secret.class, baseDeployment, context.getClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
StatefulSet existingDeployment = context.getSecondaryResource(StatefulSet.class).orElse(null);
|
StatefulSet existingDeployment = context.getSecondaryResource(StatefulSet.class).orElse(null);
|
||||||
|
@ -128,7 +126,7 @@ public class KeycloakDeploymentDependentResource extends CRUDKubernetesDependent
|
||||||
return baseDeployment;
|
return baseDeployment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureCache(Keycloak keycloakCR, StatefulSet deployment, Container kcContainer, CacheSpec spec) {
|
private void configureCache(Keycloak keycloakCR, StatefulSet deployment, Container kcContainer, CacheSpec spec, KubernetesClient client) {
|
||||||
Optional.ofNullable(spec.getConfigMapFile()).ifPresent(configFile -> {
|
Optional.ofNullable(spec.getConfigMapFile()).ifPresent(configFile -> {
|
||||||
if (configFile.getName() == null || configFile.getKey() == null) {
|
if (configFile.getName() == null || configFile.getKey() == null) {
|
||||||
throw new IllegalStateException("Cache file ConfigMap requires both a name and a key");
|
throw new IllegalStateException("Cache file ConfigMap requires both a name and a key");
|
||||||
|
@ -151,7 +149,7 @@ public class KeycloakDeploymentDependentResource extends CRUDKubernetesDependent
|
||||||
kcContainer.getVolumeMounts().add(0, volumeMount);
|
kcContainer.getVolumeMounts().add(0, volumeMount);
|
||||||
|
|
||||||
// currently the only configmap we're watching
|
// currently the only configmap we're watching
|
||||||
watchedResources.annotateDeployment(List.of(configFile.getName()), ConfigMap.class, deployment, this.client);
|
watchedResources.annotateDeployment(List.of(configFile.getName()), ConfigMap.class, deployment, client);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,12 +247,7 @@ public class KeycloakDeploymentDependentResource extends CRUDKubernetesDependent
|
||||||
}
|
}
|
||||||
|
|
||||||
// there isn't currently an editOrNewFirstContainer, so we need to do this manually
|
// there isn't currently an editOrNewFirstContainer, so we need to do this manually
|
||||||
ContainersNested<SpecNested<TemplateNested<io.fabric8.kubernetes.api.model.apps.StatefulSetFluent.SpecNested<StatefulSetBuilder>>>> containerBuilder = null;
|
var containerBuilder = specBuilder.buildContainers().isEmpty() ? specBuilder.addNewContainer() : specBuilder.editFirstContainer();
|
||||||
if (specBuilder.buildContainers().isEmpty()) {
|
|
||||||
containerBuilder = specBuilder.addNewContainer();
|
|
||||||
} else {
|
|
||||||
containerBuilder = specBuilder.editFirstContainer();
|
|
||||||
}
|
|
||||||
|
|
||||||
containerBuilder.withName("keycloak");
|
containerBuilder.withName("keycloak");
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ public class KeycloakRealmImportController implements Reconciler<KeycloakRealmIm
|
||||||
@Override
|
@Override
|
||||||
public Map<String, EventSource> prepareEventSources(EventSourceContext<KeycloakRealmImport> context) {
|
public Map<String, EventSource> prepareEventSources(EventSourceContext<KeycloakRealmImport> context) {
|
||||||
this.jobDependentResource = new KeycloakRealmImportJobDependentResource();
|
this.jobDependentResource = new KeycloakRealmImportJobDependentResource();
|
||||||
this.jobDependentResource.setKubernetesClient(context.getClient());
|
|
||||||
return EventSourceInitializer.nameEventSourcesFromDependentResource(context, jobDependentResource);
|
return EventSourceInitializer.nameEventSourcesFromDependentResource(context, jobDependentResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@ package org.keycloak.operator.testsuite.integration;
|
||||||
import io.fabric8.kubernetes.api.model.HasMetadata;
|
import io.fabric8.kubernetes.api.model.HasMetadata;
|
||||||
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
|
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
|
||||||
import io.fabric8.kubernetes.api.model.Pod;
|
import io.fabric8.kubernetes.api.model.Pod;
|
||||||
import io.fabric8.kubernetes.api.model.PodSpecFluent.ContainersNested;
|
|
||||||
import io.fabric8.kubernetes.api.model.PodTemplateSpecFluent.SpecNested;
|
|
||||||
import io.fabric8.kubernetes.api.model.Secret;
|
import io.fabric8.kubernetes.api.model.Secret;
|
||||||
import io.fabric8.kubernetes.api.model.apps.Deployment;
|
import io.fabric8.kubernetes.api.model.apps.Deployment;
|
||||||
import io.fabric8.kubernetes.api.model.apps.StatefulSet;
|
import io.fabric8.kubernetes.api.model.apps.StatefulSet;
|
||||||
|
@ -59,9 +57,7 @@ import org.keycloak.operator.Constants;
|
||||||
import org.keycloak.operator.controllers.KeycloakDeploymentDependentResource;
|
import org.keycloak.operator.controllers.KeycloakDeploymentDependentResource;
|
||||||
import org.keycloak.operator.crds.v2alpha1.deployment.Keycloak;
|
import org.keycloak.operator.crds.v2alpha1.deployment.Keycloak;
|
||||||
import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakSpecBuilder;
|
import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakSpecBuilder;
|
||||||
import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakSpecFluent.UnsupportedNested;
|
|
||||||
import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakStatus;
|
import org.keycloak.operator.crds.v2alpha1.deployment.KeycloakStatus;
|
||||||
import org.keycloak.operator.crds.v2alpha1.deployment.spec.UnsupportedSpecFluent.PodTemplateNested;
|
|
||||||
import org.keycloak.operator.crds.v2alpha1.realmimport.KeycloakRealmImport;
|
import org.keycloak.operator.crds.v2alpha1.realmimport.KeycloakRealmImport;
|
||||||
import org.keycloak.operator.testsuite.utils.K8sUtils;
|
import org.keycloak.operator.testsuite.utils.K8sUtils;
|
||||||
import org.opentest4j.TestAbortedException;
|
import org.opentest4j.TestAbortedException;
|
||||||
|
@ -405,12 +401,8 @@ public class BaseOperatorTest implements QuarkusTestAfterEachCallback {
|
||||||
public static Keycloak disableProbes(Keycloak keycloak) {
|
public static Keycloak disableProbes(Keycloak keycloak) {
|
||||||
KeycloakSpecBuilder specBuilder = new KeycloakSpecBuilder(keycloak.getSpec());
|
KeycloakSpecBuilder specBuilder = new KeycloakSpecBuilder(keycloak.getSpec());
|
||||||
var podTemplateSpecBuilder = specBuilder.editOrNewUnsupported().editOrNewPodTemplate().editOrNewSpec();
|
var podTemplateSpecBuilder = specBuilder.editOrNewUnsupported().editOrNewPodTemplate().editOrNewSpec();
|
||||||
ContainersNested<SpecNested<PodTemplateNested<UnsupportedNested<KeycloakSpecBuilder>>>> containerBuilder = null;
|
var containerBuilder = podTemplateSpecBuilder.hasContainers() ? podTemplateSpecBuilder.editContainer(0)
|
||||||
if (podTemplateSpecBuilder.hasContainers()) {
|
: podTemplateSpecBuilder.addNewContainer();
|
||||||
containerBuilder = podTemplateSpecBuilder.editContainer(0);
|
|
||||||
} else {
|
|
||||||
containerBuilder = podTemplateSpecBuilder.addNewContainer();
|
|
||||||
}
|
|
||||||
keycloak.setSpec(containerBuilder.withNewLivenessProbe().withNewExec().addToCommand("true").endExec()
|
keycloak.setSpec(containerBuilder.withNewLivenessProbe().withNewExec().addToCommand("true").endExec()
|
||||||
.endLivenessProbe().withNewReadinessProbe().withNewExec().addToCommand("true").endExec()
|
.endLivenessProbe().withNewReadinessProbe().withNewExec().addToCommand("true").endExec()
|
||||||
.endReadinessProbe().withNewStartupProbe().withNewExec().addToCommand("true").endExec()
|
.endReadinessProbe().withNewStartupProbe().withNewExec().addToCommand("true").endExec()
|
||||||
|
|
30
pom.xml
30
pom.xml
|
@ -45,8 +45,8 @@
|
||||||
<jboss.snapshots.repo.id>jboss-snapshots-repository</jboss.snapshots.repo.id>
|
<jboss.snapshots.repo.id>jboss-snapshots-repository</jboss.snapshots.repo.id>
|
||||||
<jboss.snapshots.repo.url>https://s01.oss.sonatype.org/content/repositories/snapshots/</jboss.snapshots.repo.url>
|
<jboss.snapshots.repo.url>https://s01.oss.sonatype.org/content/repositories/snapshots/</jboss.snapshots.repo.url>
|
||||||
|
|
||||||
<quarkus.version>3.2.9.Final</quarkus.version>
|
<quarkus.version>3.7.0.CR1</quarkus.version>
|
||||||
<quarkus.build.version>3.2.9.Final</quarkus.build.version>
|
<quarkus.build.version>3.7.0.CR1</quarkus.build.version>
|
||||||
|
|
||||||
<project.build-time>${timestamp}</project.build-time>
|
<project.build-time>${timestamp}</project.build-time>
|
||||||
|
|
||||||
|
@ -86,6 +86,8 @@
|
||||||
|
|
||||||
<!-- TODO Are these correct versions? -->
|
<!-- TODO Are these correct versions? -->
|
||||||
<bouncycastle.pkixfips.version>1.0.7</bouncycastle.pkixfips.version>
|
<bouncycastle.pkixfips.version>1.0.7</bouncycastle.pkixfips.version>
|
||||||
|
<!-- 1.0.2.4 exhibits class loading issues -->
|
||||||
|
<bouncycastle.bcfips.version>1.0.2.3</bouncycastle.bcfips.version>
|
||||||
|
|
||||||
<cxf.version>3.3.10</cxf.version>
|
<cxf.version>3.3.10</cxf.version>
|
||||||
<cxf.jetty.version>3.3.10</cxf.jetty.version>
|
<cxf.jetty.version>3.3.10</cxf.jetty.version>
|
||||||
|
@ -106,8 +108,6 @@
|
||||||
<servlet.api.30.version>1.0.2.Final</servlet.api.30.version>
|
<servlet.api.30.version>1.0.2.Final</servlet.api.30.version>
|
||||||
<jboss-jaxrs-api_2.1_spec>2.0.2.Final</jboss-jaxrs-api_2.1_spec>
|
<jboss-jaxrs-api_2.1_spec>2.0.2.Final</jboss-jaxrs-api_2.1_spec>
|
||||||
<jboss-servlet-api_4.0_spec>2.0.0.Final</jboss-servlet-api_4.0_spec>
|
<jboss-servlet-api_4.0_spec>2.0.0.Final</jboss-servlet-api_4.0_spec>
|
||||||
<jboss.logmanager>2.1.19.Final</jboss.logmanager>
|
|
||||||
<jboss.marshalling.version>2.0.11.Final</jboss.marshalling.version>
|
|
||||||
<jboss.spec.javax.xml.bind.jboss-jaxb-api_2.3_spec.version>2.0.1.Final</jboss.spec.javax.xml.bind.jboss-jaxb-api_2.3_spec.version>
|
<jboss.spec.javax.xml.bind.jboss-jaxb-api_2.3_spec.version>2.0.1.Final</jboss.spec.javax.xml.bind.jboss-jaxb-api_2.3_spec.version>
|
||||||
<jboss.spec.javax.servlet.jsp.jboss-jsp-api_2.3_spec.version>2.0.0.Final</jboss.spec.javax.servlet.jsp.jboss-jsp-api_2.3_spec.version>
|
<jboss.spec.javax.servlet.jsp.jboss-jsp-api_2.3_spec.version>2.0.0.Final</jboss.spec.javax.servlet.jsp.jboss-jsp-api_2.3_spec.version>
|
||||||
<log4j.version>1.2.17</log4j.version>
|
<log4j.version>1.2.17</log4j.version>
|
||||||
|
@ -427,6 +427,13 @@
|
||||||
<artifactId>bcpkix-fips</artifactId>
|
<artifactId>bcpkix-fips</artifactId>
|
||||||
<version>${bouncycastle.pkixfips.version}</version>
|
<version>${bouncycastle.pkixfips.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bc-fips</artifactId>
|
||||||
|
<version>${bouncycastle.bcfips.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.ua-parser</groupId>
|
<groupId>com.github.ua-parser</groupId>
|
||||||
<artifactId>uap-java</artifactId>
|
<artifactId>uap-java</artifactId>
|
||||||
|
@ -557,11 +564,6 @@
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>${log4j.version}</version>
|
<version>${log4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jboss.logmanager</groupId>
|
|
||||||
<artifactId>jboss-logmanager</artifactId>
|
|
||||||
<version>${jboss.logmanager}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
|
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
|
||||||
<artifactId>owasp-java-html-sanitizer</artifactId>
|
<artifactId>owasp-java-html-sanitizer</artifactId>
|
||||||
|
@ -894,16 +896,6 @@
|
||||||
<artifactId>undertow-server</artifactId>
|
<artifactId>undertow-server</artifactId>
|
||||||
<version>${elytron.undertow-server.version}</version>
|
<version>${elytron.undertow-server.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.jboss.marshalling</groupId>
|
|
||||||
<artifactId>jboss-marshalling</artifactId>
|
|
||||||
<version>${jboss.marshalling.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jboss.marshalling</groupId>
|
|
||||||
<artifactId>jboss-marshalling-river</artifactId>
|
|
||||||
<version>${jboss.marshalling.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.liquibase</groupId>
|
<groupId>org.liquibase</groupId>
|
||||||
<artifactId>liquibase-core</artifactId>
|
<artifactId>liquibase-core</artifactId>
|
||||||
|
|
|
@ -29,7 +29,6 @@ import io.quarkus.deployment.annotations.Consume;
|
||||||
import io.quarkus.deployment.annotations.ExecutionTime;
|
import io.quarkus.deployment.annotations.ExecutionTime;
|
||||||
import io.quarkus.deployment.annotations.Produce;
|
import io.quarkus.deployment.annotations.Produce;
|
||||||
import io.quarkus.deployment.annotations.Record;
|
import io.quarkus.deployment.annotations.Record;
|
||||||
import io.quarkus.deployment.builditem.BootstrapConfigSetupCompleteBuildItem;
|
|
||||||
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
|
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
|
||||||
import io.quarkus.deployment.builditem.FeatureBuildItem;
|
import io.quarkus.deployment.builditem.FeatureBuildItem;
|
||||||
import io.quarkus.deployment.builditem.GeneratedResourceBuildItem;
|
import io.quarkus.deployment.builditem.GeneratedResourceBuildItem;
|
||||||
|
@ -44,6 +43,7 @@ import io.quarkus.resteasy.reactive.server.spi.MethodScannerBuildItem;
|
||||||
import io.quarkus.runtime.configuration.ConfigurationException;
|
import io.quarkus.runtime.configuration.ConfigurationException;
|
||||||
import io.quarkus.runtime.configuration.ProfileManager;
|
import io.quarkus.runtime.configuration.ProfileManager;
|
||||||
import io.quarkus.vertx.http.deployment.RouteBuildItem;
|
import io.quarkus.vertx.http.deployment.RouteBuildItem;
|
||||||
|
import io.quarkus.resteasy.reactive.spi.IgnoreStackMixingBuildItem;
|
||||||
import io.smallrye.config.ConfigValue;
|
import io.smallrye.config.ConfigValue;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
|
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
|
||||||
|
@ -207,6 +207,11 @@ class KeycloakProcessor {
|
||||||
return new DeployedScriptSAMLProtocolMapper(metadata);
|
return new DeployedScriptSAMLProtocolMapper(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BuildStep
|
||||||
|
IgnoreStackMixingBuildItem getIgnoreStackMixing() {
|
||||||
|
return new IgnoreStackMixingBuildItem();
|
||||||
|
}
|
||||||
|
|
||||||
@BuildStep
|
@BuildStep
|
||||||
FeatureBuildItem getFeature() {
|
FeatureBuildItem getFeature() {
|
||||||
return new FeatureBuildItem("keycloak");
|
return new FeatureBuildItem("keycloak");
|
||||||
|
@ -662,7 +667,6 @@ class KeycloakProcessor {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Consume(BootstrapConfigSetupCompleteBuildItem.class)
|
|
||||||
@Consume(ProfileBuildItem.class)
|
@Consume(ProfileBuildItem.class)
|
||||||
@Produce(CryptoProviderInitBuildItem.class)
|
@Produce(CryptoProviderInitBuildItem.class)
|
||||||
@BuildStep
|
@BuildStep
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class ConfigArgsConfigSource extends PropertiesConfigSource {
|
||||||
super(parseArguments(), NAME, 600);
|
super(parseArguments(), NAME, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCliArgs(String[] args) {
|
public static void setCliArgs(String... args) {
|
||||||
System.setProperty(CLI_ARGS, String.join(ARG_SEPARATOR, args));
|
System.setProperty(CLI_ARGS, String.join(ARG_SEPARATOR, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.Config;
|
import org.keycloak.Config;
|
||||||
|
import org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource;
|
||||||
import org.keycloak.quarkus.runtime.configuration.KeycloakConfigSourceProvider;
|
import org.keycloak.quarkus.runtime.configuration.KeycloakConfigSourceProvider;
|
||||||
import org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider;
|
import org.keycloak.quarkus.runtime.configuration.MicroProfileConfigProvider;
|
||||||
|
|
||||||
|
@ -57,7 +58,6 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
private static final Properties SYSTEM_PROPERTIES = (Properties) System.getProperties().clone();
|
private static final Properties SYSTEM_PROPERTIES = (Properties) System.getProperties().clone();
|
||||||
private static final Map<String, String> ENVIRONMENT_VARIABLES = new HashMap<>(System.getenv());
|
private static final Map<String, String> ENVIRONMENT_VARIABLES = new HashMap<>(System.getenv());
|
||||||
private static final String ARG_SEPARATOR = ";;";
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void putEnvVar(String name, String value) {
|
public static void putEnvVar(String name, String value) {
|
||||||
|
@ -158,7 +158,7 @@ public class ConfigurationTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCLIPriorityOverSysProp() {
|
public void testCLIPriorityOverSysProp() {
|
||||||
System.setProperty("kc.spi.hostname.default.frontend-url", "http://propvar.unittest");
|
System.setProperty("kc.spi.hostname.default.frontend-url", "http://propvar.unittest");
|
||||||
System.setProperty(CLI_ARGS, "--spi-hostname-default-frontend-url=http://cli.unittest");
|
ConfigArgsConfigSource.setCliArgs("--spi-hostname-default-frontend-url=http://cli.unittest");
|
||||||
assertEquals("http://cli.unittest", initConfig("hostname", "default").get("frontendUrl"));
|
assertEquals("http://cli.unittest", initConfig("hostname", "default").get("frontendUrl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,53 +187,53 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommandLineArguments() {
|
public void testCommandLineArguments() {
|
||||||
System.setProperty(CLI_ARGS, "--spi-hostname-default-frontend-url=http://fromargs.unittest" + ARG_SEPARATOR + "--no-ssl");
|
ConfigArgsConfigSource.setCliArgs("--spi-hostname-default-frontend-url=http://fromargs.unittest", "--no-ssl");
|
||||||
assertEquals("http://fromargs.unittest", initConfig("hostname", "default").get("frontendUrl"));
|
assertEquals("http://fromargs.unittest", initConfig("hostname", "default").get("frontendUrl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSpiConfigurationUsingCommandLineArguments() {
|
public void testSpiConfigurationUsingCommandLineArguments() {
|
||||||
System.setProperty(CLI_ARGS, "--spi-hostname-default-frontend-url=http://spifull.unittest");
|
ConfigArgsConfigSource.setCliArgs("--spi-hostname-default-frontend-url=http://spifull.unittest");
|
||||||
assertEquals("http://spifull.unittest", initConfig("hostname", "default").get("frontendUrl"));
|
assertEquals("http://spifull.unittest", initConfig("hostname", "default").get("frontendUrl"));
|
||||||
|
|
||||||
// test multi-word SPI names using camel cases
|
// test multi-word SPI names using camel cases
|
||||||
System.setProperty(CLI_ARGS, "--spi-action-token-handler-verify-email-some-property=test");
|
ConfigArgsConfigSource.setCliArgs("--spi-action-token-handler-verify-email-some-property=test");
|
||||||
assertEquals("test", initConfig("action-token-handler", "verify-email").get("some-property"));
|
assertEquals("test", initConfig("action-token-handler", "verify-email").get("some-property"));
|
||||||
System.setProperty(CLI_ARGS, "--spi-action-token-handler-verify-email-some-property=test");
|
ConfigArgsConfigSource.setCliArgs("--spi-action-token-handler-verify-email-some-property=test");
|
||||||
assertEquals("test", initConfig("actionTokenHandler", "verifyEmail").get("someProperty"));
|
assertEquals("test", initConfig("actionTokenHandler", "verifyEmail").get("someProperty"));
|
||||||
|
|
||||||
// test multi-word SPI names using slashes
|
// test multi-word SPI names using slashes
|
||||||
System.setProperty(CLI_ARGS, "--spi-client-registration-openid-connect-static-jwk-url=http://c.jwk.url");
|
ConfigArgsConfigSource.setCliArgs("--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"));
|
assertEquals("http://c.jwk.url", initConfig("client-registration", "openid-connect").get("static-jwk-url"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResolveTransformedValue() {
|
public void testResolveTransformedValue() {
|
||||||
System.setProperty(CLI_ARGS, "");
|
ConfigArgsConfigSource.setCliArgs("");
|
||||||
assertEquals("none", createConfig().getConfigValue("kc.proxy").getValue());
|
assertEquals("none", createConfig().getConfigValue("kc.proxy").getValue());
|
||||||
System.setProperty(CLI_ARGS, "--proxy=none");
|
ConfigArgsConfigSource.setCliArgs("--proxy=none");
|
||||||
assertEquals("none", createConfig().getConfigValue("kc.proxy").getValue());
|
assertEquals("none", createConfig().getConfigValue("kc.proxy").getValue());
|
||||||
System.setProperty(CLI_ARGS, "");
|
ConfigArgsConfigSource.setCliArgs("");
|
||||||
assertEquals("none", createConfig().getConfigValue("kc.proxy").getValue());
|
assertEquals("none", createConfig().getConfigValue("kc.proxy").getValue());
|
||||||
System.setProperty(CLI_ARGS, "--proxy=none" + ARG_SEPARATOR + "--http-enabled=false");
|
ConfigArgsConfigSource.setCliArgs("--proxy=none", "--http-enabled=false");
|
||||||
assertEquals("false", createConfig().getConfigValue("kc.http-enabled").getValue());
|
assertEquals("false", createConfig().getConfigValue("kc.http-enabled").getValue());
|
||||||
System.setProperty(CLI_ARGS, "--proxy=none" + ARG_SEPARATOR + "--http-enabled=true");
|
ConfigArgsConfigSource.setCliArgs("--proxy=none", "--http-enabled=true");
|
||||||
assertEquals("true", createConfig().getConfigValue("kc.http-enabled").getValue());
|
assertEquals("true", createConfig().getConfigValue("kc.http-enabled").getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyNamesFromConfig() {
|
public void testPropertyNamesFromConfig() {
|
||||||
System.setProperty(CLI_ARGS, "--spi-client-registration-openid-connect-static-jwk-url=http://c.jwk.url");
|
ConfigArgsConfigSource.setCliArgs("--spi-client-registration-openid-connect-static-jwk-url=http://c.jwk.url");
|
||||||
Config.Scope config = initConfig("client-registration", "openid-connect");
|
Config.Scope config = initConfig("client-registration", "openid-connect");
|
||||||
assertEquals(1, config.getPropertyNames().size());
|
assertEquals(1, config.getPropertyNames().size());
|
||||||
assertEquals("http://c.jwk.url", config.get("static-jwk-url"));
|
assertEquals("http://c.jwk.url", config.get("static-jwk-url"));
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--vault-dir=secrets");
|
ConfigArgsConfigSource.setCliArgs("--vault-dir=secrets");
|
||||||
config = initConfig("vault", FilesPlainTextVaultProviderFactory.ID);
|
config = initConfig("vault", FilesPlainTextVaultProviderFactory.ID);
|
||||||
assertEquals(1, config.getPropertyNames().size());
|
assertEquals(1, config.getPropertyNames().size());
|
||||||
assertEquals("secrets", config.get("dir"));
|
assertEquals("secrets", config.get("dir"));
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--vault-type=JKS");
|
ConfigArgsConfigSource.setCliArgs("--vault-type=JKS");
|
||||||
config = initConfig("vault", FilesKeystoreVaultProviderFactory.ID);
|
config = initConfig("vault", FilesKeystoreVaultProviderFactory.ID);
|
||||||
assertEquals(1, config.getPropertyNames().size());
|
assertEquals(1, config.getPropertyNames().size());
|
||||||
assertEquals("JKS", config.get("type"));
|
assertEquals("JKS", config.get("type"));
|
||||||
|
@ -255,7 +255,7 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyMapping() {
|
public void testPropertyMapping() {
|
||||||
System.setProperty(CLI_ARGS, "--db=mariadb" + ARG_SEPARATOR + "--db-url=jdbc:mariadb://localhost/keycloak");
|
ConfigArgsConfigSource.setCliArgs("--db=mariadb", "--db-url=jdbc:mariadb://localhost/keycloak");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
||||||
assertEquals("jdbc:mariadb://localhost/keycloak", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
assertEquals("jdbc:mariadb://localhost/keycloak", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
||||||
|
@ -263,7 +263,7 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDatabaseUrlProperties() {
|
public void testDatabaseUrlProperties() {
|
||||||
System.setProperty(CLI_ARGS, "--db=mariadb" + ARG_SEPARATOR + "--db-url=jdbc:mariadb:aurora://foo/bar?a=1&b=2");
|
ConfigArgsConfigSource.setCliArgs("--db=mariadb", "--db-url=jdbc:mariadb:aurora://foo/bar?a=1&b=2");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
||||||
assertEquals("jdbc:mariadb:aurora://foo/bar?a=1&b=2", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
assertEquals("jdbc:mariadb:aurora://foo/bar?a=1&b=2", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
||||||
|
@ -271,7 +271,7 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDatabaseDefaults() {
|
public void testDatabaseDefaults() {
|
||||||
System.setProperty(CLI_ARGS, "--db=dev-file");
|
ConfigArgsConfigSource.setCliArgs("--db=dev-file");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals(H2Dialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
assertEquals(H2Dialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
||||||
|
|
||||||
|
@ -283,23 +283,23 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
assertEquals("jdbc:h2:file:" + userHomeUri + "data/h2/keycloakdb;;AUTO_SERVER=TRUE;NON_KEYWORDS=VALUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
assertEquals("jdbc:h2:file:" + userHomeUri + "data/h2/keycloakdb;;AUTO_SERVER=TRUE;NON_KEYWORDS=VALUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--db=dev-mem");
|
ConfigArgsConfigSource.setCliArgs("--db=dev-mem");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
assertEquals(H2Dialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
assertEquals(H2Dialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
||||||
assertEquals("jdbc:h2:mem:keycloakdb;NON_KEYWORDS=VALUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
assertEquals("jdbc:h2:mem:keycloakdb;NON_KEYWORDS=VALUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
||||||
assertEquals("h2", config.getConfigValue("quarkus.datasource.db-kind").getValue());
|
assertEquals("h2", config.getConfigValue("quarkus.datasource.db-kind").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--db=dev-mem" + ARG_SEPARATOR + "--db-username=other");
|
ConfigArgsConfigSource.setCliArgs("--db=dev-mem", "--db-username=other");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
assertEquals("sa", config.getConfigValue("quarkus.datasource.username").getValue());
|
assertEquals("sa", config.getConfigValue("quarkus.datasource.username").getValue());
|
||||||
// should be untransformed
|
// should be untransformed
|
||||||
assertEquals("other", config.getConfigValue("kc.db-username").getValue());
|
assertEquals("other", config.getConfigValue("kc.db-username").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--db=postgres" + ARG_SEPARATOR + "--db-username=other");
|
ConfigArgsConfigSource.setCliArgs("--db=postgres", "--db-username=other");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
assertEquals("other", config.getConfigValue("quarkus.datasource.username").getValue());
|
assertEquals("other", config.getConfigValue("quarkus.datasource.username").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--db=postgres");
|
ConfigArgsConfigSource.setCliArgs("--db=postgres");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
// username should not be set, either as the quarkus or kc property
|
// username should not be set, either as the quarkus or kc property
|
||||||
assertEquals(null, config.getConfigValue("quarkus.datasource.username").getValue());
|
assertEquals(null, config.getConfigValue("quarkus.datasource.username").getValue());
|
||||||
|
@ -308,7 +308,7 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDatabaseKindProperties() {
|
public void testDatabaseKindProperties() {
|
||||||
System.setProperty(CLI_ARGS, "--db=postgres" + ARG_SEPARATOR + "--db-url=jdbc:postgresql://localhost/keycloak" + ARG_SEPARATOR + "--db-username=postgres");
|
ConfigArgsConfigSource.setCliArgs("--db=postgres", "--db-url=jdbc:postgresql://localhost/keycloak", "--db-username=postgres");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals("org.hibernate.dialect.PostgreSQLDialect",
|
assertEquals("org.hibernate.dialect.PostgreSQLDialect",
|
||||||
config.getConfigValue("kc.db-dialect").getValue());
|
config.getConfigValue("kc.db-dialect").getValue());
|
||||||
|
@ -319,7 +319,7 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultDbPropertiesGetApplied() {
|
public void testDefaultDbPropertiesGetApplied() {
|
||||||
System.setProperty(CLI_ARGS, "--db=postgres" + ARG_SEPARATOR + "--db-url-host=myhost" + ARG_SEPARATOR + "--db-url-database=kcdb" + ARG_SEPARATOR + "--db-url-properties=?foo=bar");
|
ConfigArgsConfigSource.setCliArgs("--db=postgres", "--db-url-host=myhost", "--db-url-database=kcdb", "--db-url-properties=?foo=bar");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals("org.hibernate.dialect.PostgreSQLDialect",
|
assertEquals("org.hibernate.dialect.PostgreSQLDialect",
|
||||||
config.getConfigValue("kc.db-dialect").getValue());
|
config.getConfigValue("kc.db-dialect").getValue());
|
||||||
|
@ -329,7 +329,7 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRemoveSpaceFromValue() {
|
public void testRemoveSpaceFromValue() {
|
||||||
System.setProperty(CLI_ARGS, "--db=postgres ");
|
ConfigArgsConfigSource.setCliArgs("--db=postgres ");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals("org.hibernate.dialect.PostgreSQLDialect",
|
assertEquals("org.hibernate.dialect.PostgreSQLDialect",
|
||||||
config.getConfigValue("kc.db-dialect").getValue());
|
config.getConfigValue("kc.db-dialect").getValue());
|
||||||
|
@ -338,7 +338,7 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultDbPortGetApplied() {
|
public void testDefaultDbPortGetApplied() {
|
||||||
System.setProperty(CLI_ARGS, "--db=mssql" + ARG_SEPARATOR + "--db-url-host=myhost" + ARG_SEPARATOR + "--db-url-database=kcdb" + ARG_SEPARATOR + "--db-url-port=1234" + ARG_SEPARATOR + "--db-url-properties=?foo=bar");
|
ConfigArgsConfigSource.setCliArgs("--db=mssql", "--db-url-host=myhost", "--db-url-database=kcdb", "--db-url-port=1234", "--db-url-properties=?foo=bar");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals("org.hibernate.dialect.SQLServerDialect",
|
assertEquals("org.hibernate.dialect.SQLServerDialect",
|
||||||
config.getConfigValue("kc.db-dialect").getValue());
|
config.getConfigValue("kc.db-dialect").getValue());
|
||||||
|
@ -348,7 +348,7 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetDbUrlOverridesDefaultDataSource() {
|
public void testSetDbUrlOverridesDefaultDataSource() {
|
||||||
System.setProperty(CLI_ARGS, "--db=mariadb" + ARG_SEPARATOR + "--db-url-host=myhost" + ARG_SEPARATOR + "--db-url=jdbc:mariadb://localhost/keycloak");
|
ConfigArgsConfigSource.setCliArgs("--db=mariadb", "--db-url-host=myhost", "--db-url=jdbc:mariadb://localhost/keycloak");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals("org.hibernate.dialect.MariaDBDialect",
|
assertEquals("org.hibernate.dialect.MariaDBDialect",
|
||||||
config.getConfigValue("kc.db-dialect").getValue());
|
config.getConfigValue("kc.db-dialect").getValue());
|
||||||
|
@ -360,31 +360,31 @@ public class ConfigurationTest {
|
||||||
public void testDatabaseProperties() {
|
public void testDatabaseProperties() {
|
||||||
System.setProperty("kc.db-url-properties", ";;test=test;test1=test1");
|
System.setProperty("kc.db-url-properties", ";;test=test;test1=test1");
|
||||||
System.setProperty("kc.db-url-path", "test-dir");
|
System.setProperty("kc.db-url-path", "test-dir");
|
||||||
System.setProperty(CLI_ARGS, "--db=dev-file");
|
ConfigArgsConfigSource.setCliArgs("--db=dev-file");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals(H2Dialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
assertEquals(H2Dialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
||||||
assertEquals("jdbc:h2:file:test-dir/data/h2/keycloakdb;;test=test;test1=test1;NON_KEYWORDS=VALUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
assertEquals("jdbc:h2:file:test-dir/data/h2/keycloakdb;;test=test;test1=test1;NON_KEYWORDS=VALUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
||||||
assertEquals("xa", config.getConfigValue("quarkus.datasource.jdbc.transactions").getValue());
|
assertEquals("xa", config.getConfigValue("quarkus.datasource.jdbc.transactions").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "");
|
ConfigArgsConfigSource.setCliArgs("");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
assertEquals(H2Dialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
assertEquals(H2Dialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
||||||
assertEquals("jdbc:h2:file:test-dir/data/h2/keycloakdb;;test=test;test1=test1;NON_KEYWORDS=VALUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
assertEquals("jdbc:h2:file:test-dir/data/h2/keycloakdb;;test=test;test1=test1;NON_KEYWORDS=VALUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
||||||
|
|
||||||
System.setProperty("kc.db-url-properties", "?test=test&test1=test1");
|
System.setProperty("kc.db-url-properties", "?test=test&test1=test1");
|
||||||
System.setProperty(CLI_ARGS, "--db=mariadb");
|
ConfigArgsConfigSource.setCliArgs("--db=mariadb");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
assertEquals("jdbc:mariadb://localhost:3306/keycloak?test=test&test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
assertEquals("jdbc:mariadb://localhost:3306/keycloak?test=test&test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
||||||
assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
||||||
assertEquals(MariaDbDataSource.class.getName(), config.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
|
assertEquals(MariaDbDataSource.class.getName(), config.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--db=postgres");
|
ConfigArgsConfigSource.setCliArgs("--db=postgres");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
assertEquals("jdbc:postgresql://localhost:5432/keycloak?test=test&test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
assertEquals("jdbc:postgresql://localhost:5432/keycloak?test=test&test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
||||||
assertEquals(PostgreSQLDialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
assertEquals(PostgreSQLDialect.class.getName(), config.getConfigValue("kc.db-dialect").getValue());
|
||||||
assertEquals(PGXADataSource.class.getName(), config.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
|
assertEquals(PGXADataSource.class.getName(), config.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--db-schema=test-schema");
|
ConfigArgsConfigSource.setCliArgs("--db-schema=test-schema");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
assertEquals("test-schema", config.getConfigValue("kc.db-schema").getValue());
|
assertEquals("test-schema", config.getConfigValue("kc.db-schema").getValue());
|
||||||
assertEquals("test-schema", config.getConfigValue("kc.db-schema").getValue());
|
assertEquals("test-schema", config.getConfigValue("kc.db-schema").getValue());
|
||||||
|
@ -419,34 +419,34 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
// If explicitly set, then it is always used regardless of the profile
|
// If explicitly set, then it is always used regardless of the profile
|
||||||
System.clearProperty(Environment.PROFILE);
|
System.clearProperty(Environment.PROFILE);
|
||||||
System.setProperty(CLI_ARGS, "--cache=cluster-foo.xml");
|
ConfigArgsConfigSource.setCliArgs("--cache=cluster-foo.xml");
|
||||||
|
|
||||||
Assert.assertEquals("cluster-foo.xml", initConfig("connectionsInfinispan", "quarkus").get("configFile"));
|
Assert.assertEquals("cluster-foo.xml", initConfig("connectionsInfinispan", "quarkus").get("configFile"));
|
||||||
System.setProperty(Environment.PROFILE, "dev");
|
System.setProperty(Environment.PROFILE, "dev");
|
||||||
Assert.assertEquals("cluster-foo.xml", initConfig("connectionsInfinispan", "quarkus").get("configFile"));
|
Assert.assertEquals("cluster-foo.xml", initConfig("connectionsInfinispan", "quarkus").get("configFile"));
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--cache-stack=foo");
|
ConfigArgsConfigSource.setCliArgs("--cache-stack=foo");
|
||||||
Assert.assertEquals("foo", initConfig("connectionsInfinispan", "quarkus").get("stack"));
|
Assert.assertEquals("foo", initConfig("connectionsInfinispan", "quarkus").get("stack"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCommaSeparatedArgValues() {
|
public void testCommaSeparatedArgValues() {
|
||||||
System.setProperty(CLI_ARGS, "--spi-client-jpa-searchable-attributes=bar,foo");
|
ConfigArgsConfigSource.setCliArgs("--spi-client-jpa-searchable-attributes=bar,foo");
|
||||||
assertEquals("bar,foo", initConfig("client-jpa").get("searchable-attributes"));
|
assertEquals("bar,foo", initConfig("client-jpa").get("searchable-attributes"));
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--spi-client-jpa-searchable-attributes=bar,foo,foo bar");
|
ConfigArgsConfigSource.setCliArgs("--spi-client-jpa-searchable-attributes=bar,foo,foo bar");
|
||||||
assertEquals("bar,foo,foo bar", initConfig("client-jpa").get("searchable-attributes"));
|
assertEquals("bar,foo,foo bar", initConfig("client-jpa").get("searchable-attributes"));
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--spi-client-jpa-searchable-attributes=bar,foo, \"foo bar\"");
|
ConfigArgsConfigSource.setCliArgs("--spi-client-jpa-searchable-attributes=bar,foo, \"foo bar\"");
|
||||||
assertEquals("bar,foo, \"foo bar\"", initConfig("client-jpa").get("searchable-attributes"));
|
assertEquals("bar,foo, \"foo bar\"", initConfig("client-jpa").get("searchable-attributes"));
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--spi-client-jpa-searchable-attributes=bar,foo, \"foo bar\"" + ARG_SEPARATOR + "--spi-hostname-default-frontend-url=http://foo.unittest");
|
ConfigArgsConfigSource.setCliArgs("--spi-client-jpa-searchable-attributes=bar,foo, \"foo bar\"", "--spi-hostname-default-frontend-url=http://foo.unittest");
|
||||||
assertEquals("http://foo.unittest", initConfig("hostname-default").get("frontend-url"));
|
assertEquals("http://foo.unittest", initConfig("hostname-default").get("frontend-url"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDatabaseDriverSetExplicitly() {
|
public void testDatabaseDriverSetExplicitly() {
|
||||||
System.setProperty(CLI_ARGS, "--db=mssql" + ARG_SEPARATOR + "--db-url=jdbc:sqlserver://localhost/keycloak");
|
ConfigArgsConfigSource.setCliArgs("--db=mssql", "--db-url=jdbc:sqlserver://localhost/keycloak");
|
||||||
System.setProperty("kc.db-driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
System.setProperty("kc.db-driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
|
||||||
System.setProperty("kc.transaction-xa-enabled", "false");
|
System.setProperty("kc.transaction-xa-enabled", "false");
|
||||||
assertTrue(System.getProperty(CLI_ARGS, "").contains("mssql"));
|
assertTrue(System.getProperty(CLI_ARGS, "").contains("mssql"));
|
||||||
|
@ -459,20 +459,20 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDatabaseDialectSetExplicitly() {
|
public void testDatabaseDialectSetExplicitly() {
|
||||||
System.setProperty(CLI_ARGS, "--db-dialect=user-defined");
|
ConfigArgsConfigSource.setCliArgs("--db-dialect=user-defined");
|
||||||
assertEquals("user-defined", createConfig().getRawValue("kc.db-dialect"));
|
assertEquals("user-defined", createConfig().getRawValue("kc.db-dialect"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransactionTypeChangesDriver() {
|
public void testTransactionTypeChangesDriver() {
|
||||||
System.setProperty(CLI_ARGS, "--db=mssql" + ARG_SEPARATOR + "--transaction-xa-enabled=false");
|
ConfigArgsConfigSource.setCliArgs("--db=mssql", "--transaction-xa-enabled=false");
|
||||||
assertTrue(System.getProperty(CLI_ARGS, "").contains("mssql"));
|
assertTrue(System.getProperty(CLI_ARGS, "").contains("mssql"));
|
||||||
|
|
||||||
SmallRyeConfig jtaEnabledConfig = createConfig();
|
SmallRyeConfig jtaEnabledConfig = createConfig();
|
||||||
assertEquals("com.microsoft.sqlserver.jdbc.SQLServerDriver", jtaEnabledConfig.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
|
assertEquals("com.microsoft.sqlserver.jdbc.SQLServerDriver", jtaEnabledConfig.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
|
||||||
assertEquals("enabled", jtaEnabledConfig.getConfigValue("quarkus.datasource.jdbc.transactions").getValue());
|
assertEquals("enabled", jtaEnabledConfig.getConfigValue("quarkus.datasource.jdbc.transactions").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--db=mssql" + ARG_SEPARATOR + "--transaction-xa-enabled=true");
|
ConfigArgsConfigSource.setCliArgs("--db=mssql", "--transaction-xa-enabled=true");
|
||||||
assertTrue(System.getProperty(CLI_ARGS, "").contains("mssql"));
|
assertTrue(System.getProperty(CLI_ARGS, "").contains("mssql"));
|
||||||
SmallRyeConfig xaConfig = createConfig();
|
SmallRyeConfig xaConfig = createConfig();
|
||||||
|
|
||||||
|
@ -482,42 +482,42 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResolveHealthOption() {
|
public void testResolveHealthOption() {
|
||||||
System.setProperty(CLI_ARGS, "--health-enabled=true");
|
ConfigArgsConfigSource.setCliArgs("--health-enabled=true");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals("true", config.getConfigValue("quarkus.health.extensions.enabled").getValue());
|
assertEquals("true", config.getConfigValue("quarkus.health.extensions.enabled").getValue());
|
||||||
System.setProperty(CLI_ARGS, "");
|
ConfigArgsConfigSource.setCliArgs("");
|
||||||
config = createConfig();
|
config = createConfig();
|
||||||
assertEquals("false", config.getConfigValue("quarkus.health.extensions.enabled").getValue());
|
assertEquals("false", config.getConfigValue("quarkus.health.extensions.enabled").getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResolveMetricsOption() {
|
public void testResolveMetricsOption() {
|
||||||
System.setProperty(CLI_ARGS, "--metrics-enabled=true");
|
ConfigArgsConfigSource.setCliArgs("--metrics-enabled=true");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals("true", config.getConfigValue("quarkus.datasource.metrics.enabled").getValue());
|
assertEquals("true", config.getConfigValue("quarkus.datasource.metrics.enabled").getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLogHandlerConfig() {
|
public void testLogHandlerConfig() {
|
||||||
System.setProperty(CLI_ARGS, "--log=console,file");
|
ConfigArgsConfigSource.setCliArgs("--log=console,file");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals("true", config.getConfigValue("quarkus.log.console.enable").getValue());
|
assertEquals("true", config.getConfigValue("quarkus.log.console.enable").getValue());
|
||||||
assertEquals("true", config.getConfigValue("quarkus.log.file.enable").getValue());
|
assertEquals("true", config.getConfigValue("quarkus.log.file.enable").getValue());
|
||||||
assertEquals("false", config.getConfigValue("quarkus.log.handler.gelf.enabled").getValue());
|
assertEquals("false", config.getConfigValue("quarkus.log.handler.gelf.enabled").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--log=file");
|
ConfigArgsConfigSource.setCliArgs("--log=file");
|
||||||
SmallRyeConfig config2 = createConfig();
|
SmallRyeConfig config2 = createConfig();
|
||||||
assertEquals("false", config2.getConfigValue("quarkus.log.console.enable").getValue());
|
assertEquals("false", config2.getConfigValue("quarkus.log.console.enable").getValue());
|
||||||
assertEquals("true", config2.getConfigValue("quarkus.log.file.enable").getValue());
|
assertEquals("true", config2.getConfigValue("quarkus.log.file.enable").getValue());
|
||||||
assertEquals("false", config2.getConfigValue("quarkus.log.handler.gelf.enabled").getValue());
|
assertEquals("false", config2.getConfigValue("quarkus.log.handler.gelf.enabled").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--log=console");
|
ConfigArgsConfigSource.setCliArgs("--log=console");
|
||||||
SmallRyeConfig config3 = createConfig();
|
SmallRyeConfig config3 = createConfig();
|
||||||
assertEquals("true", config3.getConfigValue("quarkus.log.console.enable").getValue());
|
assertEquals("true", config3.getConfigValue("quarkus.log.console.enable").getValue());
|
||||||
assertEquals("false", config3.getConfigValue("quarkus.log.file.enable").getValue());
|
assertEquals("false", config3.getConfigValue("quarkus.log.file.enable").getValue());
|
||||||
assertEquals("false", config3.getConfigValue("quarkus.log.handler.gelf.enabled").getValue());
|
assertEquals("false", config3.getConfigValue("quarkus.log.handler.gelf.enabled").getValue());
|
||||||
|
|
||||||
System.setProperty(CLI_ARGS, "--log=console,gelf");
|
ConfigArgsConfigSource.setCliArgs("--log=console,gelf");
|
||||||
SmallRyeConfig config4 = createConfig();
|
SmallRyeConfig config4 = createConfig();
|
||||||
assertEquals("true", config4.getConfigValue("quarkus.log.console.enable").getValue());
|
assertEquals("true", config4.getConfigValue("quarkus.log.console.enable").getValue());
|
||||||
assertEquals("false", config4.getConfigValue("quarkus.log.file.enable").getValue());
|
assertEquals("false", config4.getConfigValue("quarkus.log.file.enable").getValue());
|
||||||
|
@ -526,7 +526,7 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOptionValueWithEqualSign() {
|
public void testOptionValueWithEqualSign() {
|
||||||
System.setProperty(CLI_ARGS, "--db=postgres" + ARG_SEPARATOR + "--db-password=my_secret=");
|
ConfigArgsConfigSource.setCliArgs("--db=postgres", "--db-password=my_secret=");
|
||||||
SmallRyeConfig config = createConfig();
|
SmallRyeConfig config = createConfig();
|
||||||
assertEquals("my_secret=", config.getConfigValue("kc.db-password").getValue());
|
assertEquals("my_secret=", config.getConfigValue("kc.db-password").getValue());
|
||||||
}
|
}
|
||||||
|
@ -577,7 +577,12 @@ public class ConfigurationTest {
|
||||||
|
|
||||||
private SmallRyeConfig createConfig() {
|
private SmallRyeConfig createConfig() {
|
||||||
KeycloakConfigSourceProvider.reload();
|
KeycloakConfigSourceProvider.reload();
|
||||||
ConfigProviderResolver.setInstance(null);
|
// older versions of quarkus implicitly picked up this config, now we
|
||||||
return ConfigUtils.configBuilder(true, LaunchMode.NORMAL).build();
|
// must set it manually
|
||||||
|
SmallRyeConfig config = ConfigUtils.configBuilder(true, LaunchMode.NORMAL).build();
|
||||||
|
SmallRyeConfigProviderResolver resolver = new SmallRyeConfigProviderResolver();
|
||||||
|
resolver.registerConfig(config, Thread.currentThread().getContextClassLoader());
|
||||||
|
ConfigProviderResolver.setInstance(resolver);
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,9 @@ package org.keycloak.it.cli;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.keycloak.it.junit5.extension.CLITest;
|
import org.keycloak.it.junit5.extension.CLITest;
|
||||||
|
import org.keycloak.it.junit5.extension.ConfigurationTestResource;
|
||||||
|
|
||||||
|
import io.quarkus.test.common.QuarkusTestResource;
|
||||||
import io.quarkus.test.junit.main.Launch;
|
import io.quarkus.test.junit.main.Launch;
|
||||||
import io.quarkus.test.junit.main.LaunchResult;
|
import io.quarkus.test.junit.main.LaunchResult;
|
||||||
import org.keycloak.quarkus.runtime.cli.command.ShowConfig;
|
import org.keycloak.quarkus.runtime.cli.command.ShowConfig;
|
||||||
|
@ -28,6 +30,7 @@ import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers;
|
||||||
|
|
||||||
import static org.keycloak.quarkus.runtime.cli.command.Main.CONFIG_FILE_LONG_NAME;
|
import static org.keycloak.quarkus.runtime.cli.command.Main.CONFIG_FILE_LONG_NAME;
|
||||||
|
|
||||||
|
@QuarkusTestResource(value = ConfigurationTestResource.class, restrictToAnnotatedClass = true)
|
||||||
@CLITest
|
@CLITest
|
||||||
public class ShowConfigCommandTest {
|
public class ShowConfigCommandTest {
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When used for in-vm tests, use {@link ConfigurationTestResource} to reset the configuration
|
||||||
|
*/
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@ExtendWith({ CLITestExtension.class })
|
@ExtendWith({ CLITestExtension.class })
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
|
|
@ -64,6 +64,7 @@ public class CLITestExtension extends QuarkusMainTestExtension {
|
||||||
private DatabaseContainer databaseContainer;
|
private DatabaseContainer databaseContainer;
|
||||||
private InfinispanContainer infinispanContainer;
|
private InfinispanContainer infinispanContainer;
|
||||||
private CLIResult result;
|
private CLIResult result;
|
||||||
|
static String[] CLI_ARGS = new String[0];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeEach(ExtensionContext context) throws Exception {
|
public void beforeEach(ExtensionContext context) throws Exception {
|
||||||
|
@ -71,13 +72,13 @@ public class CLITestExtension extends QuarkusMainTestExtension {
|
||||||
Launch launch = context.getRequiredTestMethod().getAnnotation(Launch.class);
|
Launch launch = context.getRequiredTestMethod().getAnnotation(Launch.class);
|
||||||
getStore(context).put(SYS_PROPS, new HashMap<>(System.getProperties()));
|
getStore(context).put(SYS_PROPS, new HashMap<>(System.getProperties()));
|
||||||
|
|
||||||
if (launch != null) {
|
if (launch != null && distConfig == null) {
|
||||||
for (String arg : launch.value()) {
|
for (String arg : launch.value()) {
|
||||||
if (arg.contains(CONFIG_FILE_SHORT_NAME) || arg.contains(CONFIG_FILE_LONG_NAME)) {
|
if (arg.contains(CONFIG_FILE_SHORT_NAME) || arg.contains(CONFIG_FILE_LONG_NAME)) {
|
||||||
Pattern kvSeparator = Pattern.compile(KEY_VALUE_SEPARATOR);
|
Pattern kvSeparator = Pattern.compile(KEY_VALUE_SEPARATOR);
|
||||||
String[] cfKeyValue = kvSeparator.split(arg);
|
String[] cfKeyValue = kvSeparator.split(arg);
|
||||||
setProperty(KeycloakPropertiesConfigSource.KEYCLOAK_CONFIG_FILE_PROP, cfKeyValue[1]);
|
setProperty(KeycloakPropertiesConfigSource.KEYCLOAK_CONFIG_FILE_PROP, cfKeyValue[1]);
|
||||||
} else if (distConfig == null && arg.startsWith("-D")) {
|
} else if (arg.startsWith("-D")) {
|
||||||
// allow setting system properties from JVM tests
|
// allow setting system properties from JVM tests
|
||||||
int keyValueSeparator = arg.indexOf('=');
|
int keyValueSeparator = arg.indexOf('=');
|
||||||
|
|
||||||
|
@ -114,6 +115,7 @@ public class CLITestExtension extends QuarkusMainTestExtension {
|
||||||
result = dist.run(Stream.concat(List.of(launch.value()).stream(), List.of(distConfig.defaultOptions()).stream()).collect(Collectors.toList()));
|
result = dist.run(Stream.concat(List.of(launch.value()).stream(), List.of(distConfig.defaultOptions()).stream()).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
CLI_ARGS = launch == null ? new String[] {} : launch.value();
|
||||||
configureProfile(context);
|
configureProfile(context);
|
||||||
super.beforeEach(context);
|
super.beforeEach(context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2024 Red Hat, Inc. and/or its affiliates
|
||||||
|
* and other contributors as indicated by the @author tags.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.keycloak.it.junit5.extension;
|
||||||
|
|
||||||
|
import io.quarkus.runtime.LaunchMode;
|
||||||
|
import io.quarkus.runtime.configuration.ConfigUtils;
|
||||||
|
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
|
||||||
|
import io.smallrye.config.SmallRyeConfig;
|
||||||
|
import io.smallrye.config.SmallRyeConfigProviderResolver;
|
||||||
|
|
||||||
|
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
|
||||||
|
import org.keycloak.quarkus.runtime.configuration.ConfigArgsConfigSource;
|
||||||
|
import org.keycloak.quarkus.runtime.configuration.KeycloakConfigSourceProvider;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to reset the configuration for {@link CLITest}s
|
||||||
|
*/
|
||||||
|
public class ConfigurationTestResource implements QuarkusTestResourceLifecycleManager {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> start() {
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void inject(Object testInstance) {
|
||||||
|
ConfigArgsConfigSource.setCliArgs(CLITestExtension.CLI_ARGS);
|
||||||
|
KeycloakConfigSourceProvider.reload();
|
||||||
|
SmallRyeConfig config = ConfigUtils.configBuilder(true, LaunchMode.NORMAL).build();
|
||||||
|
SmallRyeConfigProviderResolver resolver = new SmallRyeConfigProviderResolver();
|
||||||
|
resolver.registerConfig(config, Thread.currentThread().getContextClassLoader());
|
||||||
|
ConfigProviderResolver.setInstance(resolver);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -65,6 +65,11 @@
|
||||||
<groupId>org.wildfly.core</groupId>
|
<groupId>org.wildfly.core</groupId>
|
||||||
<artifactId>wildfly-controller</artifactId>
|
<artifactId>wildfly-controller</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- pick up the transitive dependencies for the quarkus logmanager -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.logmanager</groupId>
|
||||||
|
<artifactId>jboss-logmanager</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.keycloak.testsuite</groupId>
|
<groupId>org.keycloak.testsuite</groupId>
|
||||||
<artifactId>integration-arquillian-testsuite-providers-deployment</artifactId>
|
<artifactId>integration-arquillian-testsuite-providers-deployment</artifactId>
|
||||||
|
|
Loading…
Reference in a new issue