use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.PaymentConsent in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentsRequestPaymentIdEndpointWrapperTest method verifyAccessUsing_GrantTypeWrong.
@Test
public void verifyAccessUsing_GrantTypeWrong() throws Exception {
// given
PaymentConsent payment = FRDomesticConsent.builder().status(ConsentStatusCode.AUTHORISED).build();
String jws = jws("payments", OIDCConstants.GrantType.AUTHORIZATION_CODE);
wrapper.authorization("Bearer " + jws);
when(amResourceServerService.verifyAccessToken("Bearer " + jws)).thenReturn((SignedJWT) JWTParser.parse(jws));
// then
// When
OBErrorException obErrorException = catchThrowableOfType(() -> wrapper.payment(payment).applyFilters(), OBErrorException.class);
assertThat(obErrorException.getObriErrorType().getHttpStatus().value()).isEqualTo(403);
assertThat(obErrorException.getOBError().getErrorCode()).isEqualTo(ErrorCode.OBRI_ACCESS_TOKEN_INVALID.getValue());
assertThat(obErrorException.getMessage()).isEqualTo("The access token grant type AUTHORIZATION_CODE doesn't match one of the expected grant types [CLIENT_CREDENTIAL]");
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.PaymentConsent in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentsRequestPaymentIdEndpointWrapperTest method verifyAccessToken.
@Test
public void verifyAccessToken() throws Exception {
// given
PaymentConsent payment = FRDomesticConsent.builder().status(ConsentStatusCode.AUTHORISED).build();
String jws = jws("payments", OIDCConstants.GrantType.CLIENT_CREDENTIAL);
wrapper.authorization("Bearer " + jws);
when(amResourceServerService.verifyAccessToken("Bearer " + jws)).thenReturn((SignedJWT) JWTParser.parse(jws));
// then
assertThatCode(() -> {
wrapper.payment(payment).verifyAccessToken(Arrays.asList("payments"), Arrays.asList(OIDCConstants.GrantType.CLIENT_CREDENTIAL));
}).doesNotThrowAnyException();
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.PaymentConsent in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentsSubmissionEndpointWrapperTest method verifyPaymentStatus_notConsented.
@Test
public void verifyPaymentStatus_notConsented() throws Exception {
// given
PaymentConsent payment = FRDomesticConsent.builder().status(ConsentStatusCode.ACCEPTEDTECHNICALVALIDATION).build();
// When
OBErrorException obErrorException = catchThrowableOfType(() -> wrapper.payment(payment).verifyPaymentStatus(), OBErrorException.class);
assertThat(obErrorException.getObriErrorType().getHttpStatus().value()).isEqualTo(406);
assertThat(obErrorException.getMessage()).isEqualTo("Payment invalid. Payment request hasn't been authorised by the PSU yet. Payment request status: 'ACCEPTEDTECHNICALVALIDATION'");
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.PaymentConsent in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentsSubmissionEndpointWrapperTest method verifyPaymentStatus_complete.
@Test
public void verifyPaymentStatus_complete() throws Exception {
// given
PaymentConsent payment = FRDomesticConsent.builder().status(ConsentStatusCode.AUTHORISED).build();
// then
assertThatCode(() -> {
wrapper.payment(payment).verifyPaymentStatus();
}).doesNotThrowAnyException();
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.PaymentConsent in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentsSubmissionEndpointWrapperTest method verifyAccessUsing_GrantTypeWrong.
@Test
public void verifyAccessUsing_GrantTypeWrong() throws Exception {
// given
PaymentConsent payment = FRDomesticConsent.builder().status(ConsentStatusCode.AUTHORISED).build();
String jws = jws("payments", OIDCConstants.GrantType.CLIENT_CREDENTIAL);
wrapper.authorization("Bearer " + jws);
// mock handled stubbed
when(amResourceServerService.verifyAccessToken("Bearer " + jws)).thenReturn((SignedJWT) JWTParser.parse(jws));
// then
// When
OBErrorException obErrorException = catchThrowableOfType(() -> wrapper.payment(payment).applyFilters(), OBErrorException.class);
assertThat(obErrorException.getObriErrorType().getHttpStatus().value()).isEqualTo(403);
assertThat(obErrorException.getOBError().getErrorCode()).isEqualTo(ErrorCode.OBRI_ACCESS_TOKEN_INVALID.getValue());
assertThat(obErrorException.getMessage()).isEqualTo("The access token grant type CLIENT_CREDENTIAL doesn't match one of the expected grant types [AUTHORIZATION_CODE, HEADLESS_AUTH]");
}
Aggregations