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

OZG-3371 implement BayernID Postfach remote service ITCase

Sub-task: OZG-3496
parent 621b0057
Branches
Tags
No related merge requests found
Showing
with 161 additions and 13 deletions
...@@ -4,6 +4,7 @@ import javax.xml.bind.JAXBElement; ...@@ -4,6 +4,7 @@ import javax.xml.bind.JAXBElement;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport; import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.xml.transform.StringResult; import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource; import org.springframework.xml.transform.StringSource;
...@@ -40,4 +41,9 @@ class BayernIdPostfachClient extends WebServiceGatewaySupport { ...@@ -40,4 +41,9 @@ class BayernIdPostfachClient extends WebServiceGatewaySupport {
return reply.getValue(); return reply.getValue();
} }
public WebServiceTemplate getWSTemplate() {
return this.getWebServiceTemplate();
}
} }
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
<testcontainer.version>1.17.3</testcontainer.version> <testcontainer.version>1.17.3</testcontainer.version>
<maven-deploy-plugin.version>3.0.0</maven-deploy-plugin.version> <maven-deploy-plugin.version>3.0.0</maven-deploy-plugin.version>
<spring-ws-test.version>2.0.2.RELEASE</spring-ws-test.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -256,6 +258,13 @@ ...@@ -256,6 +258,13 @@
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId> <artifactId>spring-security-test</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-test</artifactId>
<version>${spring-ws-test.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
......
...@@ -34,7 +34,9 @@ import java.time.temporal.ChronoUnit; ...@@ -34,7 +34,9 @@ import java.time.temporal.ChronoUnit;
import java.util.List; import java.util.List;
import org.assertj.core.api.Assertions; import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Captor; import org.mockito.Captor;
import org.mockito.Mock; import org.mockito.Mock;
...@@ -45,6 +47,7 @@ import org.springframework.data.mongodb.core.MongoOperations; ...@@ -45,6 +47,7 @@ import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser; import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.client.ExpectedCount; import org.springframework.test.web.client.ExpectedCount;
import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -65,6 +68,7 @@ import io.grpc.stub.StreamObserver; ...@@ -65,6 +68,7 @@ import io.grpc.stub.StreamObserver;
@SpringBootTest(classes = { PlutoServerApplication.class, OsiPostfachProperties.class }) @SpringBootTest(classes = { PlutoServerApplication.class, OsiPostfachProperties.class })
@DataITCase @DataITCase
@WithMockUser @WithMockUser
@ActiveProfiles({ "itcase", "with_db", "itcase-osi-postfach" })
class PostfachMailITCase { class PostfachMailITCase {
private static final String TEST_OSI_POSTFACH_URI = "http://localhost/ApiProxy/V1/Message"; private static final String TEST_OSI_POSTFACH_URI = "http://localhost/ApiProxy/V1/Message";
......
package de.itvsh.ozg.mail.postfach.bayernid;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.ws.test.client.RequestMatchers.*;
import static org.springframework.ws.test.client.ResponseCreators.*;
import java.io.IOException;
import java.util.Collections;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.io.Resource;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.ws.test.client.MockWebServiceServer;
import de.itvsh.kop.common.test.ITCase;
import de.itvsh.ozg.mail.postfach.PostfachAddressTestFactory;
import de.itvsh.ozg.mail.postfach.PostfachBadRequestException;
import de.itvsh.ozg.mail.postfach.PostfachNachrichtTestFactory;
import de.itvsh.ozg.mail.postfach.StringBasedIdentifier;
import de.itvsh.ozg.pluto.PlutoServerApplication;
import lombok.val;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = { PlutoServerApplication.class, BayernIdProperties.class })
@ITCase
@ActiveProfiles({ "itcase", "itcase-bayernid-postfach" })
class BayernIdPostfachServiceITCase {
@Autowired
private BayernIdPostfachRemoteService bayernIdPostfachRemoteService;
@Autowired
private BayernIdPostfachClient bayernIdPostfachClient;
@Value("classpath:bayernid/bsp-nachricht")
private Resource bspNachrichtNativeResource;
@Value("classpath:bayernid/bsp-quittung")
private Resource bspQuittungNativeResource;
@Value("classpath:bayernid/bsp-quittung-error-in-schema")
private Resource bspQuittungErrorNativeResource;
private MockWebServiceServer mockWebServiceServer;
@BeforeEach
void createMockWebServiceServer() {
mockWebServiceServer = MockWebServiceServer.createServer(bayernIdPostfachClient.getWSTemplate());
}
@Test
void shouldSendMessageSuccessfully() throws IOException {
mockWebServiceServer.expect(payload(bspNachrichtNativeResource)).andRespond(withPayload(bspQuittungNativeResource));
val nachricht = PostfachNachrichtTestFactory.createBuilder()
.vorgangId("1")
.postfachAddress(PostfachAddressTestFactory.createBuilder()
.type(PostfachAddressTestFactory.TYPE)
.version(PostfachAddressTestFactory.VERSION)
.identifier(StringBasedIdentifier.builder().postfachId("1").build())
.build())
.messageId("1")
.attachments(Collections.emptyList())
.build();
assertThatCode(() -> bayernIdPostfachRemoteService.sendMessage(nachricht)).doesNotThrowAnyException();
mockWebServiceServer.verify();
}
@Test
void shouldThrowPostfachBadRequestException() throws IOException {
mockWebServiceServer.expect(payload(bspNachrichtNativeResource)).andRespond(withPayload(bspQuittungErrorNativeResource));
val nachricht = PostfachNachrichtTestFactory.createBuilder()
.vorgangId("1")
.postfachAddress(PostfachAddressTestFactory.createBuilder()
.type(PostfachAddressTestFactory.TYPE)
.version(PostfachAddressTestFactory.VERSION)
.identifier(StringBasedIdentifier.builder().postfachId("1").build())
.build())
.messageId("1")
.attachments(Collections.emptyList())
.build();
assertThatThrownBy(() -> bayernIdPostfachRemoteService.sendMessage(nachricht)).isInstanceOf(PostfachBadRequestException.class);
mockWebServiceServer.verify();
}
}
...@@ -29,7 +29,9 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat ...@@ -29,7 +29,9 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
import java.util.Collections; import java.util.Collections;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
......
ozgcloud:
bayernid:
server: http://localhost
zertifikat:
keystore: classpath:bayernid.p12
password: SyPaRAxe97
absender:
postkorbId: 28721c6f-b78f-4d5c-a048-19fd2fc429d2
name: test name
anschrift: Niemalsgasse 5, 99999 Irgendwo Stadt
dienst: Stadtverwaltung
mandant: Fürth
gemeindeSchluessel: 09563000
\ No newline at end of file
kop:
osi:
postfach:
proxyapi:
url: http://localhost/ApiProxy/V1/Message
key: 1234
realm: test-realm
notification:
mail-from: test@local.host
...@@ -12,15 +12,5 @@ grpc: ...@@ -12,15 +12,5 @@ grpc:
aktenzeichen: de.itvsh.ozg.pluto.vorgang.AktenzeichenProviderEA aktenzeichen: de.itvsh.ozg.pluto.vorgang.AktenzeichenProviderEA
kop:
osi:
postfach:
proxyapi:
url: http://localhost/ApiProxy/V1/Message
key: 1234
realm: test-realm
notification:
mail-from: test@local.host
mongock: mongock:
enabled: false enabled: false
\ No newline at end of file
File added
<ns4:sendBspNachrichtNative xmlns:ns3="http://www.akdb.de/egov/bsp/nachrichten" xmlns:ns4="urn:akdb:bsp:postkorb:komm:webservice"><bspNachricht>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;&lt;ns2:BspNachricht xmlns:ns2="http://www.akdb.de/egov/bsp/nachrichten" xmlns:ns3="urn:akdb:bsp:postkorb:komm:webservice"&gt;&lt;ns2:NachrichtenKopf&gt;&lt;ns2:Identifikation.Nachricht&gt;&lt;ns2:Erstellungszeitpunkt&gt;2020-04-01T10:30:10.000Z&lt;/ns2:Erstellungszeitpunkt&gt;&lt;ns2:NachrichtenId&gt;1&lt;/ns2:NachrichtenId&gt;&lt;/ns2:Identifikation.Nachricht&gt;&lt;ns2:Absender&gt;&lt;ns2:Dienst&gt;Stadtverwaltung&lt;/ns2:Dienst&gt;&lt;ns2:Mandant&gt;Fürth&lt;/ns2:Mandant&gt;&lt;ns2:Gemeindeschluessel&gt;&lt;ns2:Tabelle&gt;36&lt;/ns2:Tabelle&gt;&lt;ns2:Schluessel&gt;09563000&lt;/ns2:Schluessel&gt;&lt;/ns2:Gemeindeschluessel&gt;&lt;/ns2:Absender&gt;&lt;ns2:Empfaenger&gt;&lt;ns2:PostkorbId&gt;1&lt;/ns2:PostkorbId&gt;&lt;/ns2:Empfaenger&gt;&lt;/ns2:NachrichtenKopf&gt;&lt;ns2:NachrichtenInhalt&gt;&lt;ns2:Betreff&gt;Test Subject&lt;/ns2:Betreff&gt;&lt;ns2:StorkQaaLevel&gt;LEVEL_1&lt;/ns2:StorkQaaLevel&gt;&lt;ns2:ZuVorgang&gt;&lt;ns2:VorgangsId&gt;1&lt;/ns2:VorgangsId&gt;&lt;/ns2:ZuVorgang&gt;&lt;ns2:FreiText&gt;&lt;ns2:Encoding&gt;&lt;ns2:Tabelle&gt;9004&lt;/ns2:Tabelle&gt;&lt;ns2:Schluessel&gt;text/plain&lt;/ns2:Schluessel&gt;&lt;/ns2:Encoding&gt;&lt;ns2:Text&gt;BodyString&lt;/ns2:Text&gt;&lt;/ns2:FreiText&gt;&lt;/ns2:NachrichtenInhalt&gt;&lt;/ns2:BspNachricht&gt;</bspNachricht></ns4:sendBspNachrichtNative>
\ No newline at end of file
<ns2:sendBspNachrichtNativeOutput xmlns:ns2="urn:akdb:bsp:postkorb:komm:webservice"><bspQuittung>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
&lt;BspQuittung version="1.5" fassung="2020-03-15" xmlns="http://www.akdb.de/egov/bsp/nachrichten"&gt;
&lt;AnnahmeErfolgreich&gt;true&lt;/AnnahmeErfolgreich&gt;
&lt;ErgebnisStatus&gt;
&lt;Tabelle&gt;9006&lt;/Tabelle&gt;
&lt;Schluessel&gt;0&lt;/Schluessel&gt;
&lt;/ErgebnisStatus&gt;
&lt;/BspQuittung&gt;
</bspQuittung></ns2:sendBspNachrichtNativeOutput>
\ No newline at end of file
<ns2:sendBspNachrichtNativeOutput xmlns:ns2="urn:akdb:bsp:postkorb:komm:webservice"><bspQuittung>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
&lt;BspQuittung version="1.5" fassung="2020-03-15" xmlns="http://www.akdb.de/egov/bsp/nachrichten"&gt;
&lt;AnnahmeErfolgreich&gt;false&lt;/AnnahmeErfolgreich&gt;
&lt;ErgebnisStatus&gt;
&lt;Tabelle&gt;9006&lt;/Tabelle&gt;
&lt;Schluessel&gt;20&lt;/Schluessel&gt;
&lt;/ErgebnisStatus&gt;
&lt;/BspQuittung&gt;
</bspQuittung></ns2:sendBspNachrichtNativeOutput>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment