Search in sources :

Example 11 with FRDomesticVRPConsent

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

the class DomesticVrpConsentsApiControllerIT method deleteDomesticVrpPaymentConsent.

@Test
public void deleteDomesticVrpPaymentConsent() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    FRDomesticVRPConsent consent = saveFRConsent(IntentType.DOMESTIC_VRP_PAYMENT_CONSENT.generateIntentId(), FRReadRefundAccount.NO, ConsentStatusCode.EXPIRED);
    // When
    HttpResponse<OBDomesticVRPConsentResponse> response = Unirest.delete(RS_STORE_URL + port + CONTEXT_PATH + consent.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBDomesticVRPConsentResponse.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.NO_CONTENT.value());
}
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 12 with FRDomesticVRPConsent

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

the class DomesticVrpConsentsApiControllerIT method getFundsConfirmation_not_available.

@Test
public void getFundsConfirmation_not_available() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    OBVRPFundsConfirmationRequest request = aValidOBVRPFundsConfirmationRequest();
    FRDomesticVRPConsent consent = saveFRConsent(request.getData().getConsentId(), FRReadRefundAccount.NO, ConsentStatusCode.AUTHORISED);
    given(fundsAvailabilityService.isFundsAvailable(any(), any())).willReturn(false);
    FRAccountIdentifier accountIdentifier = consent.getVrpDetails().getData().getInitiation().getDebtorAccount();
    given(accountRepository.findByUserID(any())).willReturn(Collections.singletonList(FRAccount.builder().account(FRFinancialAccount.builder().accounts(Collections.singletonList(accountIdentifier)).build()).id("111").build()));
    // When
    HttpResponse<OBVRPFundsConfirmationResponse> response = Unirest.post(RS_STORE_URL + port + CONTEXT_PATH + consent.getId() + "/funds-confirmation").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(request).asObject(OBVRPFundsConfirmationResponse.class);
    // Then
    if (response.getParsingError().isPresent()) {
        log.error("The response: {}", response);
        log.error("Parsing error", response.getParsingError().get());
    }
    assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
    OBVRPFundsConfirmationResponseData responseData = response.getBody().getData();
    OBVRPFundsConfirmationRequestData requestData = request.getData();
    assertThat(responseData.getConsentId()).isEqualTo(requestData.getConsentId());
    assertThat(responseData.getReference()).isEqualTo(requestData.getReference());
    assertThat(responseData.getFundsConfirmationId()).isNotNull();
    assertThat(responseData.getInstructedAmount()).isEqualTo(requestData.getInstructedAmount());
    assertThat(responseData.getFundsAvailableResult().getFundsAvailable()).isEqualTo(OBPAFundsAvailableResult1.FundsAvailableEnum.NOTAVAILABLE);
}
Also used : FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) FRAccountIdentifierTestDataFactory.aValidFRAccountIdentifier(com.forgerock.openbanking.aspsp.rs.store.api.openbanking.testsupport.domain.FRAccountIdentifierTestDataFactory.aValidFRAccountIdentifier) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) OBVRPFundsConfirmationRequestTestDataFactory.aValidOBVRPFundsConfirmationRequest(uk.org.openbanking.testsupport.vrp.OBVRPFundsConfirmationRequestTestDataFactory.aValidOBVRPFundsConfirmationRequest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test)

Example 13 with FRDomesticVRPConsent

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

the class DomesticVrpConsentsApiControllerIT method getFundsConfirmation_available.

@Test
public void getFundsConfirmation_available() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    OBVRPFundsConfirmationRequest request = aValidOBVRPFundsConfirmationRequest();
    FRDomesticVRPConsent consent = saveFRConsent(request.getData().getConsentId(), FRReadRefundAccount.NO, ConsentStatusCode.AUTHORISED);
    given(fundsAvailabilityService.isFundsAvailable(any(), any())).willReturn(true);
    FRAccountIdentifier accountIdentifier = consent.getVrpDetails().getData().getInitiation().getDebtorAccount();
    given(accountRepository.findByUserID(any())).willReturn(Collections.singletonList(FRAccount.builder().account(FRFinancialAccount.builder().accounts(Collections.singletonList(accountIdentifier)).build()).id("111").build()));
    // When
    HttpResponse<OBVRPFundsConfirmationResponse> response = Unirest.post(RS_STORE_URL + port + CONTEXT_PATH + consent.getId() + "/funds-confirmation").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(request).asObject(OBVRPFundsConfirmationResponse.class);
    // Then
    if (response.getParsingError().isPresent()) {
        log.error("The response: {}", response);
        log.error("Parsing error", response.getParsingError().get());
    }
    assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
    OBVRPFundsConfirmationResponseData responseData = response.getBody().getData();
    OBVRPFundsConfirmationRequestData requestData = request.getData();
    assertThat(responseData.getConsentId()).isEqualTo(requestData.getConsentId());
    assertThat(responseData.getReference()).isEqualTo(requestData.getReference());
    assertThat(responseData.getFundsConfirmationId()).isNotNull();
    assertThat(responseData.getInstructedAmount()).isEqualTo(requestData.getInstructedAmount());
    assertThat(responseData.getFundsAvailableResult().getFundsAvailable()).isEqualTo(OBPAFundsAvailableResult1.FundsAvailableEnum.AVAILABLE);
}
Also used : FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) FRAccountIdentifierTestDataFactory.aValidFRAccountIdentifier(com.forgerock.openbanking.aspsp.rs.store.api.openbanking.testsupport.domain.FRAccountIdentifierTestDataFactory.aValidFRAccountIdentifier) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) OBVRPFundsConfirmationRequestTestDataFactory.aValidOBVRPFundsConfirmationRequest(uk.org.openbanking.testsupport.vrp.OBVRPFundsConfirmationRequestTestDataFactory.aValidOBVRPFundsConfirmationRequest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test)

