Search in sources :

Example 1 with FRWriteDomesticConsentData

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticConsentData in project openbanking-aspsp by OpenBankingToolkit.

the class RCSConsentDecisionApiControllerIT method getConsentDetailsForSinglePayment.

@Test
public void getConsentDetailsForSinglePayment() throws Exception {
    // Given
    FRWriteDomesticConsentData writeDomesticConsentData = FRWriteDomesticConsentData.builder().initiation(FRWriteDomesticDataInitiation.builder().build()).build();
    FRPaymentSetup payment = FRPaymentSetup.builder().pispId(PISP_ID).pispName(PISP_NAME).status(ConsentStatusCode.AWAITINGAUTHORISATION).paymentSetupRequest(FRWriteDomesticConsent.builder().data(writeDomesticConsentData).build()).build();
    payment.getInitiation().setInstructedAmount(FRAmount.builder().build());
    when(singlePaymentService.getPayment(any())).thenReturn(payment);
    String signedJwtEncoded = toEncodedSignedTestJwt("jwt/singlePaymentConsentRequestPayload.json");
    // When
    HttpResponse<SinglePaymentConsentDetails> 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(SinglePaymentConsentDetails.class);
    // Then
    assertThat(response.getStatus()).isEqualTo(200);
    SinglePaymentConsentDetails resp = response.getBody();
    assertThat(resp.getClientId()).isEqualTo(PISP_ID);
    assertThat(resp.getPispName()).isEqualTo(PISP_NAME);
    assertThat(resp.getUsername()).isEqualTo(USER_ID);
    assertThat(resp.getIntentType()).isEqualTo(IntentType.PAYMENT_SINGLE_REQUEST);
    assertThat(resp.getDecisionAPIUri()).isEqualTo(EXPECTED_DECISION_API_URI);
}
Also used : SinglePaymentConsentDetails(com.forgerock.openbanking.common.model.rcs.consentdetails.SinglePaymentConsentDetails) FRPaymentSetup(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup) 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) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with FRWriteDomesticConsentData

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticConsentData 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)

Aggregations

JwtTestHelper.utf8FileToString (com.forgerock.openbanking.aspsp.rs.rcs.api.rcs.JwtTestHelper.utf8FileToString)2 FRWriteDomesticConsentData (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticConsentData)2 Test (org.junit.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 FRDomesticConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)1 FRPaymentSetup (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup)1 DomesticPaymentConsentDetails (com.forgerock.openbanking.common.model.rcs.consentdetails.DomesticPaymentConsentDetails)1 SinglePaymentConsentDetails (com.forgerock.openbanking.common.model.rcs.consentdetails.SinglePaymentConsentDetails)1