use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method testGetDomesticPaymentSubmissionMissingConsentReturnNotFound.
@Test
public void testGetDomesticPaymentSubmissionMissingConsentReturnNotFound() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
consent.setId(IntentType.PAYMENT_DOMESTIC_CONSENT.generateIntentId());
FRDomesticPaymentSubmission submission = savePaymentSubmission(consent, UUID.randomUUID().toString());
// 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 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<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 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_6);
}
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 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 DomesticPaymentConsentsApiControllerIT method saveFRConsent.
private FRDomesticConsent saveFRConsent(FRReadRefundAccount frReadRefundAccount, ConsentStatusCode consentStatusCode) {
FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
consent.getDomesticConsent().getData().setReadRefundAccount(frReadRefundAccount);
consent.setId(IntentType.PAYMENT_DOMESTIC_CONSENT.generateIntentId());
consent.setIdempotencyKey(UUID.randomUUID().toString());
consent.setStatus(consentStatusCode);
setupTestFRConsentInitiation(consent.getInitiation());
consent.getRisk().setMerchantCategoryCode(aValidFRRisk().getMerchantCategoryCode());
consent.getRisk().setDeliveryAddress(aValidFRRisk().getDeliveryAddress());
consent.setObVersion(OBVersion.v3_1_7);
repository.save(consent);
return consent;
}
Aggregations