Example 14 with FRDomesticVRPConsent

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

the class DomesticVrpConsentsApiControllerIT method getFundsConfirmation_status_not_authorised.

@Test
public void getFundsConfirmation_status_not_authorised() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    OBVRPFundsConfirmationRequest request = aValidOBVRPFundsConfirmationRequest();
    FRDomesticVRPConsent consent = saveFRConsent(request.getData().getConsentId(), FRReadRefundAccount.NO, ConsentStatusCode.EXPIRED);
    // When
    HttpResponse<OBVRPFundsConfirmationResponse> response = Unirest.post(RS_STORE_URL + port + CONTEXT_PATH + consent.getId() + "/funds-confirmation").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(request).asObject(OBVRPFundsConfirmationResponse.class);
    // Then
    if (response.getParsingError().isPresent()) {
        log.error("The response: {}", response);
        log.error("Parsing error", response.getParsingError().get());
    }
    assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST.value());
// OBVRPFundsConfirmationResponseData responseData = response.getBody().getData();
// OBVRPFundsConfirmationRequestData requestData = request.getData();
// assertThat(responseData.getConsentId()).isEqualTo(requestData.getConsentId());
// assertThat(responseData.getReference()).isEqualTo(requestData.getReference());
// assertThat(responseData.getFundsConfirmationId()).isNotNull();
// assertThat(responseData.getInstructedAmount()).isEqualTo(requestData.getInstructedAmount());
// assertThat(responseData.getFundsAvailableResult().getFundsAvailable()).isEqualTo(OBPAFundsAvailableResult1.FundsAvailableEnum.NOTAVAILABLE);
}
Also used : FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) OBVRPFundsConfirmationRequestTestDataFactory.aValidOBVRPFundsConfirmationRequest(uk.org.openbanking.testsupport.vrp.OBVRPFundsConfirmationRequestTestDataFactory.aValidOBVRPFundsConfirmationRequest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test)

Example 15 with FRDomesticVRPConsent

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

the class DomesticVrpsApiControllerIT method createVrpPaymentSubmission.

@Test
public void createVrpPaymentSubmission() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    OBDomesticVRPRequest request = aValidOBDomesticVRPRequest();
    FRDomesticVRPConsent consent = saveFRConsent(request.getData().getConsentId(), FRReadRefundAccount.YES, ConsentStatusCode.AUTHORISED);
    // When
    HttpResponse<OBDomesticVRPResponse> 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(request).asObject(OBDomesticVRPResponse.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());
    OBDomesticVRPResponse vrpResponse = response.getBody();
    FRDomesticVrpPaymentSubmission paymentSubmission = paymentSubmissionRepository.findById(vrpResponse.getData().getConsentId()).get();
    assertThat(paymentSubmission.getId()).isEqualTo(consent.getId());
    assertThat(paymentSubmission.getId()).isEqualTo(request.getData().getConsentId());
    assertThat(vrpResponse.getData().getStatus()).isEqualTo(OBDomesticVRPResponseData.StatusEnum.PENDING);
    assertThat(paymentSubmission.getStatus()).isEqualTo(vrpResponse.getData().getStatus());
}
Also used : OBDomesticVRPRequestTestDataFactory.aValidOBDomesticVRPRequest(uk.org.openbanking.testsupport.vrp.OBDomesticVRPRequestTestDataFactory.aValidOBDomesticVRPRequest) FRDomesticVrpPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVrpPaymentSubmission) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) 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