From 624c15bfc02f947d4aa0f9b04a8560a324390f15 Mon Sep 17 00:00:00 2001
From: OZGCloud <ozgcloud@mgm-tp.com>
Date: Wed, 28 Aug 2024 17:04:14 +0200
Subject: [PATCH] OZG-6574 ignore case for service konto type comparison

---
 .../ozgcloud/alfa/postfach/PostfachMailService.java |  2 +-
 .../alfa/postfach/PostfachMailServiceTest.java      | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/postfach/PostfachMailService.java b/alfa-service/src/main/java/de/ozgcloud/alfa/postfach/PostfachMailService.java
index 732530317e..17c5a69936 100644
--- a/alfa-service/src/main/java/de/ozgcloud/alfa/postfach/PostfachMailService.java
+++ b/alfa-service/src/main/java/de/ozgcloud/alfa/postfach/PostfachMailService.java
@@ -161,7 +161,7 @@ class PostfachMailService {
 		}
 
 		return postfachConfigGroup.getPostfachConfigs().stream()
-				.filter(postfachConfig -> postfachConfig.getType().equals(serviceKontoType))
+				.filter(postfachConfig -> postfachConfig.getType().equalsIgnoreCase(serviceKontoType))
 				.map(PostfachConfig::isReplyAllowed)
 				.findFirst()
 				.orElse(false);
diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachMailServiceTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachMailServiceTest.java
index 85c964af5f..f31e143f6a 100644
--- a/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachMailServiceTest.java
+++ b/alfa-service/src/test/java/de/ozgcloud/alfa/postfach/PostfachMailServiceTest.java
@@ -556,7 +556,7 @@ class PostfachMailServiceTest {
 		}
 
 		@Test
-		@DisplayName("reply not allowed for given ServiceKonto-type")
+		@DisplayName("reply not allowed if postfach not configured")
 		void shouldReturnFalseIfPostfachNotConfigured() {
 			setPostfachConfigGroup(PostfachConfigGroupTestFactory.createBuilder().postfachConfigs(List.of()).build());
 			doReturn(false).when(service).isPostfachConfigured();
@@ -612,6 +612,17 @@ class PostfachMailServiceTest {
 			assertThat(replyAllowed).isTrue();
 		}
 
+		@Test
+		@DisplayName("reply allowed for given lower case ServiceKonto-type")
+		void shouldReturnTrueIfReplyIsAllowedForLowerCaseServiceKontoType() {
+			setPostfachConfigGroup(PostfachConfigGroupTestFactory.create());
+			doReturn(true).when(service).isPostfachConfigured();
+
+			var replyAllowed = service.isReplyAllowed(PostfachConfigTestFactory.TYPE.toLowerCase());
+
+			assertThat(replyAllowed).isTrue();
+		}
+
 		@Test
 		void shouldReturnTrueIfAlwaysAllowed() {
 			when(featureToggleProperties.isReplyAlwaysAllowed()).thenReturn(true);
-- 
GitLab