Search in sources :

Example 96 with FRDomesticConsent

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

Example 97 with FRDomesticConsent

use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticPaymentsApiControllerIT method testCreateDomesticPaymentSubmission.

@Test
public void testCreateDomesticPaymentSubmission() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    FRDomesticConsent consent = saveConsent(FRReadRefundAccount.NO);
    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);
}
Also used : FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) FRDomesticPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticPaymentSubmission) FRWriteDomesticConverter.toOBWriteDomestic2(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticConverter.toOBWriteDomestic2) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 98 with FRDomesticConsent

use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticPaymentsApiControllerIT method saveConsent.

private FRDomesticConsent saveConsent(FRReadRefundAccount frReadRefundAccount) {
    FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
    consent.getDomesticConsent().getData().setReadRefundAccount(frReadRefundAccount);
    consent.setId(IntentType.PAYMENT_DOMESTIC_CONSENT.generateIntentId());
    consent.getInitiation().setInstructedAmount(aValidFRAmount());
    consent.getInitiation().setCreditorPostalAddress(aValidFRPostalAddress());
    consent.getInitiation().setSupplementaryData(FRSupplementaryData.builder().data("{}").build());
    consent.getRisk().setMerchantCategoryCode(aValidFRRisk().getMerchantCategoryCode());
    consent.getRisk().setDeliveryAddress(aValidFRRisk().getDeliveryAddress());
    consent.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
    consentRepository.save(consent);
    return consent;
}
Also used : FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)

Example 99 with FRDomesticConsent

use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticPaymentsApiControllerIT method testGetMissingDomesticPaymentSubmissionReturnNotFound.

@Test
public void testGetMissingDomesticPaymentSubmissionReturnNotFound() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    FRDomesticConsent consent = saveConsent(FRReadRefundAccount.NO);
    FRWriteDomestic submissionRequest = JMockData.mock(FRWriteDomestic.class);
    FRDomesticPaymentSubmission submission = FRDomesticPaymentSubmission.builder().id(consent.getId()).domesticPayment(submissionRequest).build();
    // 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);
}
Also used : FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) FRDomesticPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticPaymentSubmission) FRWriteDomestic(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomestic) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 100 with FRDomesticConsent

use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticPaymentConsentsApiControllerIT method saveFRConsent.

private FRDomesticConsent saveFRConsent(FRReadRefundAccount frReadRefundAccount, ConsentStatusCode consentStatusCode) {
    FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
    consent.getDomesticConsent().getData().setReadRefundAccount(frReadRefundAccount);
    consent.setId(IntentType.PAYMENT_DOMESTIC_CONSENT.generateIntentId());
    consent.setIdempotencyKey(UUID.randomUUID().toString());
    consent.setStatus(consentStatusCode);
    setupTestFRConsentInitiation(consent.getInitiation());
    consent.getRisk().setMerchantCategoryCode(aValidFRRisk().getMerchantCategoryCode());
    consent.getRisk().setDeliveryAddress(aValidFRRisk().getDeliveryAddress());
    consent.setObVersion(OBVersion.v3_1_7);
    repository.save(consent);
    return consent;
}
Also used : FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)

Aggregations

FRDomesticConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)105 Test (org.junit.Test)62 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)50 SpringSecForTest (com.forgerock.openbanking.integration.test.support.SpringSecForTest)49 FRDomesticPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticPaymentSubmission)37 Collections (java.util.Collections)15 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)14 FRWriteDomesticConverter.toOBWriteDomestic2 (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticConverter.toOBWriteDomestic2)13 DomesticPaymentService (com.forgerock.openbanking.common.services.store.payment.DomesticPaymentService)13 ResponseEntity (org.springframework.http.ResponseEntity)12 ConsentStatusCode (com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode)11 RSEndpointWrapperService (com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService)9 FRWriteDomestic (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomestic)9 FRWriteDomesticConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticConsent)9 RsStoreGateway (com.forgerock.openbanking.common.services.store.RsStoreGateway)9 Principal (java.security.Principal)9 FRAccount (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 DateTime (org.joda.time.DateTime)7 HttpHeaders (org.springframework.http.HttpHeaders)7