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
// seems odd this isn't a 404
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.
@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());
}
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 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_7);
}
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