aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java29
-rw-r--r--src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/formallyIncorrectDeliveryRequest.soap52
-rw-r--r--src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/validDeliveryRequest.soap (renamed from src/test/resources/delivery_request_app2mzs.soap)0
3 files changed, 79 insertions, 2 deletions
diff --git a/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java b/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java
index 836bfab..5879fa2 100644
--- a/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java
+++ b/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java
@@ -16,6 +16,7 @@ import java.net.http.HttpResponse;
import java.nio.file.Paths;
import static java.net.http.HttpClient.*;
+import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@@ -24,12 +25,14 @@ public class App2MzsServiceTest {
private final String serviceUri = "http://localhost:8080/services/DeliveryRequest";
- private final String payloadFile = "src/test/resources/delivery_request_app2mzs.soap";
+ private final String basePath = "src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/";
Logger logger = LoggerFactory.getLogger(App2MzsServiceTest.class);
@Test
- public void testService() throws IOException, InterruptedException {
+ public void acceptValidDeliveryRequest() throws IOException, InterruptedException {
+
+ final String payloadFile = basePath + "validDeliveryRequest.soap";
var client = HttpClient.newBuilder().version(Version.HTTP_1_1).build();
var request = HttpRequest.newBuilder()
@@ -42,5 +45,27 @@ public class App2MzsServiceTest {
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
logger.info("response.body was " + response.body());
logger.info("response.code was " + response.statusCode());
+
+ //TODO Verify response
+
+ }
+
+ @Test
+ public void rejectFormallyIncorrectDeliveryRequest() throws IOException, InterruptedException {
+
+ var invalidDeliveryRequest = basePath + "formallyIncorrectDeliveryRequest.soap";
+
+ var client = HttpClient.newBuilder().version(Version.HTTP_1_1).build();
+ var request = HttpRequest.newBuilder()
+ .uri(URI.create(serviceUri))
+ .header("Content-Type", "text/xml;charset=UTF-8")
+ .header("SOAPAction", "\"\"")
+ .POST(HttpRequest.BodyPublishers.ofFile(Paths.get(invalidDeliveryRequest)))
+ .build();
+
+ var response = client.send(request, HttpResponse.BodyHandlers.ofString());
+ assertThat(response.statusCode()).isEqualTo(500);
+
}
+
}
diff --git a/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/formallyIncorrectDeliveryRequest.soap b/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/formallyIncorrectDeliveryRequest.soap
new file mode 100644
index 0000000..bf38ab1
--- /dev/null
+++ b/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/formallyIncorrectDeliveryRequest.soap
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<soapenv:Envelope
+ xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:mzs="http://reference.e-government.gv.at/namespace/moazs10/app2mzs#"
+ xmlns:p="http://reference.e-government.gv.at/namespace/persondata/20020228#"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<soapenv:Body>
+<mzs:DeliveryRequest>
+ <mzs:Sender>
+ <mzs:ProfileID>SampleProfile2</mzs:ProfileID>
+ <mzs:SignatureKeyID></mzs:SignatureKeyID>
+ </mzs:Sender>
+ <mzs:Receiver>
+ <p:PhysicalPerson>
+ <p:Name>
+ <p:GivenName>Maxi</p:GivenName>
+ <p:FamilyName>Mustermann1</p:FamilyName>
+ </p:Name>
+ <p:DateOfBirth>1984-01-24</p:DateOfBirth>
+ </p:PhysicalPerson>
+ <p:PostalAddress>
+ <p:CountryCode>AT</p:CountryCode>
+ <p:PostalCode>1010</p:PostalCode>
+ <p:Municipality>Wien</p:Municipality>
+ <p:DeliveryAddress>
+ <p:StreetName>Muststrasse</p:StreetName>
+ <p:BuildingNumber>10</p:BuildingNumber>
+ </p:DeliveryAddress>
+ </p:PostalAddress>
+ </mzs:Receiver>
+ <mzs:MetaData>
+ <mzs:AppDeliveryID>asd</mzs:AppDeliveryID>
+ <mzs:DeliveryQuality>nonRSa</mzs:DeliveryQuality>
+ <mzs:RequiresEncryption>false</mzs:RequiresEncryption>
+ </mzs:MetaData>
+ <mzs:XMLDocument>
+ <mzs:XMLContent>
+ <message>
+ <subject>Hello There!</subject>
+ <body>
+ <p>How are you</p>
+ <p>Nice to hear from you!</p>
+ <p>Regards, V</p>
+ </body>
+ </message>
+ </mzs:XMLContent>
+ <mzs:XMLProfileID>deckblatt</mzs:XMLProfileID>
+ </mzs:XMLDocument>
+</mzs:DeliveryRequest?>
+</soapenv:Body>
+</soapenv:Envelope>
diff --git a/src/test/resources/delivery_request_app2mzs.soap b/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/validDeliveryRequest.soap
index 662a161..662a161 100644
--- a/src/test/resources/delivery_request_app2mzs.soap
+++ b/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/validDeliveryRequest.soap