use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method testGetDomesticPaymentConsentFunds.
@Test
public void testGetDomesticPaymentConsentFunds() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveFRConsent(FRReadRefundAccount.NO, ConsentStatusCode.AUTHORISED);
given(fundsAvailabilityService.isFundsAvailable(any(), any())).willReturn(true);
// When
HttpResponse<OBWriteFundsConfirmationResponse1> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + consent.getId() + "/funds-confirmation").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header("x-ob-url", "https://it-test").asObject(OBWriteFundsConfirmationResponse1.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getBody().getData().getFundsAvailableResult().isFundsAvailable()).isEqualTo(true);
assertThat(response.getBody().getData().getFundsAvailableResult().getFundsAvailableDateTime()).isNotNull();
assertThat(response.getBody().getMeta()).isNotNull();
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method testGetDomesticPaymentConsentReturnNotFound.
@Test
public void testGetDomesticPaymentConsentReturnNotFound() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
consent.setStatus(ConsentStatusCode.CONSUMED);
// When
HttpResponse<String> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + consent.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(String.class);
// Then
assertThat(response.getStatus()).isEqualTo(400);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method testGetDomesticPaymentConsent_RefundNull.
@Test
public void testGetDomesticPaymentConsent_RefundNull() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveFRConsent(null, ConsentStatusCode.CONSUMED);
// When
HttpResponse<OBWriteDomesticConsentResponse5> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + consent.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBWriteDomesticConsentResponse5.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(200);
assertThat(response.getBody().getData().getConsentId()).isEqualTo(consent.getId());
assertThat(toFRWriteDomesticDataInitiation(response.getBody().getData().getInitiation())).isEqualTo(consent.getInitiation());
assertThat(response.getBody().getData().getStatus().getValue()).isEqualTo(consent.getStatus().toOBExternalConsentStatus2Code().toString());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method testCreateDomesticPaymentSubmission_expectRefundAccount.
@Test
public void testCreateDomesticPaymentSubmission_expectRefundAccount() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent(FRReadRefundAccount.YES);
OBWriteDomestic2 submissionRequest = new OBWriteDomestic2().risk(toOBRisk1(consent.getRisk())).data(new OBWriteDataDomestic2().consentId(consent.getId()).initiation(toOBDomestic2(consent.getInitiation())));
// When
HttpResponse<OBWriteDomesticResponse5> 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, "x-idempotency-key").header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(submissionRequest).asObject(OBWriteDomesticResponse5.class);
// Then
assertThat(response.getStatus()).isEqualTo(201);
OBWriteDomesticResponse5 rBody = response.getBody();
FRDomesticPaymentSubmission submission = submissionRepository.findById(response.getBody().getData().getDomesticPaymentId()).get();
assertThat(submission.getId()).isEqualTo(rBody.getData().getConsentId());
// Refund
OBWriteDomesticResponse5DataRefund refund = rBody.getData().getRefund();
assertThat(refund).isNotNull();
assertThat(refund.getAccount().getIdentification()).isEqualTo(consent.getInitiation().getDebtorAccount().getIdentification());
assertThat(refund.getAccount().getName()).isEqualTo(consent.getInitiation().getDebtorAccount().getName());
assertThat(refund.getAccount().getSchemeName()).isEqualTo(consent.getInitiation().getDebtorAccount().getSchemeName());
assertThat(refund.getAccount().getSecondaryIdentification()).isEqualTo(consent.getInitiation().getDebtorAccount().getSecondaryIdentification());
assertThat(toOBWriteDomestic2(submission.getDomesticPayment())).isEqualTo(submissionRequest);
assertThat(submission.getObVersion()).isEqualTo(OBVersion.v3_1_6);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method testGetDomesticPaymentSubmission_expectRefundAccount.
@Test
public void testGetDomesticPaymentSubmission_expectRefundAccount() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent(FRReadRefundAccount.YES);
FRDomesticPaymentSubmission submission = savePaymentSubmission(consent, UUID.randomUUID().toString());
// When
HttpResponse<OBWriteDomesticResponse5> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBWriteDomesticResponse5.class);
// Then
OBWriteDomesticResponse5Data bodyData = response.getBody().getData();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(bodyData.getRefund()).isNotNull();
assertThat(bodyData.getConsentId()).isEqualTo(consent.getId());
assertThat(bodyData.getInitiation()).isEqualTo(toOBWriteDomestic2DataInitiation(submission.getDomesticPayment().getData().getInitiation()));
assertThat(bodyData.getCreationDateTime()).isEqualTo(consent.getCreated());
assertThat(bodyData.getStatusUpdateDateTime()).isEqualTo(consent.getStatusUpdate());
}
Aggregations