use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpConsentsApiControllerIT method createDomesticVrpPaymentConsent.
@Test
public void createDomesticVrpPaymentConsent() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
setupMockTpp(tppRepository);
// When
HttpResponse<OBDomesticVRPConsentResponse> 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(aValidOBDomesticVRPConsentRequest()).asObject(OBDomesticVRPConsentResponse.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());
OBDomesticVRPConsentResponse consentResponse = response.getBody();
FRDomesticVRPConsent 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(toOBDomesticVRPInitiation(consent.getInitiation())).isEqualTo(consentResponse.getData().getInitiation());
assertThat(consent.getStatus().toOBExternalConsentStatus1Code().toString()).isEqualTo(consentResponse.getData().getStatus().getValue());
assertThat(consent.getRisk()).isEqualTo(toFRRisk(consentResponse.getRisk()));
assertThat(consent.getObVersion()).isEqualTo(OBVersion.v3_1_8);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpsApiControllerIT method saveFRConsent.
private FRDomesticVRPConsent saveFRConsent(String consentId, FRReadRefundAccount frReadRefundAccount, ConsentStatusCode consentStatusCode) {
FRDomesticVRPConsentDetails details = toFRDomesticVRPConsentDetails(aValidOBDomesticVRPConsentRequest());
FRDomesticVRPConsent consent = JMockData.mock(FRDomesticVRPConsent.class);
consent.setVrpDetails(details);
consent.getVrpDetails().getData().setReadRefundAccount(frReadRefundAccount);
consent.getVrpDetails().getData().getInitiation().setDebtorAccount(aValidFRAccountIdentifier());
consent.setId(consentId);
consent.setIdempotencyKey(UUID.randomUUID().toString());
consent.setStatus(consentStatusCode);
consent.getRisk().setMerchantCategoryCode(aValidFRRisk().getMerchantCategoryCode());
consent.getRisk().setDeliveryAddress(aValidFRRisk().getDeliveryAddress());
consent.setObVersion(OBVersion.v3_1_8);
consentRepository.save(consent);
return consent;
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpsApiControllerIT method getDomesticVrpPayment.
@Test
public void getDomesticVrpPayment() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticVRPConsent consent = saveFRConsent(IntentType.DOMESTIC_VRP_PAYMENT_CONSENT.generateIntentId(), FRReadRefundAccount.YES, ConsentStatusCode.AUTHORISED);
FRDomesticVrpPaymentSubmission paymentSubmission = savePaymentSubmission(consent.getId());
// When
HttpResponse<OBDomesticVRPResponse> response = Unirest.get(RS_STORE_URL + port + CONTEXT_PATH + paymentSubmission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBDomesticVRPResponse.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.OK.value());
assertThat(response.getBody().getData().getConsentId()).isEqualTo(paymentSubmission.getDomesticVrpPayment().getData().getConsentId());
assertThat(response.getBody().getData().getCreationDateTime()).isEqualTo(new DateTime(paymentSubmission.getCreated()));
}
Aggregations