Search in sources :

Example 1 with FRDomesticVRPConsent

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!
}
Also used : OBDomesticVRPInitiation(uk.org.openbanking.datamodel.vrp.OBDomesticVRPInitiation) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) FRWriteDomesticVRPDataInitiation(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRWriteDomesticVRPDataInitiation) Test(org.junit.Test)

Example 2 with FRDomesticVRPConsent

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
}
Also used : OBDomesticVRPRequest(uk.org.openbanking.datamodel.vrp.OBDomesticVRPRequest) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) Test(org.junit.Test)

Example 3 with FRDomesticVRPConsent

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
}
Also used : OBDomesticVRPRequest(uk.org.openbanking.datamodel.vrp.OBDomesticVRPRequest) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) Test(org.junit.Test)

Example 4 with FRDomesticVRPConsent

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);
}
Also used : OBDomesticVRPRequest(uk.org.openbanking.datamodel.vrp.OBDomesticVRPRequest) OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) Test(org.junit.Test)

Example 5 with FRDomesticVRPConsent

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");
}
Also used : OBDomesticVRPRequestTestDataFactory.aValidOBDomesticVRPRequest(uk.org.openbanking.testsupport.vrp.OBDomesticVRPRequestTestDataFactory.aValidOBDomesticVRPRequest) ResponseEntity(org.springframework.http.ResponseEntity) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test)

Aggregations

FRDomesticVRPConsent (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent)28 Test (org.junit.Test)20 SpringSecForTest (com.forgerock.openbanking.integration.test.support.SpringSecForTest)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 ResponseEntity (org.springframework.http.ResponseEntity)6 OBDomesticVRPRequestTestDataFactory.aValidOBDomesticVRPRequest (uk.org.openbanking.testsupport.vrp.OBDomesticVRPRequestTestDataFactory.aValidOBDomesticVRPRequest)6 FRDomesticVRPConsentDetails (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsentDetails)5 FRDomesticVRPConsentConverter.toFRDomesticVRPConsentDetails (com.forgerock.openbanking.common.services.openbanking.converter.vrp.FRDomesticVRPConsentConverter.toFRDomesticVRPConsentDetails)5 Tpp (com.forgerock.openbanking.model.Tpp)4 OBDomesticVRPRequest (uk.org.openbanking.datamodel.vrp.OBDomesticVRPRequest)4 FRDomesticVrpPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVrpPaymentSubmission)3 OBErrorException (com.forgerock.openbanking.exceptions.OBErrorException)3 OBVRPFundsConfirmationRequestTestDataFactory.aValidOBVRPFundsConfirmationRequest (uk.org.openbanking.testsupport.vrp.OBVRPFundsConfirmationRequestTestDataFactory.aValidOBVRPFundsConfirmationRequest)3 ConsentStatusEntry (com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)2 FRAccountIdentifierTestDataFactory.aValidFRAccountIdentifier (com.forgerock.openbanking.aspsp.rs.store.api.openbanking.testsupport.domain.FRAccountIdentifierTestDataFactory.aValidFRAccountIdentifier)2 FRAccountIdentifier (com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier)2 FRDomesticVRPConsentDetailsData (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsentDetailsData)2 FRWriteDomesticVRPDataInitiation (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRWriteDomesticVRPDataInitiation)2 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)2 ConsentMetricService (com.forgerock.openbanking.analytics.services.ConsentMetricService)1