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.CONSUMED);
// When
HttpResponse<String> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + consent.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(String.class);
// Then
assertThat(response.getStatus()).isEqualTo(400);
}
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_4);
repository.save(consent);
return consent;
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent 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);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentConsentDecisionUpdaterTest method paymentDecisionAllowed_missingAccountId_rejectWithException.
@Test
public void paymentDecisionAllowed_missingAccountId_rejectWithException() {
// Given
FRDomesticConsent paymentConsent = new FRDomesticConsent();
// When
assertThatThrownBy(() -> paymentConsentDecisionUpdater.applyUpdate(USER_ID, null, true, p -> {
}, paymentConsent)).isExactlyInstanceOf(IllegalArgumentException.class).hasMessage("Missing account id");
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent 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);
}
Aggregations