keycloakCRName
and realm
are no longer marked as required in KeycloakRealmImport CRD
Closes #21607
This commit is contained in:
parent
539eddc5cd
commit
6a3ea1a084
2 changed files with 20 additions and 4 deletions
|
@ -17,16 +17,15 @@
|
|||
package org.keycloak.operator.crds.v2alpha1.realmimport;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
import io.fabric8.generator.annotation.Required;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
public class KeycloakRealmImportSpec {
|
||||
|
||||
@NotNull
|
||||
@Required
|
||||
@JsonPropertyDescription("The name of the Keycloak CR to reference, in the same namespace.")
|
||||
private String keycloakCRName;
|
||||
@NotNull
|
||||
@Required
|
||||
@JsonPropertyDescription("The RealmRepresentation to import into Keycloak.")
|
||||
private RealmRepresentation realm;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.keycloak.operator.testsuite.integration;
|
|||
import io.fabric8.junit.jupiter.api.KubernetesTest;
|
||||
import io.fabric8.kubernetes.api.model.HasMetadata;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClientException;
|
||||
import io.fabric8.kubernetes.client.dsl.Resource;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
@ -30,8 +31,10 @@ import org.keycloak.operator.crds.v2alpha1.realmimport.KeycloakRealmImport;
|
|||
import java.io.FileNotFoundException;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.keycloak.operator.crds.v2alpha1.realmimport.KeycloakRealmImportBuilder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@KubernetesTest
|
||||
public class CRDTest {
|
||||
|
@ -50,6 +53,20 @@ public class CRDTest {
|
|||
roundTrip("/test-serialization-realmimport-cr.yml", KeycloakRealmImport.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRealmImportWithoutRequiredFields() {
|
||||
KeycloakRealmImport cr = new KeycloakRealmImportBuilder()
|
||||
.withNewMetadata()
|
||||
.withName("invalid-realm")
|
||||
.endMetadata()
|
||||
.withNewSpec()
|
||||
.endSpec()
|
||||
.build();
|
||||
|
||||
var eMsg = assertThrows(KubernetesClientException.class, () -> client.resource(cr).create()).getMessage();
|
||||
assertThat(eMsg).contains("spec.keycloakCRName: Required value", "spec.realm: Required value");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeycloak() {
|
||||
roundTrip("/test-serialization-keycloak-cr.yml", Keycloak.class);
|
||||
|
|
Loading…
Reference in a new issue