use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptSinglePaymentTaskTest method shouldRejectPaymentWhenCurrencyConversionException.
@Test
public void shouldRejectPaymentWhenCurrencyConversionException() throws CurrencyConverterException {
// Given
FRPaymentSetup payment = defaultPayment();
given(paymentsService.getAllPaymentsInProcess()).willReturn(Collections.singleton(payment));
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(account);
doThrow(CurrencyConverterException.class).when(moneyService).moveMoney(any(), any(), any(), any(), any());
// When
autoAcceptPaymentTask.autoAcceptPayment();
// Then
FRAmount instructedAmount = payment.getInitiation().getInstructedAmount();
verify(moneyService).moveMoney(eq(account), eq(instructedAmount), eq(FRCreditDebitIndicator.DEBIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.REJECTED)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiController method getAccount.
public ResponseEntity<OBReadAccount3> getAccount(@ApiParam(value = "A unique identifier used to identify the account resource.", required = true) @PathVariable("AccountId") String accountId, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The time when the PSU last logged in with the TPP. All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below: Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
log.info("Read account {} with permission {}", accountId, permissions);
FRAccount response = frAccountRepository.byAccountId(accountId, toFRExternalPermissionsCodeList(permissions));
final List<OBAccount3> obAccounts = Collections.singletonList(toOBAccount3(response.getAccount()));
return ResponseEntity.ok(new OBReadAccount3().data(new OBReadAccount3Data().account(obAccounts)).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(PaginationUtil.generateMetaData(1)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class AccountsApiController method getAccount.
@Override
public ResponseEntity<OBReadAccount5> getAccount(String accountId, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, List<OBExternalPermissions1Code> permissions, String httpUrl) throws OBErrorResponseException {
log.info("Read account {} with permission {}", accountId, permissions);
FRAccount response = frAccountRepository.byAccountId(accountId, toFRExternalPermissionsCodeList(permissions));
List<OBAccount6> obAccounts = Collections.singletonList(toOBAccount6(response.getAccount()));
return ResponseEntity.ok(new OBReadAccount5().data(new OBReadAccount5Data().account(obAccounts)).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(PaginationUtil.generateMetaData(1)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class Accounts3ApiControllerIT method testGetAnAccount.
@Test
public void testGetAnAccount() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_AISP);
FRAccount account = JMockData.mock(FRAccount.class);
frAccountRepository.save(account);
// When
HttpResponse<OBReadAccount3> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1.1/aisp/accounts/" + account.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header("x-ob-url", "http://localhost").header("x-ob-permissions", OBExternalPermissions1Code.READACCOUNTSDETAIL.name() + "," + OBExternalPermissions1Code.READPAN.name()).asObject(OBReadAccount3.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
OBAccount3 returnedAccount = response.getBody().getData().getAccount().get(0);
assertThat(returnedAccount).isNotNull();
assertThat(returnedAccount.getAccountId()).isEqualTo(account.getAccount().getAccountId());
assertThat(returnedAccount.getCurrency()).isEqualTo(account.getAccount().getCurrency());
assertThat(returnedAccount.getAccountType()).isEqualTo(toOBExternalAccountType1Code(account.getAccount().getAccountType()));
assertThat(returnedAccount.getAccountSubType()).isEqualTo(toOBExternalAccountSubType1Code(account.getAccount().getAccountSubType()));
assertThat(returnedAccount.getDescription()).isEqualTo(account.getAccount().getDescription());
assertThat(returnedAccount.getNickname()).isEqualTo(account.getAccount().getNickname());
assertThat(returnedAccount.getServicer().getSchemeName()).isEqualTo(account.getAccount().getServicer().getSchemeName());
assertThat(returnedAccount.getServicer().getIdentification()).isEqualTo(account.getAccount().getServicer().getIdentification());
assertThat(returnedAccount.getAccount().get(0).getIdentification()).isEqualTo(account.getAccount().getAccounts().get(0).getIdentification());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount in project openbanking-aspsp by OpenBankingToolkit.
the class DataApiControllerIT method shouldCreateNewDataUsingUpdate.
@Test
public void shouldCreateNewDataUsingUpdate() throws Exception {
// Given
OBAccount6 account = new OBAccount6().accountId(UUID.randomUUID().toString());
List<FRAccountData> accountDatas = Collections.singletonList(FRAccountData.builder().account(account).balances(Collections.singletonList(new OBCashBalance1())).build());
FRAccount savedAccount = frAccountRepository.save(FRAccount.builder().id(account.getAccountId()).userID(UUID.randomUUID().toString()).build());
FRUserData userData = new FRUserData();
userData.setAccountDatas(accountDatas);
userData.setUserName(savedAccount.getUserID());
// When
mockMvc.perform(put("/api/data/user").content(mapper.writeValueAsString(userData)).contentType("application/json")).andExpect(status().isOk());
}
Aggregations