use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method testCreateDomesticPaymentConsent_exists_idempotencyKeyExpired.
@Test
// This fails intermittently on code fresh - ignoring until more time available to investigate
@Ignore
public void testCreateDomesticPaymentConsent_exists_idempotencyKeyExpired() throws UnirestException {
// Given
final String idempotencyKey = UUID.randomUUID().toString();
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
setupMockTpp(tppRepository);
OBWriteDomesticConsent1 consentRequest = JMockData.mock(OBWriteDomesticConsent1.class);
consentRequest.getData().getInitiation().getInstructedAmount().currency("GBP").amount("1.00");
consentRequest.getData().getInitiation().getCreditorPostalAddress().country("GB").addressLine(Collections.singletonList("3 Queens Square"));
consentRequest.getRisk().merchantCategoryCode("ABCD").getDeliveryAddress().addressLine(Collections.singletonList("3 Queens Square")).country("GP");
consentRequest.getData().getAuthorisation().completionDateTime(null);
OBWriteDomesticConsent4 consent4 = toOBWriteDomesticConsent4(consentRequest);
FRDomesticConsent existingConsent = JMockData.mock(FRDomesticConsent.class);
existingConsent.setId(UUID.randomUUID().toString());
existingConsent.setStatus(ConsentStatusCode.AUTHORISED);
existingConsent.setDomesticConsent(toFRWriteDomesticConsent(consent4));
existingConsent.setIdempotencyKey(idempotencyKey);
existingConsent = repository.save(existingConsent);
// Created date will be set to now by annotation on initial creation so update it here to 25 hours in past to test idempotency expiry
existingConsent.setCreated(DateTime.now().minusHours(25));
repository.save(existingConsent);
// When
HttpResponse response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payment-consents/").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, idempotencyKey).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(consentRequest).asObject(OBWriteDomesticConsentResponse1.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 testCreateDomesticPaymentConsent_exists_idempotencyKeyValid_noActionButReturn201.
@Test
public void testCreateDomesticPaymentConsent_exists_idempotencyKeyValid_noActionButReturn201() throws UnirestException {
// Given
final String idempotencyKey = UUID.randomUUID().toString();
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
setupMockTpp(tppRepository);
OBWriteDomesticConsent4 consentRequest = JMockData.mock(OBWriteDomesticConsent4.class);
consentRequest.getData().getInitiation().getInstructedAmount().currency("GBP").amount("1.00");
consentRequest.getData().getInitiation().getCreditorPostalAddress().country("GB").addressLine(Collections.singletonList("3 Queens Square"));
consentRequest.getData().getInitiation().supplementaryData(null);
consentRequest.getRisk().merchantCategoryCode("ABCD").getDeliveryAddress().addressLine(Collections.singletonList("3 Queens Square")).country("GP").countrySubDivision("aaa");
consentRequest.getData().getAuthorisation().completionDateTime(null);
FRDomesticConsent existingConsent = JMockData.mock(FRDomesticConsent.class);
existingConsent.setId(UUID.randomUUID().toString());
existingConsent.setStatus(ConsentStatusCode.AUTHORISED);
existingConsent.setDomesticConsent(toFRWriteDomesticConsent(consentRequest));
existingConsent.setIdempotencyKey(idempotencyKey);
repository.save(existingConsent);
// When
HttpResponse<OBWriteDomesticConsentResponse2> response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payment-consents/").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, idempotencyKey).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(consentRequest).asObject(OBWriteDomesticConsentResponse2.class);
// Then
assertThat(response.getStatus()).isEqualTo(201);
OBWriteDomesticConsentResponse2 consentResponse = response.getBody();
FRDomesticConsent consent = repository.findById(consentResponse.getData().getConsentId()).get();
assertThat(consent.getId()).isEqualTo(consentResponse.getData().getConsentId());
assertThat(toOBDomestic2(consent.getInitiation())).isEqualTo(consentResponse.getData().getInitiation());
assertThat(consent.getStatus().toOBExternalConsentStatus1Code()).isEqualTo(consentResponse.getData().getStatus());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method testCreateDomesticPaymentSubmission.
@Test
public void testCreateDomesticPaymentSubmission() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent();
OBWriteDomestic2 submissionRequest = new OBWriteDomestic2().risk(toOBRisk1(consent.getRisk())).data(new OBWriteDataDomestic2().consentId(consent.getId()).initiation(toOBDomestic2(consent.getInitiation())));
// When
HttpResponse<OBWriteDomesticResponse2> response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payments").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, "x-idempotency-key").header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(submissionRequest).asObject(OBWriteDomesticResponse2.class);
// Then
assertThat(response.getStatus()).isEqualTo(201);
OBWriteDomesticResponse2 consentResponse = response.getBody();
FRDomesticPaymentSubmission submission = submissionRepository.findById(response.getBody().getData().getDomesticPaymentId()).get();
assertThat(submission.getId()).isEqualTo(consentResponse.getData().getConsentId());
assertThat(toOBWriteDomestic2(submission.getDomesticPayment())).isEqualTo(submissionRequest);
assertThat(submission.getObVersion()).isEqualTo(OBVersion.v3_1);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method saveConsent.
private FRDomesticConsent saveConsent() {
FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
consent.setId(IntentType.PAYMENT_DOMESTIC_CONSENT.generateIntentId());
consent.getInitiation().setInstructedAmount(aValidFRAmount());
consent.getInitiation().setCreditorPostalAddress(aValidFRPostalAddress());
consent.getInitiation().setSupplementaryData(FRSupplementaryData.builder().data("{}").build());
consent.getRisk().setMerchantCategoryCode(aValidFRRisk().getMerchantCategoryCode());
consent.getRisk().setDeliveryAddress(aValidFRRisk().getDeliveryAddress());
consent.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
consentRepository.save(consent);
return consent;
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method testDuplicatePaymentInitiation_validIdempotency_ShouldReturnCreated.
@Test
public void testDuplicatePaymentInitiation_validIdempotency_ShouldReturnCreated() throws Exception {
// Given
final String idempotencyKey = UUID.randomUUID().toString();
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent();
FRDomesticPaymentSubmission submission = savePaymentSubmission(consent, idempotencyKey);
OBWriteDomestic2 obWriteDomestic1 = toOBWriteDomestic2(submission.getDomesticPayment());
// When
HttpResponse<String> response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.0/pisp/domestic-payments").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, idempotencyKey).header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(obWriteDomestic1).asObject(String.class);
log.debug("Response: {} , {}", response.getStatus(), response.getBody());
// Then
assertThat(response.getStatus()).isEqualTo(201);
}
Aggregations