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:
Simon Redfern 2016-08-02 08:28:05 +02:00 committed by GitHub
commit aa8cde5ff4
3 changed files with 22 additions and 2 deletions

View File

@ -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:

View File

@ -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))
}
}
}

View File

@ -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) }
}