aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/backend
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-22 13:02:19 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-22 13:02:19 +0200
commitcb9a76eaafd37f921006822bcfe043655288bc63 (patch)
tree76c2463e181ac293134f4c5bfc7e342607f3f399 /src/main/java/at/gv/egiz/moazs/backend
parentd873625c0ced62e712dc1b1a7570b63482fd0a0a (diff)
downloadmoa-zs-cb9a76eaafd37f921006822bcfe043655288bc63.tar.gz
moa-zs-cb9a76eaafd37f921006822bcfe043655288bc63.tar.bz2
moa-zs-cb9a76eaafd37f921006822bcfe043655288bc63.zip
Test Flow of DeliveryRequest from "End-To-End" & Fix Bugs
Schema Changes: - Remove mzs:DeliveryRequest/TnvzMetaData because all metadata fields can be collected from DeliveryRequest and redundancy is not needed. Fixes and Refactoring in preprocess: - MzsDeliveryRequestValidator: Instead of returning false, throw an exception when a condition is not met, and explain which condition is not met / why it is not met in the exception's message. - Integrate interface change in ConfigProfileGenerator and DeliveryRequestAugmenter. - Rewrite and simplify DeliveryRequestAugmenter's augmentation. - ConfigUtil Fixes: Ensure that we do not override the wrong parameters while merging. This error appeared in tnvz / msg client, connection / receive timeout, key / trust store, and lax hostname verification / trust all. Fix Bugs in Interceptor / SoapUtils: - Problem: DOM access and information extraction was implemented somewhat sloppy. - SolutioN: Change DOM access interface to access DOM more efficiently. Add boundary checks and handle edge cases while extracting information from SOAP Messages. - Test those changes properly. Testing: - Implement Delivery Request Flow in ITEndToEndTest. - Start application on random port instead of fixed port when running integration tests. - Add assertions to tests in ITMzsServiceTest suite. Others Bug Fixes: - ServicesConfig: Ensure that mzs service and msg service run on different endpoint addresses (/msg and /mzs). - DeliveryRequestBackend: Throw exception when binary message is missing. Don't wrap the exception. - SaveResponseToFileSink: Wrap Response in JAXB Element (otherwise, marshaller does not recognize it)
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/backend')
-rw-r--r--src/main/java/at/gv/egiz/moazs/backend/DeliveryRequestBackend.java13
-rw-r--r--src/main/java/at/gv/egiz/moazs/backend/SaveResponseToFileSink.java2
2 files changed, 8 insertions, 7 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/backend/DeliveryRequestBackend.java b/src/main/java/at/gv/egiz/moazs/backend/DeliveryRequestBackend.java
index 6a1e0fd..72f8ba0 100644
--- a/src/main/java/at/gv/egiz/moazs/backend/DeliveryRequestBackend.java
+++ b/src/main/java/at/gv/egiz/moazs/backend/DeliveryRequestBackend.java
@@ -18,10 +18,10 @@ import org.springframework.stereotype.Component;
import java.util.function.Consumer;
-import static at.gv.egiz.moazs.scheme.RequestStatusResponse.*;
+import static at.gv.egiz.moazs.MoaZSException.moaZSException;
import static at.gv.egiz.moazs.scheme.RequestStatusResponse.generateError;
+import static at.gv.egiz.moazs.scheme.RequestStatusResponse.getAnswer;
import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.Error.errorBuilder;
-import static at.gv.zustellung.msg.xsd.DeliveryRequestStatusType.deliveryRequestStatusTypeBuilder;
import static java.lang.String.format;
@Component
@@ -72,7 +72,7 @@ public class DeliveryRequestBackend implements Consumer<String> {
try {
var mzsRequest = repository.retrieveDeliveryRequest(appDeliveryID).orElseThrow(
- () -> MoaZSException.moaZSException(format(DELIVERY_REQUEST_MISSING_ERROR_MSG, appDeliveryID)));
+ () -> moaZSException(format(DELIVERY_REQUEST_MISSING_ERROR_MSG, appDeliveryID)));
fallbackAnswerBuilder.withDeliverySystem(mzsRequest.getConfig().getMSGClient().getURL());
var msgRequest = buildMsgRequest(mzsRequest);
@@ -98,14 +98,15 @@ public class DeliveryRequestBackend implements Consumer<String> {
}
private void verifySignedStatus(String responseID, String appDeliveryID) throws MoaZSException {
+ var signedStatus = repository.retrieveBinaryResponse(responseID).orElseThrow(() -> moaZSException(
+ format(BINARY_RESPONSE_MISSING_ERROR_MSG, responseID),
+ MoaZSException.ERROR_MZS_BINARY_RESPONSE_MISSING));
try {
- var signedStatus = repository.retrieveBinaryResponse(responseID).orElseThrow(
- () -> MoaZSException.moaZSException(format(BINARY_RESPONSE_MISSING_ERROR_MSG, responseID)));
signatureVerifier.accept(signedStatus);
} catch (MoaZSException ex) {
var message = format(MsgResponseBackend.MOASP_SIGNATURE_INVALID_ERROR_MSG, appDeliveryID);
var code = MoaZSException.ERROR_MOASP_SIGNATURE_INVALID;
- throw MoaZSException.moaZSException(message, code, ex);
+ throw moaZSException(message, code, ex);
}
}
diff --git a/src/main/java/at/gv/egiz/moazs/backend/SaveResponseToFileSink.java b/src/main/java/at/gv/egiz/moazs/backend/SaveResponseToFileSink.java
index 2468ca9..c58e1a5 100644
--- a/src/main/java/at/gv/egiz/moazs/backend/SaveResponseToFileSink.java
+++ b/src/main/java/at/gv/egiz/moazs/backend/SaveResponseToFileSink.java
@@ -50,7 +50,7 @@ public class SaveResponseToFileSink {
var responseID = response.getResponseID();
var responsePath = generatePath(rootPath, responseID, "xml");
- var storeResponseToFileSystemFuture = supplyAsync(() -> msgMarshaller.marshallXml(response.getResponse()))
+ var storeResponseToFileSystemFuture = supplyAsync(() -> msgMarshaller.marshallXml(response.getResponseAsJAXBElement()))
.thenApply(responseString -> responseString.getBytes(StandardCharsets.UTF_8))
.thenAccept(responseByteArray -> storeToFile(responsePath, responseByteArray))
.exceptionally(ex -> logException(ex, responseID));