From 9a44bc4451288d46928e127a1732d599871bdbc6 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Tue, 9 Apr 2024 22:34:13 +0200
Subject: [PATCH] OZG-4870 add fromDisplayName in realm smtp config

---
 .../ozgcloud/operator/keycloak/realm/KeycloakRealmMapper.java | 1 +
 .../operator/keycloak/realm/OzgCloudKeycloakRealmSpec.java    | 4 ++++
 .../operator/keycloak/realm/KeycloakRealmMapperTest.java      | 3 ++-
 .../keycloak/realm/OzgCloudKeycloakRealmSpecTestFactory.java  | 3 ++-
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapper.java b/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapper.java
index e74f7d8..f4d143c 100644
--- a/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapper.java
+++ b/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapper.java
@@ -62,6 +62,7 @@ interface KeycloakRealmMapper {
 		smtpServer.put("starttls", server.getStarttls().toString()); 
 		smtpServer.put("auth", server.getAuth().toString()); 
 		smtpServer.put("from", server.getFrom()); 
+		smtpServer.put("fromDisplayName", server.getFromDisplayName()); 
 		return smtpServer;
 	}
 
diff --git a/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/OzgCloudKeycloakRealmSpec.java b/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/OzgCloudKeycloakRealmSpec.java
index d817517..c92f934 100644
--- a/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/OzgCloudKeycloakRealmSpec.java
+++ b/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/OzgCloudKeycloakRealmSpec.java
@@ -65,8 +65,12 @@ static class KeycloakRealmSMTPServer {
 	private String port;
 
 	private Boolean starttls;
+
 	private Boolean auth;
+
 	private String from;
+	
+	private String fromDisplayName;
 }
 
 }
diff --git a/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapperTest.java b/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapperTest.java
index c9fadd5..9a090e5 100644
--- a/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapperTest.java
+++ b/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapperTest.java
@@ -94,7 +94,7 @@ class KeycloakRealmMapperTest {
 	void shouldMapSmtpServer() {
 		var mapped = mapper.map(OzgCloudKeycloakRealmSpecTestFactory.create());
 
-		assertThat(mapped.getSmtpServer().size()).isEqualTo(7);
+		assertThat(mapped.getSmtpServer().size()).isEqualTo(8);
 	}
 
 	@Test
@@ -108,6 +108,7 @@ class KeycloakRealmMapperTest {
 		assertThat(mappedSmtpServer.get("starttls")).isEqualTo("true");
 		assertThat(mappedSmtpServer.get("auth")).isEqualTo("true");
 		assertThat(mappedSmtpServer.get("from")).isEqualTo("test@test.de");
+		assertThat(mappedSmtpServer.get("fromDisplayName")).isEqualTo("displayed name");
 		
 	}	
 }
diff --git a/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/realm/OzgCloudKeycloakRealmSpecTestFactory.java b/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/realm/OzgCloudKeycloakRealmSpecTestFactory.java
index 12ba82a..2e6ab10 100644
--- a/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/realm/OzgCloudKeycloakRealmSpecTestFactory.java
+++ b/ozgcloud-keycloak-operator/src/test/java/de/ozgcloud/operator/keycloak/realm/OzgCloudKeycloakRealmSpecTestFactory.java
@@ -29,7 +29,8 @@ public class OzgCloudKeycloakRealmSpecTestFactory {
 
 	public final static String DISPLAY_NAME = "TestDisplayName";
 	public final static boolean KEEP_AFTER_DELETE = false;
-	public final static KeycloakRealmSMTPServer SMTP_SERVER = KeycloakRealmSMTPServer.builder().host("host").user("user").password("psw").port("432").starttls(true).auth(true).from("test@test.de").build();
+	public final static KeycloakRealmSMTPServer SMTP_SERVER = KeycloakRealmSMTPServer.builder().host("host").user("user").
+	password("psw").port("432").starttls(true).auth(true).from("test@test.de").fromDisplayName("displayed name").build();
 
 	public static OzgCloudKeycloakRealmSpec create() {
 		return createBuilder().build();
-- 
GitLab