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_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<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 rBody = response.getBody();
FRDomesticPaymentSubmission submission = submissionRepository.findById(response.getBody().getData().getDomesticPaymentId()).get();
assertThat(submission.getId()).isEqualTo(rBody.getData().getConsentId());
// Refund
OBWriteDomesticResponse4DataRefund 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_4);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method testCreateDomesticPaymentConsent.
@Test
public void testCreateDomesticPaymentConsent() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
setupMockTpp(tppRepository);
// When
HttpResponse<OBWriteDomesticConsentResponse4> 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(aValidOBWriteDomesticConsent4()).asObject(OBWriteDomesticConsentResponse4.class);
// Then
log.error("The response: {}", response);
assertThat(response.getStatus()).isEqualTo(201);
OBWriteDomesticConsentResponse4 consentResponse = response.getBody();
FRDomesticConsent 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(toOBWriteDomestic2DataInitiation(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_4);
}
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<OBWriteDomesticConsentResponse4> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + consent.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBWriteDomesticConsentResponse4.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 DomesticPaymentConsentsApiControllerIT method testGetDomesticPaymentConsent.
@Test
public void testGetDomesticPaymentConsent() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
consent.setStatus(ConsentStatusCode.AUTHORISED);
consent.setIdempotencyKey(UUID.randomUUID().toString());
consent.getInitiation().setSupplementaryData(FRSupplementaryData.builder().data("{}").build());
repository.save(consent);
// When
HttpResponse<OBWriteDomesticConsentResponse2> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payment-consents/" + consent.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBWriteDomesticConsentResponse2.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getBody().getData().getConsentId()).isEqualTo(consent.getId());
assertThat(response.getBody().getData().getInitiation()).isEqualTo(toOBDomestic2(consent.getInitiation()));
assertThat(response.getBody().getData().getStatus()).isEqualTo(consent.getStatus().toOBExternalConsentStatus1Code());
Assertions.assertThat(response.getBody().getData().getCreationDateTime()).isEqualToIgnoringMillis(consent.getCreated());
Assertions.assertThat(response.getBody().getData().getStatusUpdateDateTime()).isEqualToIgnoringMillis(consent.getStatusUpdate());
}
Aggregations