Search in sources :

Example 26 with FRDomesticVRPConsent

use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticVrpConsentsApiControllerIT method createDomesticVrpPaymentConsent.

@Test
public void createDomesticVrpPaymentConsent() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    setupMockTpp(tppRepository);
    // When
    HttpResponse<OBDomesticVRPConsentResponse> response = Unirest.post(RS_STORE_URL + port + CONTEXT_PATH).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, UUID.randomUUID().toString()).header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header("x-ob-client-id", MOCK_CLIENT_ID).header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(aValidOBDomesticVRPConsentRequest()).asObject(OBDomesticVRPConsentResponse.class);
    // Then
    log.debug("Response {}:{}  {}", response.getStatus(), response.getStatusText(), response.getBody());
    if (response.getParsingError().isPresent()) {
        log.error("Parsing error", response.getParsingError().get());
    }
    assertThat(response.getStatus()).isEqualTo(HttpStatus.CREATED.value());
    OBDomesticVRPConsentResponse consentResponse = response.getBody();
    FRDomesticVRPConsent consent = repository.findById(consentResponse.getData().getConsentId()).get();
    assertThat(consent.getPispName()).isEqualTo(MOCK_PISP_NAME);
    assertThat(consent.getPispId()).isEqualTo(MOCK_PISP_ID);
    assertThat(consent.getId()).isEqualTo(consentResponse.getData().getConsentId());
    assertThat(toOBDomesticVRPInitiation(consent.getInitiation())).isEqualTo(consentResponse.getData().getInitiation());
    assertThat(consent.getStatus().toOBExternalConsentStatus1Code().toString()).isEqualTo(consentResponse.getData().getStatus().getValue());
    assertThat(consent.getRisk()).isEqualTo(toFRRisk(consentResponse.getRisk()));
    assertThat(consent.getObVersion()).isEqualTo(OBVersion.v3_1_8);
}
Also used : 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)

Example 27 with FRDomesticVRPConsent

use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticVrpsApiControllerIT 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);
    consentRepository.save(consent);
    return consent;
}
Also used : FRDomesticVRPConsentDetails(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsentDetails) FRDomesticVRPConsentConverter.toFRDomesticVRPConsentDetails(com.forgerock.openbanking.common.services.openbanking.converter.vrp.FRDomesticVRPConsentConverter.toFRDomesticVRPConsentDetails) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent)

Example 28 with FRDomesticVRPConsent

use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticVrpsApiControllerIT method getDomesticVrpPayment.

@Test
public void getDomesticVrpPayment() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    FRDomesticVRPConsent consent = saveFRConsent(IntentType.DOMESTIC_VRP_PAYMENT_CONSENT.generateIntentId(), FRReadRefundAccount.YES, ConsentStatusCode.AUTHORISED);
    FRDomesticVrpPaymentSubmission paymentSubmission = savePaymentSubmission(consent.getId());
    // When
    HttpResponse<OBDomesticVRPResponse> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + paymentSubmission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBDomesticVRPResponse.class);
    log.debug("Response {}:{}  {}", response.getStatus(), response.getStatusText(), response.getBody());
    if (response.getParsingError().isPresent()) {
        log.error("Parsing error", response.getParsingError().get());
    }
    // Then
    assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
    assertThat(response.getBody().getData().getConsentId()).isEqualTo(paymentSubmission.getDomesticVrpPayment().getData().getConsentId());
    assertThat(response.getBody().getData().getCreationDateTime()).isEqualTo(new DateTime(paymentSubmission.getCreated()));
}
Also used : FRDomesticVrpPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVrpPaymentSubmission) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) DateTime(org.joda.time.DateTime) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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