mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 16:56:56 +00:00
Merge pull request #118 from marko-md/develop
Closes #107 #106 #108 #107 - Need internal guard on Internal (Kafka) getBankAccountt Set of Requeted IDs must match the set of Returned IDs
This commit is contained in:
commit
aa8cde5ff4
@ -106,6 +106,10 @@ object ErrorMessages {
|
||||
val InvalidAccountType = "OBP-30108: Invalid Account Type."
|
||||
val InitialBalanceMustBeZero = "OBP-30109: Initial Balance of Account must be Zero (0)."
|
||||
|
||||
val InvalidGetBankAccountsConnectorResponse = "OBP-30201: Connector did not return the set of accounts we requested."
|
||||
val InvalidGetBankAccountConnectorResponse = "OBP-30202: Connector did not return the account we requested."
|
||||
val InvalidGetTransactionConnectorResponse = "OBP-30203: Connector did not return the transaction we requested."
|
||||
|
||||
|
||||
|
||||
// Transaction related messages:
|
||||
|
||||
@ -234,8 +234,11 @@ trait APIMethods200 {
|
||||
//get public accounts for all banks
|
||||
case "accounts" :: "public" :: Nil JsonGet json => {
|
||||
user =>
|
||||
val publicAccountsJson = bankAccountBasicListToJson(BankAccount.publicAccounts, Empty)
|
||||
Full(successJsonResponse(publicAccountsJson))
|
||||
for {
|
||||
publicAccountsJson <- tryo{bankAccountBasicListToJson(BankAccount.publicAccounts, Empty)} ?~ "Could not get accounts."
|
||||
} yield {
|
||||
Full(successJsonResponse(publicAccountsJson))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -224,6 +224,8 @@ object KafkaMappedConnector extends Connector with CreateViewImpls with Loggable
|
||||
// Since result is single account, we need only first list entry
|
||||
implicit val formats = net.liftweb.json.DefaultFormats
|
||||
val r = process(reqId, "getTransaction", argList).extract[KafkaInboundTransaction]
|
||||
// Check does the response data match the requested data
|
||||
if (transactionId.value != r.id) throw new Exception(ErrorMessages.InvalidGetTransactionConnectorResponse)
|
||||
createNewTransaction(r)
|
||||
}
|
||||
|
||||
@ -274,6 +276,11 @@ object KafkaMappedConnector extends Connector with CreateViewImpls with Loggable
|
||||
val r = {
|
||||
cachedAccount.getOrElseUpdate( argList.toString, () => process(reqId, "getBankAccount", argList).extract[KafkaInboundAccount])
|
||||
}
|
||||
// Check does the response data match the requested data
|
||||
val accResp = List((BankId(r.bank), AccountId(r.id))).toSet
|
||||
val acc = List((bankId, accountID)).toSet
|
||||
if ((accResp diff acc).size > 0) throw new Exception(ErrorMessages.InvalidGetBankAccountConnectorResponse)
|
||||
|
||||
Full(new KafkaBankAccount(r))
|
||||
}
|
||||
|
||||
@ -290,6 +297,12 @@ object KafkaMappedConnector extends Connector with CreateViewImpls with Loggable
|
||||
val r = {
|
||||
cachedAccounts.getOrElseUpdate( argList.toString, () => process(reqId, "getBankAccounts", argList).extract[List[KafkaInboundAccount]])
|
||||
}
|
||||
// Check does the response data match the requested data
|
||||
val accRes = for(row <- r) yield {
|
||||
(BankId(row.bank), AccountId(row.id))
|
||||
}
|
||||
if ((accRes.toSet diff accts.toSet).size > 0) throw new Exception(ErrorMessages.InvalidGetBankAccountsConnectorResponse)
|
||||
|
||||
r.map { t => new KafkaBankAccount(t) }
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user