From 0457367afb0eb7d0063f3452202559617c5d7060 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Fri, 17 Jan 2025 09:17:54 +0100 Subject: [PATCH 01/16] OZG-4094 osi2: Add osiv2-postfach dependency --- nachrichten-manager-server/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 67a127f..76af399 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -48,6 +48,7 @@ <bayernid-proxy-interface.version>0.7.0</bayernid-proxy-interface.version> <vorgang-manager.version>2.17.0</vorgang-manager.version> <muk-postfach.version>0.1.0</muk-postfach.version> + <osiv2-postfach.version>0.1.1-SNAPSHOT</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.version> <ozgcloud-common.version>4.7.0</ozgcloud-common.version> </properties> @@ -88,6 +89,11 @@ <artifactId>muk-postfach</artifactId> <version>${muk-postfach.version}</version> </dependency> + <dependency> + <groupId>de.ozgcloud.osiv2</groupId> + <artifactId>osiv2-postfach</artifactId> + <version>${osiv2-postfach.version}</version> + </dependency> <dependency> <groupId>de.ozgcloud.info</groupId> -- GitLab From 4b2018d8ad1c9b6a4da9e97da29bc88fab922834 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Wed, 22 Jan 2025 12:00:35 +0100 Subject: [PATCH 02/16] OZG-4094 osi: Add osi-postfach ITCase --- .../postfach/OsiPostfachServiceITCase.java | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java new file mode 100644 index 0000000..55bf5fd --- /dev/null +++ b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java @@ -0,0 +1,94 @@ +package de.ozgcloud.nachrichten.postfach; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.Mockito.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.event.EventListener; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.client.RestTemplate; + +import de.ozgcloud.common.test.ITCase; +import de.ozgcloud.nachrichten.attributes.ClientAttributeService; +import de.ozgcloud.nachrichten.email.EmailGrpcService; +import de.ozgcloud.nachrichten.postfach.osi.MessageAttachmentService; +import lombok.SneakyThrows; + +@ITCase +@TestPropertySource(properties = { + "ozgcloud.osi.postfach.proxyapi.key=key", + "ozgcloud.osi.postfach.proxyapi.realm=realm", + "ozgcloud.osi.postfach.proxyapi.url=url", +}) +class OsiPostfachServiceITCase { + + @Autowired + private PostfachService postfachService; + + @MockBean + private ClientAttributeService clientAttributeRemoteService; + + @MockBean + private MessageAttachmentService messageAttachmentService; + + @MockBean + private EmailGrpcService emailGrpcService; + + @MockBean + private RestTemplate restTemplate; + + @Autowired + private SentEventTestListener sentEventTestListener; + + @BeforeEach + void mock() { + sentEventTestListener.reset(); + } + + @DisplayName("should call osi postfach send") + @Test + @SneakyThrows + void shouldCallOsiPostfachSend() { + var osiNachricht = PostfachNachrichtTestFactory.createBuilder() + .postfachAddress(PostfachAddressTestFactory.createBuilder() + .serviceKontoType("OSI") + .build() + ) + .build(); + var commandId = "aaaaa"; + when(restTemplate.exchange(eq("url"), eq(HttpMethod.POST), any(), Mockito.<Class<String>>any())).thenReturn(ResponseEntity.ok("true")); + + + postfachService.sendMail(commandId, "userId", osiNachricht); + + assertThat(sentEventTestListener.events) + .extracting(PostfachMailSentEvent::getSource) + .containsExactly(commandId); + } + + @Component + static class SentEventTestListener { + final List<PostfachMailSentEvent> events = new ArrayList<>(); + + @EventListener + void onEvent(PostfachMailSentEvent event) { + events.add(event); + } + + void reset() { + events.clear(); + } + } + +} -- GitLab From 332c2296867f92626be4815be4be2b532d93d081 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Fri, 24 Jan 2025 13:28:22 +0100 Subject: [PATCH 03/16] OZG-4094 osi2: Add osiv2-postfach ITCase --- nachrichten-manager-server/pom.xml | 2 +- .../postfach/Osi2PostfachServiceITCase.java | 85 +++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 76af399..575746c 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -48,7 +48,7 @@ <bayernid-proxy-interface.version>0.7.0</bayernid-proxy-interface.version> <vorgang-manager.version>2.17.0</vorgang-manager.version> <muk-postfach.version>0.1.0</muk-postfach.version> - <osiv2-postfach.version>0.1.1-SNAPSHOT</osiv2-postfach.version> + <osiv2-postfach.version>0.1.3-SNAPSHOT</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.version> <ozgcloud-common.version>4.7.0</ozgcloud-common.version> </properties> diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java new file mode 100644 index 0000000..55a583a --- /dev/null +++ b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java @@ -0,0 +1,85 @@ +package de.ozgcloud.nachrichten.postfach; + +import static org.assertj.core.api.Assertions.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; +import org.springframework.test.context.TestPropertySource; + +import de.ozgcloud.common.test.ITCase; +import de.ozgcloud.nachrichten.attributes.ClientAttributeService; +import de.ozgcloud.nachrichten.email.EmailGrpcService; +import de.ozgcloud.nachrichten.postfach.osiv2.transfer.PostfachApiFacadeService; +import de.ozgcloud.vorgang.callcontext.WithMockCustomUser; + +@ITCase +@TestPropertySource(properties = { + "ozgcloud.osiv2-postfach.enabled=true" +}) +class Osi2PostfachServiceITCase { + + @Autowired + private PostfachService postfachService; + + @MockBean + private ApplicationEventPublisher publisher; + + @MockBean + private ClientAttributeService clientAttributeRemoteService; + + @MockBean + private PostfachApiFacadeService postfachApiFacadeService; + + @MockBean + private EmailGrpcService emailGrpcService; + + @Autowired + private OsiPostfachServiceITCase.SentEventTestListener sentEventTestListener; + + @BeforeEach + void mock() { + sentEventTestListener.reset(); + } + + @DisplayName("should call osi2 postfach send") + @Test + @WithMockCustomUser + void shouldCallOsi2PostfachSend() { + var osiNachricht = PostfachNachrichtTestFactory.createBuilder() + .postfachAddress(PostfachAddressTestFactory.createBuilder() + .serviceKontoType("OSI") + .build() + ) + .build(); + var commandId = "aaaaa"; + + postfachService.sendMail(commandId, "userId", osiNachricht); + + assertThat(sentEventTestListener.events) + .extracting(PostfachMailSentEvent::getSource) + .containsExactly(commandId); + } + + @Component + static class SentEventTestListener { + final List<PostfachMailSentEvent> events = new ArrayList<>(); + + @EventListener + void onEvent(PostfachMailSentEvent event) { + events.add(event); + } + + void reset() { + events.clear(); + } + } +} -- GitLab From 1ba6b181ea62ca0253fdf2ac7e04977bed872318 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Fri, 24 Jan 2025 13:51:13 +0100 Subject: [PATCH 04/16] OZG-4094 pom: Update parent pom --- nachrichten-manager-server/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 575746c..00327eb 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -48,7 +48,7 @@ <bayernid-proxy-interface.version>0.7.0</bayernid-proxy-interface.version> <vorgang-manager.version>2.17.0</vorgang-manager.version> <muk-postfach.version>0.1.0</muk-postfach.version> - <osiv2-postfach.version>0.1.3-SNAPSHOT</osiv2-postfach.version> + <osiv2-postfach.version>0.1.4-SNAPSHOT</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.version> <ozgcloud-common.version>4.7.0</ozgcloud-common.version> </properties> diff --git a/pom.xml b/pom.xml index 0cda336..46ef701 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ <parent> <groupId>de.ozgcloud.common</groupId> <artifactId>ozgcloud-common-parent</artifactId> - <version>4.7.0</version> + <version>4.9.0-SNAPSHOT</version> </parent> <groupId>de.ozgcloud.nachrichten</groupId> -- GitLab From 77673d7d023310cb319387cff96d6dabdef4ac48 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Fri, 24 Jan 2025 15:09:47 +0100 Subject: [PATCH 05/16] OZG-4094 pom: Use updated common version --- nachrichten-manager-server/pom.xml | 4 +--- pom.xml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 00327eb..bc84ada 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -48,9 +48,8 @@ <bayernid-proxy-interface.version>0.7.0</bayernid-proxy-interface.version> <vorgang-manager.version>2.17.0</vorgang-manager.version> <muk-postfach.version>0.1.0</muk-postfach.version> - <osiv2-postfach.version>0.1.4-SNAPSHOT</osiv2-postfach.version> + <osiv2-postfach.version>0.1.55-SNAPSHOT</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.version> - <ozgcloud-common.version>4.7.0</ozgcloud-common.version> </properties> <dependencies> @@ -110,7 +109,6 @@ <dependency> <groupId>de.ozgcloud.common</groupId> <artifactId>ozgcloud-common-lib</artifactId> - <version>${ozgcloud-common.version}</version> </dependency> <dependency> diff --git a/pom.xml b/pom.xml index 46ef701..2a90ade 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ <parent> <groupId>de.ozgcloud.common</groupId> <artifactId>ozgcloud-common-parent</artifactId> - <version>4.9.0-SNAPSHOT</version> + <version>4.9.0</version> </parent> <groupId>de.ozgcloud.nachrichten</groupId> -- GitLab From a10e35cc15ea46151c1d262e6458dde355cbf24f Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Fri, 24 Jan 2025 15:37:30 +0100 Subject: [PATCH 06/16] OZG-4094 pom: Try out osvi2-postfach --- nachrichten-manager-server/pom.xml | 10 ++++++++++ .../src/main/resources/application.yaml | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 nachrichten-manager-server/src/main/resources/application.yaml diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index bc84ada..6aa11d0 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -173,6 +173,16 @@ <artifactId>grpc-client-spring-boot-starter</artifactId> </dependency> + <!-- oauth for osiv2-postfach --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-oauth2-client</artifactId> + </dependency> + <!-- commons --> <dependency> <groupId>org.apache.commons</groupId> diff --git a/nachrichten-manager-server/src/main/resources/application.yaml b/nachrichten-manager-server/src/main/resources/application.yaml new file mode 100644 index 0000000..ee8f0aa --- /dev/null +++ b/nachrichten-manager-server/src/main/resources/application.yaml @@ -0,0 +1,8 @@ +spring: + security: + oauth2: + client: + registration: + other: + provider: + other: \ No newline at end of file -- GitLab From 945051ff8782937c0496e2c90314364cb3612b62 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Mon, 27 Jan 2025 14:29:30 +0100 Subject: [PATCH 07/16] OZG-4094 pom: Use `stage` profile of osvi2-postfach --- nachrichten-manager-server/pom.xml | 2 +- .../src/main/resources/application.yaml | 8 ------ .../postfach/Osi2PostfachServiceITCase.java | 26 ++++++++++++++----- .../postfach/OsiPostfachServiceITCase.java | 19 +++++++------- 4 files changed, 31 insertions(+), 24 deletions(-) delete mode 100644 nachrichten-manager-server/src/main/resources/application.yaml diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 6aa11d0..62b4aea 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -48,7 +48,7 @@ <bayernid-proxy-interface.version>0.7.0</bayernid-proxy-interface.version> <vorgang-manager.version>2.17.0</vorgang-manager.version> <muk-postfach.version>0.1.0</muk-postfach.version> - <osiv2-postfach.version>0.1.55-SNAPSHOT</osiv2-postfach.version> + <osiv2-postfach.version>0.1.0-SNAPSHOT</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.version> </properties> diff --git a/nachrichten-manager-server/src/main/resources/application.yaml b/nachrichten-manager-server/src/main/resources/application.yaml deleted file mode 100644 index ee8f0aa..0000000 --- a/nachrichten-manager-server/src/main/resources/application.yaml +++ /dev/null @@ -1,8 +0,0 @@ -spring: - security: - oauth2: - client: - registration: - other: - provider: - other: \ No newline at end of file diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java index 55a583a..516d16b 100644 --- a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java +++ b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java @@ -9,27 +9,33 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; -import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.ActiveProfiles; -import de.ozgcloud.common.test.ITCase; +import de.ozgcloud.nachrichten.NachrichtenManagerTestApplication; import de.ozgcloud.nachrichten.attributes.ClientAttributeService; import de.ozgcloud.nachrichten.email.EmailGrpcService; +import de.ozgcloud.nachrichten.postfach.osiv2.config.Osi2PostfachProperties; import de.ozgcloud.nachrichten.postfach.osiv2.transfer.PostfachApiFacadeService; import de.ozgcloud.vorgang.callcontext.WithMockCustomUser; -@ITCase -@TestPropertySource(properties = { - "ozgcloud.osiv2-postfach.enabled=true" -}) +@SpringBootTest(classes = NachrichtenManagerTestApplication.class, + properties = { + "ozgcloud.osiv2-postfach.enabled=true" + }) +@ActiveProfiles({ "itcase", "stage" }) class Osi2PostfachServiceITCase { @Autowired private PostfachService postfachService; + @Autowired + private Osi2PostfachProperties.ApiConfiguration osi2ApiConfiguration; + @MockBean private ApplicationEventPublisher publisher; @@ -50,6 +56,14 @@ class Osi2PostfachServiceITCase { sentEventTestListener.reset(); } + @DisplayName("should use stage profile properties") + @Test + void shouldUseStageProfileProperties() { + var url = osi2ApiConfiguration.getUrl(); + + assertThat(url).isNotEmpty(); + } + @DisplayName("should call osi2 postfach send") @Test @WithMockCustomUser diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java index 55bf5fd..d647dcc 100644 --- a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java +++ b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java @@ -11,26 +11,28 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.event.EventListener; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; -import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.ActiveProfiles; import org.springframework.web.client.RestTemplate; -import de.ozgcloud.common.test.ITCase; +import de.ozgcloud.nachrichten.NachrichtenManagerTestApplication; import de.ozgcloud.nachrichten.attributes.ClientAttributeService; import de.ozgcloud.nachrichten.email.EmailGrpcService; import de.ozgcloud.nachrichten.postfach.osi.MessageAttachmentService; import lombok.SneakyThrows; -@ITCase -@TestPropertySource(properties = { - "ozgcloud.osi.postfach.proxyapi.key=key", - "ozgcloud.osi.postfach.proxyapi.realm=realm", - "ozgcloud.osi.postfach.proxyapi.url=url", -}) +@SpringBootTest(classes = NachrichtenManagerTestApplication.class, + properties = { + "ozgcloud.osi.postfach.proxyapi.key=key", + "ozgcloud.osi.postfach.proxyapi.realm=realm", + "ozgcloud.osi.postfach.proxyapi.url=url", + }) +@ActiveProfiles({ "itcase" }) class OsiPostfachServiceITCase { @Autowired @@ -69,7 +71,6 @@ class OsiPostfachServiceITCase { var commandId = "aaaaa"; when(restTemplate.exchange(eq("url"), eq(HttpMethod.POST), any(), Mockito.<Class<String>>any())).thenReturn(ResponseEntity.ok("true")); - postfachService.sendMail(commandId, "userId", osiNachricht); assertThat(sentEventTestListener.events) -- GitLab From 04311c397e477afd4d6d79a1c501d6752f402c37 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Tue, 28 Jan 2025 13:54:21 +0100 Subject: [PATCH 08/16] OZG-4094 pom: Use branch version of osiv2-postfach --- nachrichten-manager-server/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 62b4aea..bc64521 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -48,7 +48,7 @@ <bayernid-proxy-interface.version>0.7.0</bayernid-proxy-interface.version> <vorgang-manager.version>2.17.0</vorgang-manager.version> <muk-postfach.version>0.1.0</muk-postfach.version> - <osiv2-postfach.version>0.1.0-SNAPSHOT</osiv2-postfach.version> + <osiv2-postfach.version>0.1.0-SNAPSHOT-OZG-4094</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.version> </properties> -- GitLab From 4ef33b188d89b6809cfdcae8487096a4472e23a0 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Tue, 28 Jan 2025 14:24:29 +0100 Subject: [PATCH 09/16] OZG-4094 pom: Use branch version of nachrichten-manager --- .../pom.xml | 2 +- nachrichten-manager-server/pom.xml | 2 +- pom.xml | 23 ++++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/nachrichten-manager-postfach-interface/pom.xml b/nachrichten-manager-postfach-interface/pom.xml index b336d40..01b9cf6 100644 --- a/nachrichten-manager-postfach-interface/pom.xml +++ b/nachrichten-manager-postfach-interface/pom.xml @@ -31,7 +31,7 @@ <parent> <groupId>de.ozgcloud.nachrichten</groupId> <artifactId>nachrichten-manager</artifactId> - <version>2.17.0-SNAPSHOT</version> + <version>2.17.0-SNAPSHOT-OZG-4094</version> <relativePath>../</relativePath> </parent> diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index bc64521..1d9bc0b 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -32,7 +32,7 @@ <parent> <groupId>de.ozgcloud.nachrichten</groupId> <artifactId>nachrichten-manager</artifactId> - <version>2.17.0-SNAPSHOT</version> + <version>2.17.0-SNAPSHOT-OZG-4094</version> <relativePath>../</relativePath> </parent> diff --git a/pom.xml b/pom.xml index 2a90ade..57ea7de 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ <groupId>de.ozgcloud.nachrichten</groupId> <artifactId>nachrichten-manager</artifactId> - <version>2.17.0-SNAPSHOT</version> + <version>2.17.0-SNAPSHOT-OZG-4094</version> <name>OZG-Cloud Nachrichten Manager</name> <packaging>pom</packaging> @@ -54,4 +54,25 @@ <module>nachrichten-manager-postfach-interface</module> </modules> + <profiles> + <profile> + <id>nexus-deploy</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <distributionManagement> + <repository> + <id>ozg-nexus</id> + <name>ozg-releases</name> + <url>https://nexus.ozg-sh.de/repository/ozg-releases/</url> + </repository> + <snapshotRepository> + <id>ozg-snapshots-nexus</id> + <name>ozg-snapshots</name> + <url>https://nexus.ozg-sh.de/repository/ozg-snapshots/</url> + </snapshotRepository> + </distributionManagement> + </profile> + </profiles> + </project> -- GitLab From f6869cf63fbc269975e7dbb8f3c5e44c74cb6202 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Fri, 31 Jan 2025 09:39:36 +0100 Subject: [PATCH 10/16] OZG-4094 pom: Reset version version of nachrichten-manager --- nachrichten-manager-postfach-interface/pom.xml | 2 +- nachrichten-manager-server/pom.xml | 4 ++-- pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nachrichten-manager-postfach-interface/pom.xml b/nachrichten-manager-postfach-interface/pom.xml index 01b9cf6..b336d40 100644 --- a/nachrichten-manager-postfach-interface/pom.xml +++ b/nachrichten-manager-postfach-interface/pom.xml @@ -31,7 +31,7 @@ <parent> <groupId>de.ozgcloud.nachrichten</groupId> <artifactId>nachrichten-manager</artifactId> - <version>2.17.0-SNAPSHOT-OZG-4094</version> + <version>2.17.0-SNAPSHOT</version> <relativePath>../</relativePath> </parent> diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 1d9bc0b..62b4aea 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -32,7 +32,7 @@ <parent> <groupId>de.ozgcloud.nachrichten</groupId> <artifactId>nachrichten-manager</artifactId> - <version>2.17.0-SNAPSHOT-OZG-4094</version> + <version>2.17.0-SNAPSHOT</version> <relativePath>../</relativePath> </parent> @@ -48,7 +48,7 @@ <bayernid-proxy-interface.version>0.7.0</bayernid-proxy-interface.version> <vorgang-manager.version>2.17.0</vorgang-manager.version> <muk-postfach.version>0.1.0</muk-postfach.version> - <osiv2-postfach.version>0.1.0-SNAPSHOT-OZG-4094</osiv2-postfach.version> + <osiv2-postfach.version>0.1.0-SNAPSHOT</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.version> </properties> diff --git a/pom.xml b/pom.xml index 57ea7de..c67418a 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ <groupId>de.ozgcloud.nachrichten</groupId> <artifactId>nachrichten-manager</artifactId> - <version>2.17.0-SNAPSHOT-OZG-4094</version> + <version>2.17.0-SNAPSHOT</version> <name>OZG-Cloud Nachrichten Manager</name> <packaging>pom</packaging> -- GitLab From 19832ebfa91dada8f77860ce59a1472fa423da7c Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Fri, 31 Jan 2025 09:42:00 +0100 Subject: [PATCH 11/16] OZG-4094 pom: Remove nexus repo --- pom.xml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/pom.xml b/pom.xml index c67418a..2a90ade 100644 --- a/pom.xml +++ b/pom.xml @@ -54,25 +54,4 @@ <module>nachrichten-manager-postfach-interface</module> </modules> - <profiles> - <profile> - <id>nexus-deploy</id> - <activation> - <activeByDefault>false</activeByDefault> - </activation> - <distributionManagement> - <repository> - <id>ozg-nexus</id> - <name>ozg-releases</name> - <url>https://nexus.ozg-sh.de/repository/ozg-releases/</url> - </repository> - <snapshotRepository> - <id>ozg-snapshots-nexus</id> - <name>ozg-snapshots</name> - <url>https://nexus.ozg-sh.de/repository/ozg-snapshots/</url> - </snapshotRepository> - </distributionManagement> - </profile> - </profiles> - </project> -- GitLab From 9af008a00b0771fa5b6e41fdd7697f786d71f004 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Fri, 31 Jan 2025 09:53:41 +0100 Subject: [PATCH 12/16] OZG-4094 osi2: Use new config key --- .../nachrichten/postfach/Osi2PostfachServiceITCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java index 516d16b..efe8e23 100644 --- a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java +++ b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java @@ -25,7 +25,7 @@ import de.ozgcloud.vorgang.callcontext.WithMockCustomUser; @SpringBootTest(classes = NachrichtenManagerTestApplication.class, properties = { - "ozgcloud.osiv2-postfach.enabled=true" + "ozgcloud.osiv2.enabled=true" }) @ActiveProfiles({ "itcase", "stage" }) class Osi2PostfachServiceITCase { -- GitLab From 3c2bbafc0f9dd4e8a5d1163bae1335b7b52b0a8d Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Tue, 4 Feb 2025 17:45:47 +0100 Subject: [PATCH 13/16] OZG-4094 osi2: Remove ITCases --- nachrichten-manager-server/pom.xml | 2 +- .../postfach/Osi2PostfachServiceITCase.java | 99 ------------------- .../postfach/OsiPostfachServiceITCase.java | 95 ------------------ 3 files changed, 1 insertion(+), 195 deletions(-) delete mode 100644 nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java delete mode 100644 nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 62b4aea..6bf7913 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -48,7 +48,7 @@ <bayernid-proxy-interface.version>0.7.0</bayernid-proxy-interface.version> <vorgang-manager.version>2.17.0</vorgang-manager.version> <muk-postfach.version>0.1.0</muk-postfach.version> - <osiv2-postfach.version>0.1.0-SNAPSHOT</osiv2-postfach.version> + <osiv2-postfach.version>0.1.0</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.version> </properties> diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java deleted file mode 100644 index efe8e23..0000000 --- a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/Osi2PostfachServiceITCase.java +++ /dev/null @@ -1,99 +0,0 @@ -package de.ozgcloud.nachrichten.postfach; - -import static org.assertj.core.api.Assertions.*; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.event.EventListener; -import org.springframework.stereotype.Component; -import org.springframework.test.context.ActiveProfiles; - -import de.ozgcloud.nachrichten.NachrichtenManagerTestApplication; -import de.ozgcloud.nachrichten.attributes.ClientAttributeService; -import de.ozgcloud.nachrichten.email.EmailGrpcService; -import de.ozgcloud.nachrichten.postfach.osiv2.config.Osi2PostfachProperties; -import de.ozgcloud.nachrichten.postfach.osiv2.transfer.PostfachApiFacadeService; -import de.ozgcloud.vorgang.callcontext.WithMockCustomUser; - -@SpringBootTest(classes = NachrichtenManagerTestApplication.class, - properties = { - "ozgcloud.osiv2.enabled=true" - }) -@ActiveProfiles({ "itcase", "stage" }) -class Osi2PostfachServiceITCase { - - @Autowired - private PostfachService postfachService; - - @Autowired - private Osi2PostfachProperties.ApiConfiguration osi2ApiConfiguration; - - @MockBean - private ApplicationEventPublisher publisher; - - @MockBean - private ClientAttributeService clientAttributeRemoteService; - - @MockBean - private PostfachApiFacadeService postfachApiFacadeService; - - @MockBean - private EmailGrpcService emailGrpcService; - - @Autowired - private OsiPostfachServiceITCase.SentEventTestListener sentEventTestListener; - - @BeforeEach - void mock() { - sentEventTestListener.reset(); - } - - @DisplayName("should use stage profile properties") - @Test - void shouldUseStageProfileProperties() { - var url = osi2ApiConfiguration.getUrl(); - - assertThat(url).isNotEmpty(); - } - - @DisplayName("should call osi2 postfach send") - @Test - @WithMockCustomUser - void shouldCallOsi2PostfachSend() { - var osiNachricht = PostfachNachrichtTestFactory.createBuilder() - .postfachAddress(PostfachAddressTestFactory.createBuilder() - .serviceKontoType("OSI") - .build() - ) - .build(); - var commandId = "aaaaa"; - - postfachService.sendMail(commandId, "userId", osiNachricht); - - assertThat(sentEventTestListener.events) - .extracting(PostfachMailSentEvent::getSource) - .containsExactly(commandId); - } - - @Component - static class SentEventTestListener { - final List<PostfachMailSentEvent> events = new ArrayList<>(); - - @EventListener - void onEvent(PostfachMailSentEvent event) { - events.add(event); - } - - void reset() { - events.clear(); - } - } -} diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java deleted file mode 100644 index d647dcc..0000000 --- a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/OsiPostfachServiceITCase.java +++ /dev/null @@ -1,95 +0,0 @@ -package de.ozgcloud.nachrichten.postfach; - -import static org.assertj.core.api.Assertions.*; -import static org.mockito.Mockito.*; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.event.EventListener; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.web.client.RestTemplate; - -import de.ozgcloud.nachrichten.NachrichtenManagerTestApplication; -import de.ozgcloud.nachrichten.attributes.ClientAttributeService; -import de.ozgcloud.nachrichten.email.EmailGrpcService; -import de.ozgcloud.nachrichten.postfach.osi.MessageAttachmentService; -import lombok.SneakyThrows; - -@SpringBootTest(classes = NachrichtenManagerTestApplication.class, - properties = { - "ozgcloud.osi.postfach.proxyapi.key=key", - "ozgcloud.osi.postfach.proxyapi.realm=realm", - "ozgcloud.osi.postfach.proxyapi.url=url", - }) -@ActiveProfiles({ "itcase" }) -class OsiPostfachServiceITCase { - - @Autowired - private PostfachService postfachService; - - @MockBean - private ClientAttributeService clientAttributeRemoteService; - - @MockBean - private MessageAttachmentService messageAttachmentService; - - @MockBean - private EmailGrpcService emailGrpcService; - - @MockBean - private RestTemplate restTemplate; - - @Autowired - private SentEventTestListener sentEventTestListener; - - @BeforeEach - void mock() { - sentEventTestListener.reset(); - } - - @DisplayName("should call osi postfach send") - @Test - @SneakyThrows - void shouldCallOsiPostfachSend() { - var osiNachricht = PostfachNachrichtTestFactory.createBuilder() - .postfachAddress(PostfachAddressTestFactory.createBuilder() - .serviceKontoType("OSI") - .build() - ) - .build(); - var commandId = "aaaaa"; - when(restTemplate.exchange(eq("url"), eq(HttpMethod.POST), any(), Mockito.<Class<String>>any())).thenReturn(ResponseEntity.ok("true")); - - postfachService.sendMail(commandId, "userId", osiNachricht); - - assertThat(sentEventTestListener.events) - .extracting(PostfachMailSentEvent::getSource) - .containsExactly(commandId); - } - - @Component - static class SentEventTestListener { - final List<PostfachMailSentEvent> events = new ArrayList<>(); - - @EventListener - void onEvent(PostfachMailSentEvent event) { - events.add(event); - } - - void reset() { - events.clear(); - } - } - -} -- GitLab From 14c8031b7de40a3b6709035bece0b384b93a5ac0 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Thu, 6 Feb 2025 10:10:21 +0100 Subject: [PATCH 14/16] OZG-4094 postfach-nachricht: Fix reading PostfachAddress --- .../postfach/PostfachNachrichtMapper.java | 4 +-- .../postfach/PostfachNachrichtMapperTest.java | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java b/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java index c521e7d..6ef2b4b 100644 --- a/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java +++ b/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java @@ -239,7 +239,7 @@ public abstract class PostfachNachrichtMapper { } private Map<String, Object> buildPostfachAddressIdentifierMap(PostfachAddress postfachAddress) { - var identifier = (StringBasedIdentifier) postfachAddress.getIdentifier(); - return Map.of(PostfachAddress.FIELD_POSTFACH_ID, identifier.getPostfachId()); + var identifier = postfachAddress.getIdentifier(); + return Map.of(PostfachAddress.FIELD_POSTFACH_ID, identifier.isStringBasedIdentifier() ? identifier.toString() : ""); } } \ No newline at end of file diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapperTest.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapperTest.java index 9e6c5c7..469309f 100644 --- a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapperTest.java +++ b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapperTest.java @@ -23,6 +23,7 @@ */ package de.ozgcloud.nachrichten.postfach; +import static de.ozgcloud.nachrichten.postfach.StringBasedIdentifierTestFactory.*; import static org.assertj.core.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; @@ -338,6 +339,40 @@ class PostfachNachrichtMapperTest { assertDoesNotThrow(() -> mapper.mapToMap(postfachMail)); } + @DisplayName("should map non string based identifier to empty") + @Test + + void shouldMapNonStringBasedIdentifierToEmpty() { + var postfachMail = PostfachNachrichtTestFactory.createBuilder() + .postfachAddress(PostfachAddressTestFactory.createBuilder() + .identifier(new PostfachAddressIdentifier() { + }) + .build() + ).build(); + + var postfachId = mapPostfachId(postfachMail); + + assertThat(postfachId).isEmpty(); + } + + @DisplayName("should map string based identifier") + @Test + void shouldMapStringBasedIdentifier() { + var postfachMail = PostfachNachrichtTestFactory.create(); + + var postfachId = mapPostfachId(postfachMail); + + assertThat(postfachId).isEqualTo(STRING_BASED_IDENTIFIER_POSTFACH_ID_VALUE); + } + + @SuppressWarnings("unchecked") + private String mapPostfachId(PostfachNachricht nachricht) { + var result = mapper.mapToMap(nachricht); + var postfachAddress = (Map<String, Object>) result.get(PostfachNachricht.POSTFACH_ADDRESS_FIELD); + var postfachIdentifier = (Map<String, Object>) postfachAddress.get(PostfachAddress.IDENTIFIER_FIELD); + return (String) postfachIdentifier.get(PostfachAddress.FIELD_POSTFACH_ID); + } + @Test void shouldProceedWithEmptyPostfachAddress() { var postfachMail = PostfachNachrichtTestFactory.createBuilder().postfachAddress(null).build(); -- GitLab From b997517bf7629920187db89fa415fbadc2720495 Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Thu, 6 Feb 2025 11:31:53 +0100 Subject: [PATCH 15/16] OZG-4094 Remove starter dependencies --- nachrichten-manager-server/pom.xml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/nachrichten-manager-server/pom.xml b/nachrichten-manager-server/pom.xml index 6bf7913..fa3c2b2 100644 --- a/nachrichten-manager-server/pom.xml +++ b/nachrichten-manager-server/pom.xml @@ -48,7 +48,7 @@ <bayernid-proxy-interface.version>0.7.0</bayernid-proxy-interface.version> <vorgang-manager.version>2.17.0</vorgang-manager.version> <muk-postfach.version>0.1.0</muk-postfach.version> - <osiv2-postfach.version>0.1.0</osiv2-postfach.version> + <osiv2-postfach.version>0.2.0</osiv2-postfach.version> <api-lib.version>0.16.0</api-lib.version> </properties> @@ -173,16 +173,6 @@ <artifactId>grpc-client-spring-boot-starter</artifactId> </dependency> - <!-- oauth for osiv2-postfach --> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-oauth2-client</artifactId> - </dependency> - <!-- commons --> <dependency> <groupId>org.apache.commons</groupId> -- GitLab From 4643643e335c62c511648d7a2c44c509510e5d5d Mon Sep 17 00:00:00 2001 From: Jan Zickermann <jan.zickermann@dataport.de> Date: Wed, 12 Feb 2025 11:06:57 +0100 Subject: [PATCH 16/16] OZG-4094 Throw exception for unexpected postfachIdentifier --- .../nachrichten/postfach/PostfachNachrichtMapper.java | 5 ++++- .../postfach/PostfachNachrichtMapperTest.java | 9 ++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java b/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java index 6ef2b4b..1fff1bd 100644 --- a/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java +++ b/nachrichten-manager-server/src/main/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapper.java @@ -240,6 +240,9 @@ public abstract class PostfachNachrichtMapper { private Map<String, Object> buildPostfachAddressIdentifierMap(PostfachAddress postfachAddress) { var identifier = postfachAddress.getIdentifier(); - return Map.of(PostfachAddress.FIELD_POSTFACH_ID, identifier.isStringBasedIdentifier() ? identifier.toString() : ""); + if (!identifier.isStringBasedIdentifier()) { + throw new IllegalStateException("Illegal Type of Postfach Identifier: " + identifier.getClass().getName()); + } + return Map.of(PostfachAddress.FIELD_POSTFACH_ID, identifier.toString()); } } \ No newline at end of file diff --git a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapperTest.java b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapperTest.java index 469309f..30a5d0b 100644 --- a/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapperTest.java +++ b/nachrichten-manager-server/src/test/java/de/ozgcloud/nachrichten/postfach/PostfachNachrichtMapperTest.java @@ -339,10 +339,9 @@ class PostfachNachrichtMapperTest { assertDoesNotThrow(() -> mapper.mapToMap(postfachMail)); } - @DisplayName("should map non string based identifier to empty") + @DisplayName("should throw if not string-based identifier") @Test - - void shouldMapNonStringBasedIdentifierToEmpty() { + void shouldThrowIfNotStringBasedIdentifier() { var postfachMail = PostfachNachrichtTestFactory.createBuilder() .postfachAddress(PostfachAddressTestFactory.createBuilder() .identifier(new PostfachAddressIdentifier() { @@ -350,9 +349,9 @@ class PostfachNachrichtMapperTest { .build() ).build(); - var postfachId = mapPostfachId(postfachMail); + assertThatThrownBy(() -> mapPostfachId(postfachMail)) + .isInstanceOf(IllegalStateException.class); - assertThat(postfachId).isEmpty(); } @DisplayName("should map string based identifier") -- GitLab