Search in sources :

Example 11 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 12 with FRAccountRequest

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.

the class InfoApiControllerIT method mockAccountPermissions.

private void mockAccountPermissions(List<FRExternalPermissionsCode> permissions) {
    FRAccountRequest value = new FRAccountRequest();
    Tpp tpp = new Tpp();
    tpp.setClientId("test-tpp");
    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) Tpp(com.forgerock.openbanking.model.Tpp)

Example 13 with FRAccountRequest

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.

the class AccountsApiEndpointWrapperTest method testMatls_failMatlsCheck.

@Test
public void testMatls_failMatlsCheck() {
    // 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("PSDGB-OB-45434324");
    given(this.tppStoreService.findByClientId(clientId)).willReturn(Optional.of(tpp));
    // Then
    OBErrorException exception = catchThrowableOfType(() -> wrapper.verifyMatlsFromAccountRequest(), OBErrorException.class);
    assertThat(exception.getObriErrorType()).isEqualTo(MATLS_TPP_AUTHENTICATION_INVALID_FROM_ACCOUNT_REQUEST);
}
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) OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) X509Authentication(com.forgerock.spring.security.multiauth.model.authentication.X509Authentication) Test(org.junit.Test)

Example 14 with FRAccountRequest

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.

the class AccountsApiEndpointWrapperTest method testMatls_failOauth2RegistrationDeleted.

@Test
public void testMatls_failOauth2RegistrationDeleted() {
    // 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;
    given(this.tppStoreService.findByClientId(clientId)).willReturn(Optional.empty());
    // Then
    OBErrorException exception = catchThrowableOfType(() -> wrapper.verifyMatlsFromAccountRequest(), OBErrorException.class);
    assertThat(exception.getObriErrorType()).isEqualTo(MATLS_TPP_AUTHENTICATION_INVALID_FROM_ACCOUNT_REQUEST);
}
Also used : FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest) X509Authentication(com.forgerock.spring.security.multiauth.model.authentication.X509Authentication) Authentication(org.springframework.security.core.Authentication) OBErrorException(com.forgerock.openbanking.exceptions.OBErrorException) X509Authentication(com.forgerock.spring.security.multiauth.model.authentication.X509Authentication) Test(org.junit.Test)

Example 15 with FRAccountRequest

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest in project openbanking-aspsp by OpenBankingToolkit.

the class AccountRequestStoreServiceImpl method getAccountRequest.

private Optional<FRAccountRequest> getAccountRequest(String accountRequestId) {
    ParameterizedTypeReference<Optional<FRAccountRequest>> ptr = new ParameterizedTypeReference<Optional<FRAccountRequest>>() {
    };
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(rsStoreRoot + "/api/account-requests/" + accountRequestId);
    URI uri = builder.build().encode().toUri();
    return restTemplate.exchange(uri, HttpMethod.GET, null, ptr).getBody();
}
Also used : Optional(java.util.Optional) FRAccountRequest(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccountRequest) ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) URI(java.net.URI)

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