Search in sources :

Example 51 with OBErrorException

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) PasswordLessUserNameAuthentication(com.forgerock.spring.security.multiauth.model.authentication.PasswordLessUserNameAuthentication) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) UUID(java.util.UUID) Before(org.junit.Before)

Example 52 with OBErrorException

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'");
}
Also used : PaymentConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.PaymentConsent) OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) Test(org.junit.Test)

Example 53 with OBErrorException

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();
}
Also used : OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) Test(org.junit.Test)

Example 54 with OBErrorException

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");
}
Also used : OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) Test(org.junit.Test)

Example 55 with OBErrorException

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'");
}
Also used : OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) Test(org.junit.Test)

Aggregations

OBErrorException (com.forgerock.openbanking.exceptions.OBErrorException)69 Test (org.junit.Test)20 ParseException (java.text.ParseException)19 IOException (java.io.IOException)13 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)9 SignedJWT (com.nimbusds.jwt.SignedJWT)9 ResponseEntity (org.springframework.http.ResponseEntity)9 InvalidTokenException (com.forgerock.openbanking.jwt.exceptions.InvalidTokenException)8 Tpp (com.forgerock.openbanking.model.Tpp)8 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)6 PaymentConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.PaymentConsent)5 List (java.util.List)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 AccountRequest (com.forgerock.openbanking.common.model.openbanking.persistence.account.AccountRequest)4 OIDCConstants (com.forgerock.openbanking.constants.OIDCConstants)4 JWTClaimsSet (com.nimbusds.jwt.JWTClaimsSet)4 PermissionDenyException (com.forgerock.openbanking.common.error.exception.PermissionDenyException)3 OAuth2BearerTokenUsageInvalidTokenException (com.forgerock.openbanking.common.error.exception.oauth2.OAuth2BearerTokenUsageInvalidTokenException)3 OAuth2InvalidClientException (com.forgerock.openbanking.common.error.exception.oauth2.OAuth2InvalidClientException)3