mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 13:07:02 +00:00
feature/create endpoint get currencies and tweak system integrity currency check
This commit is contained in:
parent
16b89b672e
commit
357854ae32
@ -225,7 +225,7 @@ trait APIMethods510 {
|
||||
implementedInApiVersion,
|
||||
nameOf(accountCurrencyCheck),
|
||||
"GET",
|
||||
"/management/system/integrity/account-currency-check",
|
||||
"/management/system/integrity/banks/BANK_ID/account-currency-check",
|
||||
"Check for Sensible Currencies",
|
||||
s"""Check for sensible currencies at Bank Account model
|
||||
|
|
||||
@ -243,15 +243,15 @@ trait APIMethods510 {
|
||||
)
|
||||
|
||||
lazy val accountCurrencyCheck: OBPEndpoint = {
|
||||
case "management" :: "system" :: "integrity" :: "account-currency-check" :: Nil JsonGet _ => {
|
||||
case "management" :: "system" :: "integrity" :: "banks" :: BankId(bankId) :: "account-currency-check" :: Nil JsonGet _ => {
|
||||
cc =>
|
||||
for {
|
||||
currenciess: List[String] <- Future {
|
||||
currencies: List[String] <- Future {
|
||||
MappedBankAccount.findAll().map(_.accountCurrency.get).distinct
|
||||
}
|
||||
currentCurrencies: List[String] <- Future { CurrencyUtil.getCurrencyCodes() }
|
||||
(bankCurrencies, callContext) <- NewStyle.function.getCurrentCurrencies(bankId, cc.callContext)
|
||||
} yield {
|
||||
(JSONFactory510.getSensibleCurrenciesCheck(currenciess, currentCurrencies), HttpCode.`200`(cc.callContext))
|
||||
(JSONFactory510.getSensibleCurrenciesCheck(bankCurrencies, currencies), HttpCode.`200`(callContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,8 +93,8 @@ object JSONFactory510 {
|
||||
debug_info = debugInfo
|
||||
)
|
||||
}
|
||||
def getSensibleCurrenciesCheck(currencies: List[String], currentCurrencies: List[String]): CheckSystemIntegrityJsonV510 = {
|
||||
val incorrectCurrencies: List[String] = currencies.filterNot(c => currentCurrencies.contains(c))
|
||||
def getSensibleCurrenciesCheck(bankCurrencies: List[String], accountCurrencies: List[String]): CheckSystemIntegrityJsonV510 = {
|
||||
val incorrectCurrencies: List[String] = bankCurrencies.filterNot(c => accountCurrencies.contains(c))
|
||||
val success = incorrectCurrencies.size == 0
|
||||
val debugInfo = if(success) None else Some(s"Incorrect currencies: ${incorrectCurrencies.mkString(",")}")
|
||||
CheckSystemIntegrityJsonV510(
|
||||
|
||||
@ -134,7 +134,7 @@ class SystemIntegrityTest extends V510ServerSetup {
|
||||
feature(s"test $ApiEndpoint4 version $VersionOfApi - Unauthorized access") {
|
||||
scenario("We will call the endpoint without user credentials", ApiEndpoint1, VersionOfApi) {
|
||||
When("We make a request v5.1.0")
|
||||
val request510 = (v5_1_0_Request / "management" / "system" / "integrity" / "account-currency-check").GET
|
||||
val request510 = (v5_1_0_Request / "management" / "system" / "integrity" / "banks" / testBankId1.value / "account-currency-check").GET
|
||||
val response510 = makeGetRequest(request510)
|
||||
Then("We should get a 401")
|
||||
response510.code should equal(401)
|
||||
@ -145,7 +145,7 @@ class SystemIntegrityTest extends V510ServerSetup {
|
||||
feature(s"test $ApiEndpoint4 version $VersionOfApi - Authorized access") {
|
||||
scenario("We will call the endpoint with user credentials but without a proper entitlement", ApiEndpoint1, VersionOfApi) {
|
||||
When("We make a request v5.1.0")
|
||||
val request510 = (v5_1_0_Request / "management" / "system" / "integrity" / "account-currency-check").GET <@(user1)
|
||||
val request510 = (v5_1_0_Request / "management" / "system" / "integrity" / "banks" / testBankId1.value / "account-currency-check").GET <@(user1)
|
||||
val response510 = makeGetRequest(request510)
|
||||
Then("error should be " + UserHasMissingRoles + CanGetSystemIntegrity)
|
||||
response510.code should equal(403)
|
||||
@ -157,7 +157,7 @@ class SystemIntegrityTest extends V510ServerSetup {
|
||||
scenario("We will call the endpoint with user credentials and a proper entitlement", ApiEndpoint1, VersionOfApi) {
|
||||
Entitlement.entitlement.vend.addEntitlement("", resourceUser1.userId, CanGetSystemIntegrity.toString)
|
||||
When("We make a request v5.1.0")
|
||||
val request510 = (v5_1_0_Request / "management" / "system" / "integrity" / "account-currency-check").GET <@(user1)
|
||||
val request510 = (v5_1_0_Request / "management" / "system" / "integrity" / "banks" / testBankId1.value / "account-currency-check").GET <@(user1)
|
||||
val response510 = makeGetRequest(request510)
|
||||
Then("We get successful response")
|
||||
response510.code should equal(200)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user