use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpPaymentsEndpointWrapperTest method fail_checkRequestAndConsentInitiationMatch.
@Test
public void fail_checkRequestAndConsentInitiationMatch() throws OBErrorException {
// Given
DomesticVrpPaymentsEndpointWrapper domesticVrpPaymentsEndpointWrapper = new DomesticVrpPaymentsEndpointWrapper(endpointWrapperService, tppStoreService, riskValidator);
// Create the request data
OBDomesticVRPInitiation requestInitiation = OBDomesticVRPCommonTestDataFactory.aValidOBDomesticVRPInitiation();
// Create an FR Consent with slightly differing initiation data
FRDomesticVRPConsent frConsent = FRVrpTestDataFactory.aValidFRDomesticVRPConsent();
FRWriteDomesticVRPDataInitiation differentInitiationData = (FRWriteDomesticVRPDataInitiation) FRDomesticVRPConverters.toFRDomesticVRPInitiation(requestInitiation);
differentInitiationData.getDebtorAccount().setIdentification("mismatched identification");
frConsent.getVrpDetails().getData().setInitiation(differentInitiationData);
// When
OBErrorException exception = catchThrowableOfType(() -> domesticVrpPaymentsEndpointWrapper.checkRequestAndConsentInitiationMatch(requestInitiation, frConsent), OBErrorException.class);
// Then
assertThat(exception.getObriErrorType()).isEqualTo(OBRIErrorType.REQUEST_VRP_INITIATION_DOESNT_MATCH_CONSENT);
assertThat(exception.getOBError().getErrorCode()).isEqualTo(OBStandardErrorCodes1.UK_OBIE_RESOURCE_CONSENT_MISMATCH.toString());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpPaymentsEndpointWrapperTest method fail_checkCreditorAccountIsInInstructionIfNotInConsent.
/**
* If the CreditorAccount was not specified in the consent, the CreditorAccount must be specified in the
* instruction.
*/
@Test
public void fail_checkCreditorAccountIsInInstructionIfNotInConsent() throws OBErrorException {
// Given
DomesticVrpPaymentsEndpointWrapper domesticVrpPaymentsEndpointWrapper = new DomesticVrpPaymentsEndpointWrapper(endpointWrapperService, tppStoreService, riskValidator);
// Create the request data
OBDomesticVRPRequest vrpRequest = OBDomesticVRPRequestTestDataFactory.aValidOBDomesticVRPRequest();
vrpRequest.getData().getInitiation().setCreditorAccount(null);
vrpRequest.getData().getInstruction().setCreditorAccount(null);
// Create an FR Consent with slightly differing initiation data
FRDomesticVRPConsent frConsent = FRVrpTestDataFactory.aValidFRDomesticVRPConsent();
frConsent.getVrpDetails().getData().getInitiation().setCreditorAccount(null);
// When
OBErrorException exception = catchThrowableOfType(() -> domesticVrpPaymentsEndpointWrapper.checkCreditorAccountIsInInstructionIfNotInConsent(vrpRequest, frConsent), OBErrorException.class);
// Then
assertThat(exception.getObriErrorType()).isEqualTo(OBRIErrorType.REQUEST_VRP_CREDITOR_ACCOUNT_NOT_SPECIFIED);
assertThat(exception.getOBError().getErrorCode()).isEqualTo(OBStandardErrorCodes1.UK_OBIE_RESOURCE_CONSENT_MISMATCH.toString());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class FRDomesticVRPConsentConverterTest method convertFRDomesticVRPConsentDetailsToOB.
@Test
public void convertFRDomesticVRPConsentDetailsToOB() {
// given
FRDomesticVRPConsent frDomesticVRPConsent = getFRDomesticVRPConsent();
OBDomesticVRPConsentRequest obDomesticVRPConsentRequest = toOBDomesticVRPConsentRequest(frDomesticVRPConsent.getVrpDetails());
// when
OBDomesticVRPConsentRequestData obData = obDomesticVRPConsentRequest.getData();
FRDomesticVRPConsentDetailsData frData = frDomesticVRPConsent.getVrpDetails().getData();
// then (check few fields)
assertThat(frData.getReadRefundAccount().getValue()).isEqualTo(obData.getReadRefundAccount().getValue());
assertThat(frData.getInitiation().getCreditorAccount().getIdentification()).isEqualTo(obData.getInitiation().getCreditorAccount().getIdentification());
assertThat(frData.getInitiation().getDebtorAccount().getIdentification()).isEqualTo(obData.getInitiation().getDebtorAccount().getIdentification());
assertThat(frData.getControlParameters().getVrpType().size()).isEqualTo(obData.getControlParameters().getVrPType().size());
assertThat(frData.getControlParameters().getPeriodicLimits().get(0).getPeriodType().getValue()).isEqualTo(obData.getControlParameters().getPeriodicLimits().get(0).getPeriodType().getValue());
assertThat(frData.getControlParameters().getPeriodicLimits().get(0).getPeriodAlignment().getValue()).isEqualTo(obData.getControlParameters().getPeriodicLimits().get(0).getPeriodAlignment().getValue());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpsApiController method domesticVrpPost.
@Override
public /**
* @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true)
* @RequestHeader(value = "Authorization", required = true) String authorization,
*
* @ApiParam(value = "A detached JWS signature of the body of the payload.", required = true)
* @RequestHeader(value = "x-jws-signature", required = true) String xJwsSignature,
*
* @ApiParam(value = "Default", required = true)
* @Valid
* @RequestBody OBDomesticVRPRequest obDomesticVRPRequest,
*
* @ApiParam(value = "The time when the PSU last logged in with the TPP. All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below: Sun, 10 Sep 2017 19:43:31 UTC")
* @RequestHeader(value = "x-fapi-auth-date", required = false) String xFapiAuthDate,
*
* @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.")
* @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress,
*
* @ApiParam(value = "An RFC4122 UID used as a correlation id.")
* @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId,
*
* @ApiParam(value = "Indicates the user-agent that the PSU is using.")
* @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent,
*/
ResponseEntity<OBDomesticVRPResponse> domesticVrpPost(String authorization, String xJwsSignature, OBDomesticVRPRequest obDomesticVRPRequest, String xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
log.debug("Received VRP payment submission: '{}'", obDomesticVRPRequest);
String consentId = obDomesticVRPRequest.getData().getConsentId();
FRDomesticVRPConsent frDomesticVRPConsent = domesticVRPConsentRepository.findById(consentId).orElseThrow(() -> new OBErrorResponseException(HttpStatus.BAD_REQUEST, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.PAYMENT_CONSENT_BEHIND_SUBMISSION_NOT_FOUND.toOBError1(consentId)));
log.debug("Found VRP consent '{}' to match this consent id: {} ", frDomesticVRPConsent, consentId);
FRDomesticVRPRequest frDomesticVRPRequest = toFRDomesticVRPRequest(obDomesticVRPRequest);
FRDomesticVrpPaymentSubmission vrpPaymentSubmission = FRDomesticVrpPaymentSubmission.builder().id(consentId).domesticVrpPayment(frDomesticVRPRequest).status(OBDomesticVRPResponseData.StatusEnum.PENDING).created(new Date()).updated(new Date()).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
vrpPaymentSubmission = new IdempotentRepositoryAdapter<>(paymentSubmissionRepository).idempotentSave(vrpPaymentSubmission);
return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(obDomesticVRPRequest, vrpPaymentSubmission, frDomesticVRPConsent));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpConsentsApiControllerIT method saveFRConsent.
private FRDomesticVRPConsent saveFRConsent(String consentId, FRReadRefundAccount frReadRefundAccount, ConsentStatusCode consentStatusCode) {
FRDomesticVRPConsentDetails details = toFRDomesticVRPConsentDetails(aValidOBDomesticVRPConsentRequest());
FRDomesticVRPConsent consent = JMockData.mock(FRDomesticVRPConsent.class);
consent.setVrpDetails(details);
consent.getVrpDetails().getData().setReadRefundAccount(frReadRefundAccount);
consent.getVrpDetails().getData().getInitiation().setDebtorAccount(aValidFRAccountIdentifier());
consent.setId(consentId);
consent.setIdempotencyKey(UUID.randomUUID().toString());
consent.setStatus(consentStatusCode);
consent.getRisk().setMerchantCategoryCode(aValidFRRisk().getMerchantCategoryCode());
consent.getRisk().setDeliveryAddress(aValidFRRisk().getDeliveryAddress());
consent.setObVersion(OBVersion.v3_1_8);
repository.save(consent);
return consent;
}
Aggregations