use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpConsentsApiControllerIT method deleteDomesticVrpPaymentConsent.
@Test
public void deleteDomesticVrpPaymentConsent() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticVRPConsent consent = saveFRConsent(IntentType.DOMESTIC_VRP_PAYMENT_CONSENT.generateIntentId(), FRReadRefundAccount.NO, ConsentStatusCode.EXPIRED);
// When
HttpResponse<OBDomesticVRPConsentResponse> response = Unirest.delete(RS_STORE_URL + port + CONTEXT_PATH + consent.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBDomesticVRPConsentResponse.class);
log.debug("Response {}:{} {}", response.getStatus(), response.getStatusText(), response.getBody());
if (response.getParsingError().isPresent()) {
log.error("Parsing error", response.getParsingError().get());
}
// Then
assertThat(response.getStatus()).isEqualTo(HttpStatus.NO_CONTENT.value());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpConsentsApiControllerIT method getFundsConfirmation_not_available.
@Test
public void getFundsConfirmation_not_available() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
OBVRPFundsConfirmationRequest request = aValidOBVRPFundsConfirmationRequest();
FRDomesticVRPConsent consent = saveFRConsent(request.getData().getConsentId(), FRReadRefundAccount.NO, ConsentStatusCode.AUTHORISED);
given(fundsAvailabilityService.isFundsAvailable(any(), any())).willReturn(false);
FRAccountIdentifier accountIdentifier = consent.getVrpDetails().getData().getInitiation().getDebtorAccount();
given(accountRepository.findByUserID(any())).willReturn(Collections.singletonList(FRAccount.builder().account(FRFinancialAccount.builder().accounts(Collections.singletonList(accountIdentifier)).build()).id("111").build()));
// When
HttpResponse<OBVRPFundsConfirmationResponse> response = Unirest.post(RS_STORE_URL + port + CONTEXT_PATH + consent.getId() + "/funds-confirmation").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(request).asObject(OBVRPFundsConfirmationResponse.class);
// Then
if (response.getParsingError().isPresent()) {
log.error("The response: {}", response);
log.error("Parsing error", response.getParsingError().get());
}
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
OBVRPFundsConfirmationResponseData responseData = response.getBody().getData();
OBVRPFundsConfirmationRequestData requestData = request.getData();
assertThat(responseData.getConsentId()).isEqualTo(requestData.getConsentId());
assertThat(responseData.getReference()).isEqualTo(requestData.getReference());
assertThat(responseData.getFundsConfirmationId()).isNotNull();
assertThat(responseData.getInstructedAmount()).isEqualTo(requestData.getInstructedAmount());
assertThat(responseData.getFundsAvailableResult().getFundsAvailable()).isEqualTo(OBPAFundsAvailableResult1.FundsAvailableEnum.NOTAVAILABLE);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpConsentsApiControllerIT method getFundsConfirmation_available.
@Test
public void getFundsConfirmation_available() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
OBVRPFundsConfirmationRequest request = aValidOBVRPFundsConfirmationRequest();
FRDomesticVRPConsent consent = saveFRConsent(request.getData().getConsentId(), FRReadRefundAccount.NO, ConsentStatusCode.AUTHORISED);
given(fundsAvailabilityService.isFundsAvailable(any(), any())).willReturn(true);
FRAccountIdentifier accountIdentifier = consent.getVrpDetails().getData().getInitiation().getDebtorAccount();
given(accountRepository.findByUserID(any())).willReturn(Collections.singletonList(FRAccount.builder().account(FRFinancialAccount.builder().accounts(Collections.singletonList(accountIdentifier)).build()).id("111").build()));
// When
HttpResponse<OBVRPFundsConfirmationResponse> response = Unirest.post(RS_STORE_URL + port + CONTEXT_PATH + consent.getId() + "/funds-confirmation").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(request).asObject(OBVRPFundsConfirmationResponse.class);
// Then
if (response.getParsingError().isPresent()) {
log.error("The response: {}", response);
log.error("Parsing error", response.getParsingError().get());
}
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
OBVRPFundsConfirmationResponseData responseData = response.getBody().getData();
OBVRPFundsConfirmationRequestData requestData = request.getData();
assertThat(responseData.getConsentId()).isEqualTo(requestData.getConsentId());
assertThat(responseData.getReference()).isEqualTo(requestData.getReference());
assertThat(responseData.getFundsConfirmationId()).isNotNull();
assertThat(responseData.getInstructedAmount()).isEqualTo(requestData.getInstructedAmount());
assertThat(responseData.getFundsAvailableResult().getFundsAvailable()).isEqualTo(OBPAFundsAvailableResult1.FundsAvailableEnum.AVAILABLE);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpConsentsApiControllerIT method getFundsConfirmation_status_not_authorised.
@Test
public void getFundsConfirmation_status_not_authorised() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
OBVRPFundsConfirmationRequest request = aValidOBVRPFundsConfirmationRequest();
FRDomesticVRPConsent consent = saveFRConsent(request.getData().getConsentId(), FRReadRefundAccount.NO, ConsentStatusCode.EXPIRED);
// When
HttpResponse<OBVRPFundsConfirmationResponse> response = Unirest.post(RS_STORE_URL + port + CONTEXT_PATH + consent.getId() + "/funds-confirmation").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(request).asObject(OBVRPFundsConfirmationResponse.class);
// Then
if (response.getParsingError().isPresent()) {
log.error("The response: {}", response);
log.error("Parsing error", response.getParsingError().get());
}
assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST.value());
// OBVRPFundsConfirmationResponseData responseData = response.getBody().getData();
// OBVRPFundsConfirmationRequestData requestData = request.getData();
// assertThat(responseData.getConsentId()).isEqualTo(requestData.getConsentId());
// assertThat(responseData.getReference()).isEqualTo(requestData.getReference());
// assertThat(responseData.getFundsConfirmationId()).isNotNull();
// assertThat(responseData.getInstructedAmount()).isEqualTo(requestData.getInstructedAmount());
// assertThat(responseData.getFundsAvailableResult().getFundsAvailable()).isEqualTo(OBPAFundsAvailableResult1.FundsAvailableEnum.NOTAVAILABLE);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpsApiControllerIT method createVrpPaymentSubmission.
@Test
public void createVrpPaymentSubmission() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
OBDomesticVRPRequest request = aValidOBDomesticVRPRequest();
FRDomesticVRPConsent consent = saveFRConsent(request.getData().getConsentId(), FRReadRefundAccount.YES, ConsentStatusCode.AUTHORISED);
// When
HttpResponse<OBDomesticVRPResponse> 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, 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(request).asObject(OBDomesticVRPResponse.class);
// Then
log.debug("Response {}:{} {}", response.getStatus(), response.getStatusText(), response.getBody());
if (response.getParsingError().isPresent()) {
log.error("Parsing error", response.getParsingError().get());
}
assertThat(response.getStatus()).isEqualTo(HttpStatus.CREATED.value());
OBDomesticVRPResponse vrpResponse = response.getBody();
FRDomesticVrpPaymentSubmission paymentSubmission = paymentSubmissionRepository.findById(vrpResponse.getData().getConsentId()).get();
assertThat(paymentSubmission.getId()).isEqualTo(consent.getId());
assertThat(paymentSubmission.getId()).isEqualTo(request.getData().getConsentId());
assertThat(vrpResponse.getData().getStatus()).isEqualTo(OBDomesticVRPResponseData.StatusEnum.PENDING);
assertThat(paymentSubmission.getStatus()).isEqualTo(vrpResponse.getData().getStatus());
}
Aggregations