use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.
the class TransactionsApiControllerIT method mockAccountPermissions.
private void mockAccountPermissions(List<FRExternalPermissionsCode> permissions) {
FRAccountRequest value = new FRAccountRequest();
value.setAisp(tpp);
value.setAccountIds(Collections.singletonList("100000123"));
value.setAccountRequest(FRReadResponse.builder().data(FRReadDataResponse.builder().permissions(permissions).transactionFromDateTime(CONSENT_FROM).transactionToDateTime(CONSENT_TO).status(FRExternalRequestStatusCode.AUTHORISED).build()).build());
given(accountRequestStore.get(any())).willReturn(Optional.of(value));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.
the class TransactionsApiControllerIT method mockAccountPermissions.
private void mockAccountPermissions(List<FRExternalPermissionsCode> permissions) {
FRAccountRequest value = new FRAccountRequest();
value.setAisp(tpp);
value.setAccountIds(Collections.singletonList("100000123"));
value.setAccountRequest(FRReadResponse.builder().data(FRReadDataResponse.builder().permissions(permissions).transactionFromDateTime(CONSENT_FROM).transactionToDateTime(CONSENT_TO).status(FRExternalRequestStatusCode.AUTHORISED).build()).build());
given(accountRequestStore.get(any())).willReturn(Optional.of(value));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiEndpointWrapperTest method verifyAccountId_noMatch.
@Test
public void verifyAccountId_noMatch() throws Exception {
// Given
wrapper.accountRequest = new FRAccountRequest();
wrapper.accountRequest.setAccountIds(Collections.singletonList("differentAccount123"));
wrapper.accountId("12345");
// When
OBErrorException obErrorException = catchThrowableOfType(() -> wrapper.verifyAccountId(), OBErrorException.class);
// Then
assertThat(obErrorException.getMessage()).isEqualTo("You are not authorised to access account '12345'. The account request 'null' only authorised the following accounts: '[differentAccount123]'");
assertThat(obErrorException.getOBError().getErrorCode()).isEqualTo(OBStandardErrorCodes1.UK_OBIE_FIELD_INVALID.getValue());
assertThat(obErrorException.getObriErrorType().getHttpStatus().value()).isEqualTo(400);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiEndpointWrapperTest method verifyAccountId_null_noException.
@Test
public void verifyAccountId_null_noException() throws Exception {
// Given
wrapper.accountRequest = new FRAccountRequest();
wrapper.accountRequest.setAccountIds(Collections.singletonList("12345"));
// Then
assertThatCode(() -> {
wrapper.accountId(null).verifyAccountId();
}).doesNotThrowAnyException();
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiEndpointWrapperTest method testMatls_success.
@Test
public void testMatls_success() {
// Given
String authorisatioNumber = "PSDGB-OB-2345343";
String clientId = "clientId";
FRAccountRequest accountRequest = new FRAccountRequest();
accountRequest.setClientId(clientId);
wrapper.accountRequest = accountRequest;
Collection<? extends GrantedAuthority> authorities = Collections.emptyList();
Authentication authentication = new X509Authentication(authorisatioNumber, authorities, null);
wrapper.principal = authentication;
Tpp tpp = new Tpp();
tpp.setAuthorisationNumber(authorisatioNumber);
given(this.tppStoreService.findByClientId(clientId)).willReturn(Optional.of(tpp));
// Then
assertThatCode(() -> wrapper.verifyMatlsFromAccountRequest()).doesNotThrowAnyException();
}
Aggregations