use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpPaymentsEndpointWrapperTest method success_checkRequestAndConsentInitiationMatch.
@Test
public void success_checkRequestAndConsentInitiationMatch() throws OBErrorException {
// Given
DomesticVrpPaymentsEndpointWrapper domesticVrpPaymentsEndpointWrapper = new DomesticVrpPaymentsEndpointWrapper(endpointWrapperService, tppStoreService, riskValidator);
OBDomesticVRPInitiation requestInitiation = OBDomesticVRPCommonTestDataFactory.aValidOBDomesticVRPInitiation();
FRDomesticVRPConsent frConsent = FRVrpTestDataFactory.aValidFRDomesticVRPConsent();
FRWriteDomesticVRPDataInitiation matchingInitiation = (FRWriteDomesticVRPDataInitiation) FRDomesticVRPConverters.toFRDomesticVRPInitiation(requestInitiation);
frConsent.getVrpDetails().getData().setInitiation(matchingInitiation);
// When
domesticVrpPaymentsEndpointWrapper.checkRequestAndConsentInitiationMatch(requestInitiation, frConsent);
// Then
// If no exception then we're good!
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpPaymentsEndpointWrapperTest method success_checkCreditorAccountIsInInstructionIfNotInConsent.
/**
* If the CreditorAccount was not specified in the consent, the CreditorAccount must be specified in the
* instruction.
*/
@Test
public void success_checkCreditorAccountIsInInstructionIfNotInConsent() throws OBErrorException {
// Given
DomesticVrpPaymentsEndpointWrapper domesticVrpPaymentsEndpointWrapper = new DomesticVrpPaymentsEndpointWrapper(endpointWrapperService, tppStoreService, riskValidator);
// Create the request data
OBDomesticVRPRequest vrpRequest = OBDomesticVRPRequestTestDataFactory.aValidOBDomesticVRPRequest();
// Create an FR Consent with slightly differing initiation data
FRDomesticVRPConsent frConsent = FRVrpTestDataFactory.aValidFRDomesticVRPConsent();
frConsent.getVrpDetails().getData().getInitiation().setCreditorAccount(null);
// When
domesticVrpPaymentsEndpointWrapper.checkCreditorAccountIsInInstructionIfNotInConsent(vrpRequest, frConsent);
// Then
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpPaymentsEndpointWrapperTest method success_validateRisk.
@Test
public void success_validateRisk() throws OBErrorException {
// Given
DomesticVrpPaymentsEndpointWrapper domesticVrpPaymentsEndpointWrapper = new DomesticVrpPaymentsEndpointWrapper(endpointWrapperService, tppStoreService, riskValidator);
OBDomesticVRPRequest vrpRequest = OBDomesticVRPRequestTestDataFactory.aValidOBDomesticVRPRequest();
FRDomesticVRPConsent vrpConsent = FRVrpTestDataFactory.aValidFRDomesticVRPConsent();
vrpRequest.setRisk(toOBRisk1(vrpConsent.getRisk()));
// When
domesticVrpPaymentsEndpointWrapper.checkRequestAndConsentRiskMatch(vrpRequest, vrpConsent);
// Then
// If no exception then we're good
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpPaymentsEndpointWrapperTest method fail_validateRisk.
@Test
public void fail_validateRisk() throws OBErrorException {
// Given
DomesticVrpPaymentsEndpointWrapper domesticVrpPaymentsEndpointWrapper = new DomesticVrpPaymentsEndpointWrapper(endpointWrapperService, tppStoreService, riskValidator);
OBDomesticVRPRequest vrpRequest = OBDomesticVRPRequestTestDataFactory.aValidOBDomesticVRPRequest();
FRDomesticVRPConsent vrpConsent = FRVrpTestDataFactory.aValidFRDomesticVRPConsent();
vrpRequest.setRisk(toOBRisk1(vrpConsent.getRisk()));
vrpRequest.getRisk().setMerchantCategoryCode("mismatched Merchange Category Code");
// When
OBErrorException exception = catchThrowableOfType(() -> domesticVrpPaymentsEndpointWrapper.checkRequestAndConsentRiskMatch(vrpRequest, vrpConsent), OBErrorException.class);
// Then
assertThat(exception.getObriErrorType()).isEqualTo(OBRIErrorType.REQUEST_VRP_RISK_DOESNT_MATCH_CONSENT);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpsApiControllerIT method createVrpPaymentInitiationNotMatch.
@Test
public void createVrpPaymentInitiationNotMatch() throws Exception {
// Given
String jws = jws("payments", OIDCConstants.GrantType.AUTHORIZATION_CODE);
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
given(amResourceServerService.verifyAccessToken("Bearer " + jws)).willReturn(SignedJWT.parse(jws));
FRDomesticVRPConsent frDomesticVRPConsent = aValidFRDomesticVRPConsent(IntentType.DOMESTIC_VRP_PAYMENT_CONSENT.generateIntentId(), ConsentStatusCode.AUTHORISED);
OBDomesticVRPConsentResponse consentResponse = FRDomesticVRPConsentConverter.toOBDomesticVRPConsentResponse(frDomesticVRPConsent);
OBDomesticVRPRequest request = buildAValidOBDomesticVRPRequest(consentResponse);
request.getData().setInitiation(new OBDomesticVRPInitiation());
given(vrpPaymentConsentService.getVrpPaymentConsent(request.getData().getConsentId())).willReturn(frDomesticVRPConsent);
// When
HttpResponse<ResponseEntity> response = Unirest.post(HOST + port + VRP_CONTXT_PATH).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.X_IDEMPOTENCY_KEY, IDEMPOTENCY_KEY).header(OBHeaders.X_JWS_SIGNATURE, jws).header(OBHeaders.AUTHORIZATION, "Bearer " + jws).header(OBHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.getMimeType()).body(request).asObject(ResponseEntity.class);
// Then
assertThat(response).isNotNull();
assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST.value());
assertThat(response.getParsingError().get().getOriginalBody()).contains("{\"ErrorCode\":\"UK.OBIE.Resource.ConsentMismatch\"");
assertThat(response.getParsingError().get().getOriginalBody()).contains("The provided initiation data differs from that in the matching consent");
}
Aggregations