use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method testCreateDomesticPaymentSubmission_refundNull.
@Test
public void testCreateDomesticPaymentSubmission_refundNull() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent(null);
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 testGetDomesticPaymentSubmission.
@Test
public void testGetDomesticPaymentSubmission() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent(FRReadRefundAccount.NO);
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()).isNull();
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());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method testGetDomesticPaymentSubmission.
@Test
public void testGetDomesticPaymentSubmission() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent(FRReadRefundAccount.NO);
FRDomesticPaymentSubmission submission = savePaymentSubmission(consent, UUID.randomUUID().toString());
// When
HttpResponse<OBWriteDomesticResponse4> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBWriteDomesticResponse4.class);
// Then
OBWriteDomesticResponse4Data bodyData = response.getBody().getData();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(bodyData.getRefund()).isNull();
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());
}
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<OBWriteDomesticResponse4> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBWriteDomesticResponse4.class);
// Then
OBWriteDomesticResponse4Data 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());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method testCreateDomesticPaymentSubmission_refundNull.
@Test
public void testCreateDomesticPaymentSubmission_refundNull() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent(null);
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);
}
Aggregations