Skip to content
Snippets Groups Projects
Commit 77547481 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4870 improve kc smtp config unittests

parent 130da165
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
package de.ozgcloud.operator.keycloak.realm; package de.ozgcloud.operator.keycloak.realm;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import java.util.Map;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
...@@ -102,21 +103,24 @@ class KeycloakRealmMapperTest { ...@@ -102,21 +103,24 @@ class KeycloakRealmMapperTest {
void shouldContainSmtpServerKeysValues() { void shouldContainSmtpServerKeysValues() {
var mapped = mapper.map(OzgCloudKeycloakRealmSpecTestFactory.create()); var mapped = mapper.map(OzgCloudKeycloakRealmSpecTestFactory.create());
var mappedSmtpServer = mapped.getSmtpServer(); var mappedSmtpServer = mapped.getSmtpServer();
assertThat(mappedSmtpServer.get("host"))
.isEqualTo(KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_HOST); assertThat(Map.of(mappedSmtpServer.get("host"), KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_HOST));
assertThat(mappedSmtpServer.get("port")) assertThat(Map.of(mappedSmtpServer.get("port"), KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_PORT));
.isEqualTo(KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_PORT); assertThat(Map.of(mappedSmtpServer.get("password"), KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_PASSWORD));
assertThat(mappedSmtpServer.get("password")).isEqualTo(KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_PASSWORD); assertThat(Map.of(mappedSmtpServer.get("user"), KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_USER));
assertThat(mappedSmtpServer.get("user")) assertThat(Map.of(mappedSmtpServer.get("starttls"), KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_STARTTLS));
.isEqualTo(KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_USER); assertThat(Map.of(mappedSmtpServer.get("auth"), KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_AUTH));
assertThat(mappedSmtpServer.get("starttls")).isEqualTo(KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_STARTTLS); assertThat(Map.of(mappedSmtpServer.get("from"), KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_FROM));
assertThat(mappedSmtpServer.get("auth")) assertThat(Map.of(mappedSmtpServer.get("fromDisplayName"), KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_FROM_DISPLAY_NAME));
.isEqualTo(KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_AUTH);
assertThat(mappedSmtpServer.get("from"))
.isEqualTo(KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_FROM);
assertThat(mappedSmtpServer.get("fromDisplayName"))
.isEqualTo(KeycloakRealmSmtpServerTestFactory.SMTP_SERVER_FROM_DISPLAY_NAME);
} }
@Test
void shouldMapWhenSmtpServerIsNull() {
var mapped = mapper.map(OzgCloudKeycloakRealmSpecTestFactory.createBuilder().smtpServer(null).build());
assertThat(mapped.getSmtpServer()).isEmpty();
}
} }
...@@ -71,15 +71,6 @@ class KeycloakRealmReconcilerTest { ...@@ -71,15 +71,6 @@ class KeycloakRealmReconcilerTest {
assertThat(response.getResource().getStatus().getStatus()).isEqualTo(OzgCloudCustomResourceStatus.OK); assertThat(response.getResource().getStatus().getStatus()).isEqualTo(OzgCloudCustomResourceStatus.OK);
} }
@Test
void shouldCreateRealmWithSpecWithoutSMTPServer() {
OzgCloudKeycloakRealm realm = OzgCloudKeycloakRealmTestFactory.create();
reconciler.reconcile(realm, null);
var spec = realm.getSpec();
spec.setSmtpServer(null);
verify(service).createRealm(spec, OzgCloudKeycloakRealmTestFactory.METADATA_NAMESPACE);
}
} }
@DisplayName("Cleanup") @DisplayName("Cleanup")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment