Search in sources :

Example 1 with DomesticPaymentConsentDetails

use of com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails in project openbanking-aspsp by OpenBankingToolkit.

the class RCSConsentDecisionApiControllerIT method getConsentDetailsForDomesticPayment.

@Test
public void getConsentDetailsForDomesticPayment() throws Exception {
    // Given
    FRWriteDomesticConsentData writeDomesticConsentData = FRWriteDomesticConsentData.builder().initiation(FRWriteDomesticDataInitiation.builder().build()).build();
    FRDomesticConsent payment = FRDomesticConsent.builder().pispId(PISP_ID).pispName(PISP_NAME).status(ConsentStatusCode.AWAITINGAUTHORISATION).domesticConsent(FRWriteDomesticConsent.builder().data(writeDomesticConsentData).build()).build();
    payment.getInitiation().setInstructedAmount(FRAmount.builder().build());
    when(domesticPaymentService.getPayment(any())).thenReturn(payment);
    String signedJwtEncoded = toEncodedSignedTestJwt("jwt/domesticPaymentConsentRequestPayload.json");
    // When
    HttpResponse<DomesticPaymentConsentDetails> response = Unirest.post("https://rs-rcs:" + port + "/api/rcs/consent/details/").header(OBHeaders.CONTENT_TYPE, CONTENT_TYPE_JWT).header("Cookie", MOCK_COOKIE).body(signedJwtEncoded).asObject(DomesticPaymentConsentDetails.class);
    // Then
    assertThat(response.getStatus()).isEqualTo(200);
    DomesticPaymentConsentDetails resp = response.getBody();
    assertThat(resp.getClientId()).isEqualTo(PISP_ID);
    assertThat(resp.getUsername()).isEqualTo(USER_ID);
    assertThat(resp.getIntentType()).isEqualTo(IntentType.PAYMENT_DOMESTIC_CONSENT);
    assertThat(resp.getDecisionAPIUri()).isEqualTo(EXPECTED_DECISION_API_URI);
}
Also used : FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) FRWriteDomesticConsentData(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticConsentData) JwtTestHelper.utf8FileToString(com.forgerock.openbanking.aspsp.rs.rcs.api.rcs.JwtTestHelper.utf8FileToString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DomesticPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with DomesticPaymentConsentDetails

use of com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails in project openbanking-aspsp by OpenBankingToolkit.

the class RCSDomesticPaymentDetailsApiTest method shouldReturnAllAccountsWhenNoDebtor.

@Test
public void shouldReturnAllAccountsWhenNoDebtor() throws OBErrorException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<List<AccountWithBalance>>() {
    });
    FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
    consent.getInitiation().setDebtorAccount(null);
    given(paymentService.getPayment(any())).willReturn(consent);
    given(tppStoreService.findById(consent.getPispId())).willReturn(Optional.of(Tpp.builder().clientId(CLIENT_ID).build()));
    // When
    ResponseEntity responseEntity = api.consentDetails("abcd", accounts, "testuser", "c123", CLIENT_ID);
    // Then
    DomesticPaymentConsentDetails body = (DomesticPaymentConsentDetails) Objects.requireNonNull(responseEntity.getBody());
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts()).isEqualTo(accounts);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) List(java.util.List) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) DomesticPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails) Test(org.junit.Test)

Example 3 with DomesticPaymentConsentDetails

use of com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails in project openbanking-aspsp by OpenBankingToolkit.

the class RCSDomesticPaymentDetailsApiTest method shouldReturnRequestedAccountWhenDebtor.

@Test
public void shouldReturnRequestedAccountWhenDebtor() throws OBErrorException, JsonProcessingException {
    // Given
    List<AccountWithBalance> accounts = JMockData.mock(new TypeReference<>() {
    });
    FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
    FRAccountIdentifier firstAccount = accounts.get(0).getAccount().getAccounts().get(0);
    consent.getInitiation().getDebtorAccount().setIdentification(firstAccount.getIdentification());
    given(paymentService.getPayment(any())).willReturn(consent);
    given(tppStoreService.findById(consent.getPispId())).willReturn(Optional.of(Tpp.builder().clientId(CLIENT_ID).build()));
    // When
    ResponseEntity responseEntity = api.consentDetails("abcd", accounts, "user1", "c123", CLIENT_ID);
    // Then
    DomesticPaymentConsentDetails body = (DomesticPaymentConsentDetails) Objects.requireNonNull(responseEntity.getBody());
    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.registerModule(new JodaModule());
    mapper.setTimeZone(TimeZone.getDefault());
    mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    String json = mapper.writeValueAsString(body);
    log.info("Json Serialize as String \n{}", json);
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(body.getAccounts().size()).isEqualTo(1);
    assertThat(body.getAccounts()).containsExactly(accounts.get(0));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) AccountWithBalance(com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance) DomesticPaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

FRDomesticConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)3 DomesticPaymentConsentDetails (com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails)3 Test (org.junit.Test)3 AccountWithBalance (com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountWithBalance)2 ResponseEntity (org.springframework.http.ResponseEntity)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)1 JwtTestHelper.utf8FileToString (com.forgerock.openbanking.aspsp.rs.rcs.api.rcs.JwtTestHelper.utf8FileToString)1 FRAccountIdentifier (com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier)1 FRWriteDomesticConsentData (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticConsentData)1 List (java.util.List)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1