use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentsApiControllerIT method testDuplicatePaymentInitiationShouldReturnForbidden.
@Test
public void testDuplicatePaymentInitiationShouldReturnForbidden() throws Exception {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRFileConsent consent = saveConsent();
FRFilePaymentSubmission submission = savePaymentSubmission(consent);
OBWriteFile2 obWriteFile = new OBWriteFile2();
obWriteFile.data(new OBWriteFile2Data().consentId(submission.getId()).initiation(toOBWriteFile2DataInitiation(consent.getInitiation())));
// When
HttpResponse<String> response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.1/pisp/file-payments").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(obWriteFile).asObject(String.class);
// Then
assertThat(response.getStatus()).isEqualTo(403);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentsApiControllerIT method testReportNotReady_NotFound.
@Test
public void testReportNotReady_NotFound() throws Exception {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRFileConsent consent = saveConsent(ConsentStatusCode.PENDING);
when(paymentReportFileService.createPaymentReport(eq(consent))).thenThrow(new OBErrorResponseException(HttpStatus.NOT_FOUND, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.FILE_PAYMENT_REPORT_NOT_READY.toOBError1(consent.getId(), consent.getStatus().toString(), "")));
// When
HttpResponse<String> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/file-payments/" + consent.getId() + "/report-file").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").header("Accept", "application/json; charset=utf-8").asString();
log.debug("Response: {}", response.getBody());
// Then
assertThat(response.getStatus()).isEqualTo(404);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentsApiControllerIT method testGetMissingInternationalPaymentSubmissionReturnNotFound.
@Test
public void testGetMissingInternationalPaymentSubmissionReturnNotFound() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRFileConsent consent = saveConsent();
FRWriteFile submissionRequest = JMockData.mock(FRWriteFile.class);
FRFilePaymentSubmission submission = FRFilePaymentSubmission.builder().id(consent.getId()).filePayment(submissionRequest).build();
// When
HttpResponse<String> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/file-payments/" + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").asObject(String.class);
// Then
assertThat(response.getStatus()).isEqualTo(400);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentsApiControllerIT method saveConsent.
private FRFileConsent saveConsent(ConsentStatusCode statusCode) {
FRFileConsent consent = JMockData.mock(FRFileConsent.class);
consent.setId(IntentType.PAYMENT_FILE_CONSENT.generateIntentId());
consent.getInitiation().setControlSum(new BigDecimal("1001.1"));
consent.getInitiation().setFileType("UK.OBIE.PaymentInitiation.3.0");
consent.getInitiation().setFileReference("Test");
consent.getInitiation().setNumberOfTransactions("100");
consent.getInitiation().setFileHash("sdjhgfksfkshfjksh");
consent.getInitiation().setRequestedExecutionDateTime(null);
consent.getInitiation().setSupplementaryData(FRSupplementaryData.builder().data("{}").build());
consent.setStatus(statusCode);
consentRepository.save(consent);
return consent;
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentConsentsApiControllerIT method testGetFileConsent.
@Test
public void testGetFileConsent() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRFileConsent consent = JMockData.mock(FRFileConsent.class);
consent.setStatus(ConsentStatusCode.AWAITINGUPLOAD);
consent.getInitiation().setSupplementaryData(FRSupplementaryData.builder().data("{}").build());
repository.save(consent);
// When
HttpResponse<OBWriteFileConsentResponse2> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/file-payment-consents/" + consent.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(CONTENT_TYPE, "application/json").header(ACCEPT, "application/json").asObject(OBWriteFileConsentResponse2.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getBody().getData().getConsentId()).isEqualTo(consent.getId());
assertThat(response.getBody().getData().getInitiation().getFileType()).isEqualTo(consent.getInitiation().getFileType());
assertThat(response.getBody().getData().getInitiation().getFileHash()).isEqualTo(consent.getInitiation().getFileHash());
assertThat(response.getBody().getData().getStatus()).isEqualTo(consent.getStatus().toOBExternalConsentStatus2Code());
Assertions.assertThat(response.getBody().getData().getCreationDateTime()).isEqualToIgnoringMillis(consent.getCreated());
Assertions.assertThat(response.getBody().getData().getStatusUpdateDateTime()).isEqualToIgnoringMillis(consent.getStatusUpdate());
}
Aggregations