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 DomesticPaymentsApiControllerIT method testCreateDomesticPaymentSubmission.
@Test
public void testCreateDomesticPaymentSubmission() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent(FRReadRefundAccount.NO);
OBWriteDomestic2 submissionRequest = new OBWriteDomestic2().risk(toOBRisk1(consent.getRisk())).data(new OBWriteDataDomestic2().consentId(consent.getId()).initiation(toOBDomestic2(consent.getInitiation())));
// When
HttpResponse<OBWriteDomesticResponse4> 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(OBWriteDomesticResponse4.class);
// Then
assertThat(response.getStatus()).isEqualTo(201);
OBWriteDomesticResponse4 consentResponse = response.getBody();
FRDomesticPaymentSubmission submission = submissionRepository.findById(response.getBody().getData().getDomesticPaymentId()).get();
assertThat(submission.getId()).isEqualTo(consentResponse.getData().getConsentId());
assertThat(consentResponse.getData().getRefund()).isNull();
assertThat(toOBWriteDomestic2(submission.getDomesticPayment())).isEqualTo(submissionRequest);
assertThat(submission.getObVersion()).isEqualTo(OBVersion.v3_1_4);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method testGetMissingDomesticPaymentSubmissionReturnNotFound.
@Test
public void testGetMissingDomesticPaymentSubmissionReturnNotFound() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent(FRReadRefundAccount.NO);
FRWriteDomestic submissionRequest = JMockData.mock(FRWriteDomestic.class);
FRDomesticPaymentSubmission submission = FRDomesticPaymentSubmission.builder().id(consent.getId()).domesticPayment(submissionRequest).build();
// When
HttpResponse<String> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + submission.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 DomesticPaymentsApiControllerIT method saveConsent.
private FRDomesticConsent saveConsent(FRReadRefundAccount frReadRefundAccount) {
FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
consent.getDomesticConsent().getData().setReadRefundAccount(frReadRefundAccount);
consent.setId(IntentType.PAYMENT_DOMESTIC_CONSENT.generateIntentId());
consent.getInitiation().setInstructedAmount(aValidFRAmount());
consent.getInitiation().setCreditorPostalAddress(aValidFRPostalAddress());
consent.getInitiation().setSupplementaryData(FRSupplementaryData.builder().data("{}").build());
consent.getRisk().setMerchantCategoryCode(aValidFRRisk().getMerchantCategoryCode());
consent.getRisk().setDeliveryAddress(aValidFRRisk().getDeliveryAddress());
consent.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
consentRepository.save(consent);
return consent;
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method testGetDomesticPaymentConsent.
@Test
public void testGetDomesticPaymentConsent() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveFRConsent(FRReadRefundAccount.NO, 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());
}
Aggregations