use of com.forgerock.openbanking.exceptions.OBErrorException in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentsSubmissionEndpointWrapperTest method setup.
@Before
public void setup() {
// setting required objects to the perform test
UUID uuid = UUID.randomUUID();
// create required object to initialise the wrapper properly
RSEndpointWrapperService rsEndpointWrapperService = new RSEndpointWrapperService(obHeaderCheckerService, cryptoApiClient, null, null, rsConfiguration, null, null, false, null, rsConfiguration.financialId, amOpenBankingConfiguration, null, null, null, amResourceServerService, null, null, null, null);
wrapper = new PaymentsSubmissionsEndpointWrapper(rsEndpointWrapperService, tppStoreService) {
@Override
protected ResponseEntity run(PaymentRestEndpointContent main) throws OBErrorException {
return super.run(main);
}
};
wrapper.principal(new PasswordLessUserNameAuthentication("test-tpp", Collections.EMPTY_LIST));
wrapper.xFapiFinancialId(uuid.toString());
// generic mock handled stubb
when(obHeaderCheckerService.verifyFinancialIdHeader(uuid.toString())).thenReturn(true);
}
use of com.forgerock.openbanking.exceptions.OBErrorException in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentsSubmissionEndpointWrapperTest method verifyPaymentStatus_rejected.
@Test
public void verifyPaymentStatus_rejected() throws Exception {
// given
PaymentConsent payment = FRDomesticConsent.builder().status(ConsentStatusCode.REJECTED).build();
// When
OBErrorException obErrorException = catchThrowableOfType(() -> wrapper.payment(payment).verifyPaymentStatus(), OBErrorException.class);
assertThat(obErrorException.getObriErrorType().getHttpStatus().value()).isEqualTo(401);
assertThat(obErrorException.getMessage()).isEqualTo("Payment invalid. Payment has been rejected. Payment request status: 'REJECTED'");
}
use of com.forgerock.openbanking.exceptions.OBErrorException in project openbanking-aspsp by OpenBankingToolkit.
the class RSEndpointWrapperTest method shouldMatch_verifyMatcherVersion.
@Test
public void shouldMatch_verifyMatcherVersion() {
// Given
String value = "https://tpp.callbackurl.com/v3.1.2/event-notifications";
String valueToCompare = "3.1.2";
OBErrorException exception = catchThrowableOfType(() -> testRSEndpointWrapper.verifyMatcherVersion(value, valueToCompare), OBErrorException.class);
;
// Then
assertThat(exception).isNull();
}
use of com.forgerock.openbanking.exceptions.OBErrorException in project openbanking-aspsp by OpenBankingToolkit.
the class RSEndpointWrapperTest method shouldFailToVerifyIdempotencyKeyGivenInvalidKey.
@Test
public void shouldFailToVerifyIdempotencyKeyGivenInvalidKey() {
// Given
String xIdempotencyKey = "";
// When
OBErrorException exception = catchThrowableOfType(() -> testRSEndpointWrapper.verifyIdempotencyKeyLength(xIdempotencyKey), OBErrorException.class);
// Then
assertThat(exception).hasMessage("Invalid Idempotency Key provided in header. The x-idempotency-key in the request headers must be between 1 and 40 characters. Provided value: '' has length: 0");
}
use of com.forgerock.openbanking.exceptions.OBErrorException in project openbanking-aspsp by OpenBankingToolkit.
the class RSEndpointWrapperTest method shouldFailMatch_verifyMatcherVersion.
@Test
public void shouldFailMatch_verifyMatcherVersion() {
// Given
String value = "https://tpp.callbackurl.com/v3.1.2/event-notifications";
String valueToCompare = "3.1.3";
OBErrorException exception = catchThrowableOfType(() -> testRSEndpointWrapper.verifyMatcherVersion(value, valueToCompare), OBErrorException.class);
;
// Then
assertThat(exception).hasMessage("The object received is invalid. Reason 'Version on the callback url field https://tpp.callbackurl.com/v3.1.2/event-notifications doesn't match with the version value field 3.1.3'");
}
Aggregations