Search in sources :

Example 1 with FRAccountRequest

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));
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest)

Example 2 with FRAccountRequest

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));
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest)

Example 3 with FRAccountRequest

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

Example 4 with FRAccountRequest

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();
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest) Test(org.junit.Test)

Example 5 with FRAccountRequest

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();
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest) Tpp(com.forgerock.openbanking.model.Tpp) X509Authentication(com.forgerock.spring.security.multiauth.model.authentication.X509Authentication) Authentication(org.springframework.security.core.Authentication) X509Authentication(com.forgerock.spring.security.multiauth.model.authentication.X509Authentication) Test(org.junit.Test)

Aggregations

FRAccountRequest (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest)16 Test (org.junit.Test)6 Tpp (com.forgerock.openbanking.model.Tpp)4 OBErrorException (com.forgerock.openbanking.exceptions.OBErrorException)3 X509Authentication (com.forgerock.spring.security.multiauth.model.authentication.X509Authentication)3 Authentication (org.springframework.security.core.Authentication)3 ConsentStatusEntry (com.forgerock.openbanking.analytics.model.entries.ConsentStatusEntry)2 FRReadResponseConverter.toOBReadResponse1 (com.forgerock.openbanking.common.services.openbanking.converter.account.FRReadResponseConverter.toOBReadResponse1)1 URI (java.net.URI)1 Optional (java.util.Optional)1 ParameterizedTypeReference (org.springframework.core.ParameterizedTypeReference)1 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)1 OBReadDataResponse1 (uk.org.openbanking.datamodel.account.OBReadDataResponse1)1 OBReadResponse1 (uk.org.openbanking.datamodel.account.OBReadResponse1)1