From dccb2646a18ba86c4dc61df93e4877817c2c97c8 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Wed, 30 Oct 2024 13:17:16 +0100 Subject: [PATCH] PINT: Minor tweaks discovered during a review session --- .../eblinterop/PintScenarioListBuilder.java | 2 ++ .../action/PintReceiverValidationAction.java | 9 +++++++++ ...ationEndpointScenarioParametersAction.java | 2 +- ...itionalDocumentUrlPathAndContentCheck.java | 2 +- .../eblinterop/party/PintSendingPlatform.java | 6 +++--- .../messages/pint-3.0.0-issuance-entry.json | 19 ------------------- 6 files changed, 16 insertions(+), 24 deletions(-) delete mode 100644 pint/src/main/resources/standards/pint/messages/pint-3.0.0-issuance-entry.json diff --git a/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/PintScenarioListBuilder.java b/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/PintScenarioListBuilder.java index 403827dc..ee58ccdc 100644 --- a/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/PintScenarioListBuilder.java +++ b/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/PintScenarioListBuilder.java @@ -27,6 +27,7 @@ class PintScenarioListBuilder extends ScenarioListBuilder createModuleScenarioListBuilders( String standardVersion, String sendingPlatformPartyName, String receivingPlatformPartyName) { @@ -146,6 +147,7 @@ private static PintScenarioListBuilder receiverValidation() { receivingPlatform, (PintAction) previousAction, 200, + resolveMessageSchemaValidator(RECEIVER_VALIDATION_REQUEST), resolveMessageSchemaValidator(RECEIVER_VALIDATION_RESPONSE) )); } diff --git a/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/action/PintReceiverValidationAction.java b/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/action/PintReceiverValidationAction.java index 5863c036..afb563af 100644 --- a/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/action/PintReceiverValidationAction.java +++ b/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/action/PintReceiverValidationAction.java @@ -11,6 +11,7 @@ @Getter @Slf4j public class PintReceiverValidationAction extends PintAction { + private final JsonSchemaValidator requestSchemaValidator; private final JsonSchemaValidator responseSchemaValidator; public PintReceiverValidationAction( @@ -18,6 +19,7 @@ public PintReceiverValidationAction( String targetPartyName, PintAction previousAction, int responseCode, + JsonSchemaValidator requestSchemaValidator, JsonSchemaValidator responseSchemaValidator ) { super( @@ -27,6 +29,7 @@ public PintReceiverValidationAction( "ReceiverValidation(%d)".formatted(responseCode), responseCode ); + this.requestSchemaValidator = requestSchemaValidator; this.responseSchemaValidator = responseSchemaValidator; } @@ -64,6 +67,12 @@ protected Stream createSubChecks() { getMatchedExchangeUuid(), HttpMessageType.RESPONSE, expectedApiVersion), + new JsonSchemaCheck( + PintRole::isSendingPlatform, + getMatchedExchangeUuid(), + HttpMessageType.REQUEST, + requestSchemaValidator + ), new JsonSchemaCheck( PintRole::isReceivingPlatform, getMatchedExchangeUuid(), diff --git a/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/action/SupplyValidationEndpointScenarioParametersAction.java b/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/action/SupplyValidationEndpointScenarioParametersAction.java index 9e57a7eb..6cd00d9c 100644 --- a/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/action/SupplyValidationEndpointScenarioParametersAction.java +++ b/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/action/SupplyValidationEndpointScenarioParametersAction.java @@ -31,7 +31,7 @@ public boolean isInputRequired() { @Override public void handlePartyInput(JsonNode partyInput) { super.handlePartyInput(partyInput); - setDsp(getDsp().withReceiverValidation(partyInput)); + setDsp(getDsp().withReceiverValidation(partyInput.path("input"))); } public static ObjectNode getJsonForPrompt() { diff --git a/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/checks/AdditionalDocumentUrlPathAndContentCheck.java b/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/checks/AdditionalDocumentUrlPathAndContentCheck.java index eeb12fdc..e3e49c70 100644 --- a/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/checks/AdditionalDocumentUrlPathAndContentCheck.java +++ b/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/checks/AdditionalDocumentUrlPathAndContentCheck.java @@ -31,7 +31,7 @@ public AdditionalDocumentUrlPathAndContentCheck( Supplier envelopeReferenceSupplier) { super( titlePrefix, - "The URL path of the HTTP request is correct", + "Validate document checksum (body and URL) of the HTTP request is correct", isRelevantForRoleName, matchedExchangeUuid, HttpMessageType.REQUEST); diff --git a/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/party/PintSendingPlatform.java b/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/party/PintSendingPlatform.java index b07c7d95..e81cad38 100644 --- a/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/party/PintSendingPlatform.java +++ b/pint/src/main/java/org/dcsa/conformance/standards/eblinterop/party/PintSendingPlatform.java @@ -192,7 +192,7 @@ private void retryTransfer(JsonNode actionPrompt) { } var body = OBJECT_MAPPER.createObjectNode(); - var tdPayload = loadTDR(tdr); + var tdPayload = loadTransportDocument(tdr); body.set("transportDocument", tdPayload); body.set("envelopeManifestSignedContent", sendingState.getSignedManifest()); body.set("envelopeTransferChain", sendingState.getSignedEnvelopeTransferChain()); @@ -214,7 +214,7 @@ private void retryTransfer(JsonNode actionPrompt) { "Re-sent an eBL with transportDocumentReference '%s' with type: %s".formatted(tdr, retryType.name())); } - private ObjectNode loadTDR(String tdr) { + private ObjectNode loadTransportDocument(String tdr) { var tdPayload = (ObjectNode) JsonToolkit.templateFileToJsonNode( "/standards/pint/messages/pint-%s-transport-document.json" @@ -295,7 +295,7 @@ private void initiateTransferRequest(JsonNode actionPrompt) { var body = OBJECT_MAPPER.createObjectNode(); - var tdPayload = loadTDR(tdr); + var tdPayload = loadTransportDocument(tdr); body.set("transportDocument", tdPayload); if (!isCorrect && tdPayload.path("transportDocument").has("issuingParty")) { ((ObjectNode) tdPayload.path("transportDocument")).remove("issuingParty"); diff --git a/pint/src/main/resources/standards/pint/messages/pint-3.0.0-issuance-entry.json b/pint/src/main/resources/standards/pint/messages/pint-3.0.0-issuance-entry.json deleted file mode 100644 index 07d2a5dd..00000000 --- a/pint/src/main/resources/standards/pint/messages/pint-3.0.0-issuance-entry.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "documentHash": "DOCUMENT_HASH", - "previousEndorsementChainEntryHash": null, - "transactions": [ - { - "timestamp": 1658385166302442200, - "platformHost": "https://exampleblplatform.net", - "actor": { - "eBLPlatformIdentifier": "test1234@exampleblplatform.net", - "partyName": "Some carrier" - }, - "recipient": { - "eBLPlatformIdentifier": "RECEIVER_PLATFORM_IDENTIFIER", - "partyName": "RECEIVER_LEGAL_NAME" - }, - "action": "ISSU" - } - ] -}