diff options
author | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-05-09 16:12:08 +0200 |
---|---|---|
committer | Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at> | 2019-05-09 16:15:45 +0200 |
commit | a95679d191c2ac9cd4d61a5848240163e1676495 (patch) | |
tree | 57baff67ff870e1130f75027bc097d5c6de4307b | |
parent | f27ff5780d98e747742140c526fb1e3469bb5748 (diff) | |
download | moa-zs-a95679d191c2ac9cd4d61a5848240163e1676495.tar.gz moa-zs-a95679d191c2ac9cd4d61a5848240163e1676495.tar.bz2 moa-zs-a95679d191c2ac9cd4d61a5848240163e1676495.zip |
Reactivate and Fix Unit Tests
- Relax Validation for now by only validating incoming requests.
4 files changed, 117 insertions, 87 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/App2MzsService.java b/src/main/java/at/gv/egiz/moazs/App2MzsService.java index 090bad3..6c59f85 100644 --- a/src/main/java/at/gv/egiz/moazs/App2MzsService.java +++ b/src/main/java/at/gv/egiz/moazs/App2MzsService.java @@ -22,7 +22,7 @@ import static java.text.MessageFormat.format; import static java.util.concurrent.CompletableFuture.supplyAsync; @Service -@SchemaValidation +@SchemaValidation(type = SchemaValidation.SchemaValidationType.IN) public class App2MzsService implements App2MzsPortType { private static final Logger logger = LoggerFactory.getLogger(App2MzsService.class); diff --git a/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java b/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java index f13a4dd..2924bf2 100644 --- a/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java +++ b/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java @@ -2,6 +2,7 @@ package at.gv.egiz.moazs; import at.gv.egiz.moazs.pipeline.DeliveryPipeline; import at.gv.egiz.moazs.repository.DeliveryRepository; +import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType; import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.DeliveryRequestStatusTypeBuilder; import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.Success.SuccessBuilder; import org.junit.Test; @@ -16,13 +17,19 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Primary; import org.springframework.test.context.junit4.SpringRunner; +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.nio.file.Paths; +import java.util.GregorianCalendar; +import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.Success.successBuilder; +import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.deliveryRequestStatusTypeBuilder; import static java.net.http.HttpClient.Version; import static org.junit.Assert.assertEquals; @@ -48,17 +55,29 @@ public class App2MzsServiceTest { public DeliveryPipeline deliveryPipelineThatAlwaysSucceeds() { return appDeliveryId -> { - var success = new SuccessBuilder() + var success = successBuilder() + .withDeliverySystem("Test Delivery System") + .withZSDeliveryID("ZD-Delivery-ID") .withAppDeliveryID(appDeliveryId) + .withDeliveryTimestamp(genTimeStamp()) .build(); - var status = new DeliveryRequestStatusTypeBuilder() + var status = deliveryRequestStatusTypeBuilder() .withSuccess(success) .build(); repository.add(status); }; } + + private XMLGregorianCalendar genTimeStamp() { + try { + return DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()); + } catch (DatatypeConfigurationException e) { + throw new RuntimeException("ups"); + } + + } } @Test @@ -79,23 +98,23 @@ public class App2MzsServiceTest { assertEquals(500, response.statusCode()); } -// @Test -// public void rejectFormallyIncorrectDeliveryRequest() throws IOException, InterruptedException { -// var response = sendDeliveryRequestFile("formallyIncorrectDeliveryRequest.soap"); -// assertEquals(500, response.statusCode()); -// } -// -// @Test -// public void rejectRequestWithoutAppDeliveryID() throws IOException, InterruptedException { -// var response = sendDeliveryRequestFile("missingAppDeliveryId.soap"); -// assertEquals(500, response.statusCode()); -// } -// -// @Test -// public void rejectRequestWithoutMetaData() throws IOException, InterruptedException { -// var response = sendDeliveryRequestFile("missingMetaData.soap"); -// assertEquals(500, response.statusCode()); -// } + @Test + public void rejectFormallyIncorrectDeliveryRequest() throws IOException, InterruptedException { + var response = sendDeliveryRequestFile("formallyIncorrectDeliveryRequest.soap"); + assertEquals(500, response.statusCode()); + } + + @Test + public void rejectRequestWithoutAppDeliveryID() throws IOException, InterruptedException { + var response = sendDeliveryRequestFile("missingAppDeliveryId.soap"); + assertEquals(500, response.statusCode()); + } + + @Test + public void rejectRequestWithoutMetaData() throws IOException, InterruptedException { + var response = sendDeliveryRequestFile("missingMetaData.soap"); + assertEquals(500, response.statusCode()); + } private HttpResponse<String> sendDeliveryRequestFile(String fileName) throws IOException, InterruptedException { diff --git a/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/missingAppDeliveryId.soap b/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/missingAppDeliveryId.soap index e981b31..e481caa 100644 --- a/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/missingAppDeliveryId.soap +++ b/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/missingAppDeliveryId.soap @@ -9,40 +9,47 @@ <soapenv:Body> <mzs:DeliveryRequest> <mzs:Sender> - <p:CorporateBody> - <p:FullName>Bundesministerium für Testzwecke</p:FullName> - </p:CorporateBody> - <mzs:WebserviceURL>https://authority.gv.at/delivery_notification</mzs:WebserviceURL> - </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> - <msg:MetaData /> - <mzs:Payload> - <mzs:DocumentReference>https://authority.gv.at/files/73bdf969781ba41fa07df1ff8439cf685c0db1c3</mzs:DocumentReference> - <mzs:FileName>brief.xml</mzs:FileName> - <mzs:MIMEType>text/xml</mzs:MIMEType> - <msg:CheckSum> - <msg:AlgorithmID>SHA1</msg:AlgorithmID> - <msg:Value>9b972c70fdaf5e1b26b3387c87b0ffb72e5940b6</msg:Value> - </msg:CheckSum> - <mzs:Size>123401</mzs:Size> - </mzs:Payload> + <p:CorporateBody> + <p:Identification> + <p:Value>kkvj693+tw99uW8UPuEK9en1LzZItkylPajkUUyJJDWQB78VGPkAuhCEk+TD12yQDD/WRglsf+JfQpjubIs/4l/ptluJ9teF3nwkNlu5Dm7mIjzgW1qxrDyomCmPvVxTWOCBuMUbOWRZBhOq+KvDQAu9Vv9KnqSfjYeDZrpHYu4=</p:Value> + <p:Type>urn:publicid:gv:at:cemtoken</p:Type> + </p:Identification> + <p:FullName>Bundesministerium für Testzwecke</p:FullName> + </p:CorporateBody> + <mzs:WebserviceURL>https://authority.gv.at/delivery_notification</mzs:WebserviceURL> + </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> + <msg:MetaData> + <msg:Subject>WichtigeMitteilung</msg:Subject> + <msg:DeliveryQuality>RSa</msg:DeliveryQuality> + </msg:MetaData> + <mzs:Payload> + <mzs:DocumentReference>https://authority.gv.at/files/73bdf969781ba41fa07df1ff8439cf685c0db1c3</mzs:DocumentReference> + <mzs:FileName>brief.xml</mzs:FileName> + <mzs:MIMEType>text/xml</mzs:MIMEType> + <msg:CheckSum> + <msg:AlgorithmID>SHA1</msg:AlgorithmID> + <msg:Value>9b972c70fdaf5e1b26b3387c87b0ffb72e5940b6</msg:Value> + </msg:CheckSum> + <mzs:Size>123401</mzs:Size> + </mzs:Payload> </mzs:DeliveryRequest> </soapenv:Body> </soapenv:Envelope> diff --git a/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/missingMetaData.soap b/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/missingMetaData.soap index 4a1e02d..cf55d6d 100644 --- a/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/missingMetaData.soap +++ b/src/test/resources/at/gv/egiz/moazs/App2MzsServiceTest/missingMetaData.soap @@ -9,39 +9,43 @@ <soapenv:Body> <mzs:DeliveryRequest> <mzs:Sender> - <p:CorporateBody> - <p:FullName>Bundesministerium für Testzwecke</p:FullName> - </p:CorporateBody> - <mzs:WebserviceURL>https://authority.gv.at/delivery_notification</mzs:WebserviceURL> - </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:Payload> - <mzs:DocumentReference>https://authority.gv.at/files/73bdf969781ba41fa07df1ff8439cf685c0db1c3</mzs:DocumentReference> - <mzs:FileName>brief.xml</mzs:FileName> - <mzs:MIMEType>text/xml</mzs:MIMEType> - <msg:CheckSum> - <msg:AlgorithmID>SHA1</msg:AlgorithmID> - <msg:Value>9b972c70fdaf5e1b26b3387c87b0ffb72e5940b6</msg:Value> - </msg:CheckSum> - <mzs:Size>123401</mzs:Size> - </mzs:Payload> + <p:CorporateBody> + <p:Identification> + <p:Value>kkvj693+tw99uW8UPuEK9en1LzZItkylPajkUUyJJDWQB78VGPkAuhCEk+TD12yQDD/WRglsf+JfQpjubIs/4l/ptluJ9teF3nwkNlu5Dm7mIjzgW1qxrDyomCmPvVxTWOCBuMUbOWRZBhOq+KvDQAu9Vv9KnqSfjYeDZrpHYu4=</p:Value> + <p:Type>urn:publicid:gv:at:cemtoken</p:Type> + </p:Identification> + <p:FullName>Bundesministerium für Testzwecke</p:FullName> + </p:CorporateBody> + <mzs:WebserviceURL>https://authority.gv.at/delivery_notification</mzs:WebserviceURL> + </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:Payload> + <mzs:DocumentReference>https://authority.gv.at/files/73bdf969781ba41fa07df1ff8439cf685c0db1c3</mzs:DocumentReference> + <mzs:FileName>brief.xml</mzs:FileName> + <mzs:MIMEType>text/xml</mzs:MIMEType> + <msg:CheckSum> + <msg:AlgorithmID>SHA1</msg:AlgorithmID> + <msg:Value>9b972c70fdaf5e1b26b3387c87b0ffb72e5940b6</msg:Value> + </msg:CheckSum> + <mzs:Size>123401</mzs:Size> + </mzs:Payload> </mzs:DeliveryRequest> </soapenv:Body> </soapenv:Envelope> |