Search in sources :

Example 26 with FRFileConsent

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);
}
Also used : FRWriteFileConverter.toOBWriteFile2(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteFileConverter.toOBWriteFile2) FRFileConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent) FRFilePaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFilePaymentSubmission) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 27 with FRFileConsent

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);
}
Also used : FRFileConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 28 with FRFileConsent

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);
}
Also used : FRFileConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent) FRWriteFile(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile) FRFilePaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFilePaymentSubmission) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 29 with FRFileConsent

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;
}
Also used : FRFileConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent) BigDecimal(java.math.BigDecimal)

Example 30 with FRFileConsent

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());
}
Also used : OBWriteFileConsentResponse2(uk.org.openbanking.datamodel.payment.OBWriteFileConsentResponse2) FRFileConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test)

Aggregations

FRFileConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent)45 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)29 FRFilePaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFilePaymentSubmission)13 SpringSecForTest (com.forgerock.openbanking.integration.test.support.SpringSecForTest)12 Date (java.util.Date)12 Test (org.junit.Test)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 RSEndpointWrapperService (com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService)8 RsStoreGateway (com.forgerock.openbanking.common.services.store.RsStoreGateway)8 FilePaymentService (com.forgerock.openbanking.common.services.store.payment.FilePaymentService)8 Principal (java.security.Principal)8 Collections (java.util.Collections)8 HttpServletRequest (javax.servlet.http.HttpServletRequest)8 DateTime (org.joda.time.DateTime)8 Resource (org.springframework.core.io.Resource)8 HttpHeaders (org.springframework.http.HttpHeaders)8 ResponseEntity (org.springframework.http.ResponseEntity)7 Controller (org.springframework.stereotype.Controller)7 FRWriteFile (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile)5 Tpp (com.forgerock.openbanking.model.Tpp)5