Search in sources :

Example 56 with FRDomesticConsent

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

the class DomesticPaymentConsentsApiControllerIT method testGetDomesticPaymentConsentFunds.

@Test
public void testGetDomesticPaymentConsentFunds() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
    consent.setStatus(ConsentStatusCode.AUTHORISED);
    consent.setIdempotencyKey(UUID.randomUUID().toString());
    repository.save(consent);
    given(fundsAvailabilityService.isFundsAvailable(any(), any())).willReturn(true);
    // When
    HttpResponse<OBWriteFundsConfirmationResponse1> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payment-consents/" + consent.getId() + "/funds-confirmation").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header("x-ob-url", "https://it-test").asObject(OBWriteFundsConfirmationResponse1.class);
    // Then
    assertThat(response.getStatus()).isEqualTo(200);
    assertThat(response.getBody().getData().getFundsAvailableResult().isFundsAvailable()).isEqualTo(true);
    assertThat(response.getBody().getData().getFundsAvailableResult().getFundsAvailableDateTime()).isNotNull();
    assertThat(response.getBody().getMeta()).isNotNull();
}
Also used : OBWriteFundsConfirmationResponse1(uk.org.openbanking.datamodel.payment.OBWriteFundsConfirmationResponse1) FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test)

Example 57 with FRDomesticConsent

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.ACCEPTEDSETTLEMENTCOMPLETED);
    // When
    HttpResponse<String> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payment-consents/" + consent.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) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test)

Example 58 with FRDomesticConsent

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

the class DomesticPaymentConsentsApiControllerIT method testCreateDomesticPaymentConsent.

@Test
public void testCreateDomesticPaymentConsent() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    setupMockTpp(tppRepository);
    OBWriteDomesticConsent2 consentRequest = JMockData.mock(OBWriteDomesticConsent2.class);
    consentRequest.getData().getInitiation().getInstructedAmount().currency("GBP").amount("1.00");
    consentRequest.getData().getInitiation().getCreditorPostalAddress().country("GB").addressLine(Collections.singletonList("3 Queens Square"));
    consentRequest.getData().getInitiation().supplementaryData(new OBSupplementaryData1());
    consentRequest.getRisk().merchantCategoryCode("ABCD").getDeliveryAddress().countrySubDivision("Wessex").addressLine(Collections.singletonList("3 Queens Square")).country("GP");
    // When
    HttpResponse<OBWriteDomesticConsentResponse2> response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payment-consents/").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, UUID.randomUUID().toString()).header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header("x-ob-client-id", MOCK_CLIENT_ID).header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(consentRequest).asObject(OBWriteDomesticConsentResponse2.class);
    // Then
    log.error("The response: {}", response);
    assertThat(response.getStatus()).isEqualTo(201);
    OBWriteDomesticConsentResponse2 consentResponse = response.getBody();
    FRDomesticConsent consent = repository.findById(consentResponse.getData().getConsentId()).get();
    assertThat(consent.getPispName()).isEqualTo(MOCK_PISP_NAME);
    assertThat(consent.getPispId()).isEqualTo(MOCK_PISP_ID);
    assertThat(consent.getId()).isEqualTo(consentResponse.getData().getConsentId());
    assertThat(toOBDomestic2(consent.getInitiation())).isEqualTo(consentResponse.getData().getInitiation());
    assertThat(consent.getStatus().toOBExternalConsentStatus1Code()).isEqualTo(consentResponse.getData().getStatus());
    assertThat(consent.getRisk()).isEqualTo(toFRRisk(consentResponse.getRisk()));
    assertThat(consent.getObVersion()).isEqualTo(OBVersion.v3_1);
}
Also used : OBSupplementaryData1(uk.org.openbanking.datamodel.payment.OBSupplementaryData1) FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) OBWriteDomesticConsentResponse2(uk.org.openbanking.datamodel.payment.OBWriteDomesticConsentResponse2) OBWriteDomesticConsent2(uk.org.openbanking.datamodel.payment.OBWriteDomesticConsent2) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test)

Example 59 with FRDomesticConsent

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();
    FRDomesticPaymentSubmission submission = savePaymentSubmission(consent, UUID.randomUUID().toString());
    // When
    HttpResponse<OBWriteDomesticConsentResponse2> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payments/" + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBWriteDomesticConsentResponse2.class);
    // Then
    assertThat(response.getStatus()).isEqualTo(200);
    assertThat(response.getBody().getData().getConsentId()).isEqualTo(consent.getId());
    assertThat(response.getBody().getData().getInitiation()).isEqualTo(toOBDomestic2(submission.getDomesticPayment().getData().getInitiation()));
    assertThat(response.getBody().getData().getCreationDateTime()).isEqualTo(consent.getCreated());
    assertThat(response.getBody().getData().getStatusUpdateDateTime()).isEqualTo(consent.getStatusUpdate());
}
Also used : FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) FRDomesticPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticPaymentSubmission) OBWriteDomesticConsentResponse2(uk.org.openbanking.datamodel.payment.OBWriteDomesticConsentResponse2) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 60 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("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payments/" + 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)

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