Skip to content

Commit

Permalink
PINT: Minor tweaks discovered during a review session
Browse files Browse the repository at this point in the history
  • Loading branch information
nt-gt committed Oct 30, 2024
1 parent fbf9b18 commit dccb264
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PintScenarioListBuilder extends ScenarioListBuilder<PintScenarioListBuilde
private static final String ENVELOPE_TRANSFER_CHAIN_ENTRY_SCHEMA = "EnvelopeTransferChainEntry";
private static final String ISSUANCE_MANIFEST_SCHEMA = "IssuanceManifest";
private static final String RECEIVER_VALIDATION_RESPONSE = "ReceiverValidationResponse";
private static final String RECEIVER_VALIDATION_REQUEST = "IdentifyingCode";

public static LinkedHashMap<String, PintScenarioListBuilder> createModuleScenarioListBuilders(
String standardVersion, String sendingPlatformPartyName, String receivingPlatformPartyName) {
Expand Down Expand Up @@ -146,6 +147,7 @@ private static PintScenarioListBuilder receiverValidation() {
receivingPlatform,
(PintAction) previousAction,
200,
resolveMessageSchemaValidator(RECEIVER_VALIDATION_REQUEST),
resolveMessageSchemaValidator(RECEIVER_VALIDATION_RESPONSE)
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
@Getter
@Slf4j
public class PintReceiverValidationAction extends PintAction {
private final JsonSchemaValidator requestSchemaValidator;
private final JsonSchemaValidator responseSchemaValidator;

public PintReceiverValidationAction(
String sourcePartyName,
String targetPartyName,
PintAction previousAction,
int responseCode,
JsonSchemaValidator requestSchemaValidator,
JsonSchemaValidator responseSchemaValidator
) {
super(
Expand All @@ -27,6 +29,7 @@ public PintReceiverValidationAction(
"ReceiverValidation(%d)".formatted(responseCode),
responseCode
);
this.requestSchemaValidator = requestSchemaValidator;
this.responseSchemaValidator = responseSchemaValidator;
}

Expand Down Expand Up @@ -64,6 +67,12 @@ protected Stream<? extends ConformanceCheck> createSubChecks() {
getMatchedExchangeUuid(),
HttpMessageType.RESPONSE,
expectedApiVersion),
new JsonSchemaCheck(
PintRole::isSendingPlatform,
getMatchedExchangeUuid(),
HttpMessageType.REQUEST,
requestSchemaValidator
),
new JsonSchemaCheck(
PintRole::isReceivingPlatform,
getMatchedExchangeUuid(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AdditionalDocumentUrlPathAndContentCheck(
Supplier<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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"
Expand Down Expand Up @@ -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");
Expand Down

This file was deleted.

0 comments on commit dccb264

Please sign in to comment.