From ebfba1eb0579e4cca235a4122d05469e15f0c5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Wed, 16 Jan 2019 05:27:48 +0100 Subject: [PATCH 1/3] Improved Json response in case of an error message --- src/main/scala/bootstrap/liftweb/Boot.scala | 4 +- .../scala/code/api/ErrorMessageJsonAST.scala | 66 ++-- .../SwaggerDefinitionsJSON.scala | 3 +- src/main/scala/code/api/util/APIUtil.scala | 6 +- .../scala/code/api/v1_2/JSONFactory1.2.scala | 7 +- .../code/api/v1_2_1/JSONFactory1.2.1.scala | 4 +- src/test/scala/code/api/directloginTest.scala | 9 +- .../scala/code/api/v1_2_1/API1_2_1Test.scala | 320 +++++++++--------- .../scala/code/api/v1_4_0/CustomerTest.scala | 4 +- .../scala/code/api/v2_0_0/AccountTest.scala | 2 +- .../scala/code/api/v2_0_0/CustomerTest.scala | 4 +- .../code/api/v2_0_0/EntitlementTests.scala | 6 +- .../api/v2_0_0/TransactionRequestsTest.scala | 4 +- .../v2_1_0/CreateTransactionTypeTest.scala | 6 +- .../scala/code/api/v2_1_0/CustomerTest.scala | 4 +- .../code/api/v2_1_0/EntitlementTests.scala | 6 +- .../api/v2_1_0/TransactionRequestsTest.scala | 14 +- .../UpdateConsumerRedirectUrlTest.scala | 4 +- .../scala/code/api/v2_1_0/UserTests.scala | 4 +- .../scala/code/api/v2_2_0/API2_2_0Test.scala | 20 +- .../api/v2_2_0/CreateCounterpartyTest.scala | 9 +- .../scala/code/api/v3_0_0/AccountTest.scala | 2 +- .../scala/code/api/v3_0_0/BranchesTest.scala | 2 +- .../code/api/v3_0_0/TransactionsTest.scala | 18 +- src/test/scala/code/api/v3_0_0/UserTest.scala | 12 +- .../scala/code/api/v3_0_0/ViewsTests.scala | 20 +- .../scala/code/api/v3_0_0/WarehouseTest.scala | 2 +- .../code/api/v3_0_0/WarehouseTestAsync.scala | 2 +- .../scala/code/api/v3_1_0/ConsumerTest.scala | 2 +- .../code/api/v3_1_0/CustomerAddressTest.scala | 14 +- .../scala/code/api/v3_1_0/CustomerTest.scala | 14 +- .../code/api/v3_1_0/FundsAvailableTest.scala | 14 +- .../code/api/v3_1_0/GetAdapterInfoTest.scala | 2 +- .../scala/code/api/v3_1_0/RateLimitTest.scala | 8 +- .../code/api/v3_1_0/RefreshObpDateTest.scala | 2 +- .../code/api/v3_1_0/TaxResidenceTest.scala | 18 +- .../api/v3_1_0/TransactionRequestTest.scala | 2 +- .../code/api/v3_1_0/TransactionTest.scala | 2 +- .../code/api/v3_1_0/UserAuthContextTest.scala | 16 +- .../scala/code/api/v3_1_0/WebhooksTest.scala | 12 +- 40 files changed, 333 insertions(+), 337 deletions(-) diff --git a/src/main/scala/bootstrap/liftweb/Boot.scala b/src/main/scala/bootstrap/liftweb/Boot.scala index 2228e0fb0..c0704a401 100644 --- a/src/main/scala/bootstrap/liftweb/Boot.scala +++ b/src/main/scala/bootstrap/liftweb/Boot.scala @@ -444,7 +444,7 @@ class Boot extends MdcLoggable { case(Props.RunModes.Development, r, e) => { logger.error("Exception being returned to browser when processing " + r.uri.toString, e) JsonResponse( - Extraction.decompose(ErrorMessage(s"${ErrorMessages.InternalServerError} ${showExceptionAtJson(e)}")), + Extraction.decompose(ErrorMessage(code = 500, message = s"${ErrorMessages.InternalServerError} ${showExceptionAtJson(e)}")), 500 ) } @@ -452,7 +452,7 @@ class Boot extends MdcLoggable { sendExceptionEmail(e) logger.error("Exception being returned to browser when processing " + r.uri.toString, e) JsonResponse( - Extraction.decompose(ErrorMessage(s"${ErrorMessages.InternalServerError}")), + Extraction.decompose(ErrorMessage(code = 500, message = s"${ErrorMessages.InternalServerError}")), 500 ) } diff --git a/src/main/scala/code/api/ErrorMessageJsonAST.scala b/src/main/scala/code/api/ErrorMessageJsonAST.scala index 159b00387..4896ab32b 100644 --- a/src/main/scala/code/api/ErrorMessageJsonAST.scala +++ b/src/main/scala/code/api/ErrorMessageJsonAST.scala @@ -1,37 +1,37 @@ /** -Open Bank Project - API -Copyright (C) 2011-2018, TESOBE Ltd - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . - -Email: contact@tesobe.com -TESOBE Ltd -Osloerstrasse 16/17 -Berlin 13359, Germany - - This product includes software developed at - TESOBE (http://www.tesobe.com/) - by - Simon Redfern : simon AT tesobe DOT com - Stefan Bethge : stefan AT tesobe DOT com - Everett Sochowski : everett AT tesobe DOT com - Ayoub Benali: ayoub AT tesobe DOT com - - */ + * Open Bank Project - API + * Copyright (C) 2011-2018, TESOBE Ltd + * * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * * + * Email: contact@tesobe.com + * TESOBE Ltd + * Osloerstrasse 16/17 + * Berlin 13359, Germany + * * + * This product includes software developed at + * TESOBE (http://www.tesobe.com/) + * by + * Simon Redfern : simon AT tesobe DOT com + * Stefan Bethge : stefan AT tesobe DOT com + * Everett Sochowski : everett AT tesobe DOT com + * Ayoub Benali: ayoub AT tesobe DOT com + * + */ package code.api -case class ErrorMessage( - error : String -) +case class ErrorMessage(code: Int, + message: String + ) diff --git a/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala b/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala index c3454aa3c..a096aa4ea 100644 --- a/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala +++ b/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala @@ -458,7 +458,8 @@ object SwaggerDefinitionsJSON { )*/ val errorMessage = ErrorMessage( - error = "String" + code = 500, + message = "Internal Server Error" ) val postTransactionImageJSON = PostTransactionImageJSON( diff --git a/src/main/scala/code/api/util/APIUtil.scala b/src/main/scala/code/api/util/APIUtil.scala index 73fb14fc1..f6669a695 100644 --- a/src/main/scala/code/api/util/APIUtil.scala +++ b/src/main/scala/code/api/util/APIUtil.scala @@ -428,15 +428,15 @@ object APIUtil extends MdcLoggable { case _ => httpCode } - JsonResponse(Extraction.decompose(ErrorMessage(message)), getHeaders() ::: headers.list, Nil, code) + JsonResponse(Extraction.decompose(ErrorMessage(message = message, code = code)), getHeaders() ::: headers.list, Nil, code) } def notImplementedJsonResponse(message : String = ErrorMessages.NotImplemented, httpCode : Int = 501)(implicit headers: CustomResponseHeaders = CustomResponseHeaders(Nil)) : JsonResponse = - JsonResponse(Extraction.decompose(ErrorMessage(message)), getHeaders() ::: headers.list, Nil, httpCode) + JsonResponse(Extraction.decompose(ErrorMessage(message = message, code = httpCode)), getHeaders() ::: headers.list, Nil, httpCode) def oauthHeaderRequiredJsonResponse(implicit headers: CustomResponseHeaders = CustomResponseHeaders(Nil)) : JsonResponse = - JsonResponse(Extraction.decompose(ErrorMessage("Authentication via OAuth is required")), getHeaders() ::: headers.list, Nil, 400) + JsonResponse(Extraction.decompose(ErrorMessage(message = "Authentication via OAuth is required", code = 400)), getHeaders() ::: headers.list, Nil, 400) /** check the currency ISO code from the ISOCurrencyCodes.xml file */ def isValidCurrencyISOCode(currencyCode: String): Boolean = { diff --git a/src/main/scala/code/api/v1_2/JSONFactory1.2.scala b/src/main/scala/code/api/v1_2/JSONFactory1.2.scala index a76cffb5f..d047d78a1 100644 --- a/src/main/scala/code/api/v1_2/JSONFactory1.2.scala +++ b/src/main/scala/code/api/v1_2/JSONFactory1.2.scala @@ -45,9 +45,10 @@ case class HostedBy( email : String, phone : String ) -case class ErrorMessage( - error : String -) + +case class ErrorMessage(code: Int, + message: String + ) case class SuccessMessage( success : String ) diff --git a/src/main/scala/code/api/v1_2_1/JSONFactory1.2.1.scala b/src/main/scala/code/api/v1_2_1/JSONFactory1.2.1.scala index 88c36d853..d461985b0 100644 --- a/src/main/scala/code/api/v1_2_1/JSONFactory1.2.1.scala +++ b/src/main/scala/code/api/v1_2_1/JSONFactory1.2.1.scala @@ -51,8 +51,8 @@ case class HostedBy( ) case class RateLimiting(enabled: Boolean, technology: String, service_available: Boolean, is_active: Boolean) -case class ErrorMessage( - error : String +case class ErrorMessage(code: Int, + message : String ) case class SuccessMessage( success : String diff --git a/src/test/scala/code/api/directloginTest.scala b/src/test/scala/code/api/directloginTest.scala index 4a9326738..a96972b0f 100644 --- a/src/test/scala/code/api/directloginTest.scala +++ b/src/test/scala/code/api/directloginTest.scala @@ -10,6 +10,7 @@ import net.liftweb.mapper.By import net.liftweb.util.Helpers._ import org.scalatest.BeforeAndAfter import code.api.util.ErrorMessages._ +import code.api.v1_2_1.ErrorMessage @@ -246,11 +247,7 @@ class directloginTest extends ServerSetup with BeforeAndAfter { } private def assertResponse(response: APIResponse, expectedErrorMessage: String): Unit = { - response.body match { - case JObject(List(JField(name, JString(value)))) => - name should equal("error") - value should startWith(expectedErrorMessage) - case _ => fail("Expected an error message") - } + response.body.extract[ErrorMessage].message should startWith(expectedErrorMessage) } + } \ No newline at end of file diff --git a/src/test/scala/code/api/v1_2_1/API1_2_1Test.scala b/src/test/scala/code/api/v1_2_1/API1_2_1Test.scala index 595bc440a..fad6e2cf2 100644 --- a/src/test/scala/code/api/v1_2_1/API1_2_1Test.scala +++ b/src/test/scala/code/api/v1_2_1/API1_2_1Test.scala @@ -1038,7 +1038,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -1199,7 +1199,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -1316,7 +1316,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -1378,7 +1378,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("We will not get the list of the available views on a bank account due to insufficient privileges", API1_2_1, GetViews){ @@ -1390,7 +1390,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } feature("Create a view on a bank account"){ @@ -1420,7 +1420,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("We will not create a view on a bank account due to insufficient privileges", API1_2_1, PostView){ @@ -1433,7 +1433,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("We will not create a view because the bank account does not exist", API1_2_1, PostView){ @@ -1445,7 +1445,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("We will not create a view because the view already exists", API1_2_1, PostView){ @@ -1459,7 +1459,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we are not allowed to create a view with an empty name") { @@ -1481,7 +1481,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("can not create the System View") { @@ -1501,7 +1501,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -1594,7 +1594,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser reply.code should equal(400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update a view on a bank account due to insufficient privileges", API1_2_1, PutView){ @@ -1612,7 +1612,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser reply.code should equal(400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we can not update a System view on a bank account") { @@ -1632,7 +1632,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -1685,7 +1685,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("We will not delete a view on a bank account due to insufficient privileges", API1_2_1, DeleteView){ @@ -1698,7 +1698,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("We will not delete a view on a bank account because it does not exist", API1_2_1, PostView){ @@ -1710,7 +1710,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we can not delete a system view on a bank account", API1_2_1, DeleteView){ @@ -1721,7 +1721,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -1768,7 +1768,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get one bank account permissions by using an other access token", API1_2_1, GetPermissions){ @@ -1780,7 +1780,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -1811,7 +1811,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the permissions of a random user", API1_2_1, GetPermission){ @@ -1823,7 +1823,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -1854,7 +1854,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we cannot grant a user access to a view on an bank account because the view does not exist", API1_2_1, PostPermission){ @@ -1868,7 +1868,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) val viewsAfter = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSONV121].views.length viewsAfter should equal(viewsBefore) } @@ -1884,7 +1884,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) val viewsAfter = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSONV121].views.length viewsAfter should equal(viewsBefore) } @@ -1924,7 +1924,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we cannot grant a user access to a list of views on an bank account because they don't exist", API1_2_1, PostPermissions){ @@ -1938,7 +1938,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we cannot grant a user access to a list of views on an bank account because some views don't exist", API1_2_1, PostPermissions){ @@ -1953,7 +1953,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) val viewsAfter = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSONV121].views.length viewsAfter should equal(viewsBefore) } @@ -1970,7 +1970,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) val viewsAfter = getUserAccountPermission(bankId, bankAccount.id, userId, user1).body.extract[ViewsJSONV121].views.length viewsAfter should equal(viewsBefore) } @@ -2207,7 +2207,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the other bank accounts of a bank account because the user does not have enough privileges", API1_2_1, GetCounterparties){ @@ -2219,7 +2219,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the other bank accounts of a bank account because the view does not exist", API1_2_1, GetCounterparties){ @@ -2231,7 +2231,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -2262,7 +2262,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get one random other bank account of a bank account because the user does not have enough privileges", API1_2_1, GetCounterparty){ @@ -2276,7 +2276,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get one random other bank account of a bank account because the view does not exist", API1_2_1, GetCounterparty){ @@ -2289,7 +2289,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get one random other bank account of a bank account because the account does not exist", API1_2_1, GetCounterparty){ @@ -2302,7 +2302,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -2332,7 +2332,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the metadata of one random other bank account because the user does not have enough privileges", API1_2_1, GetCounterpartyMetadata){ @@ -2346,7 +2346,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the metadata of one random other bank account because the view does not exist", API1_2_1, GetCounterpartyMetadata){ @@ -2360,7 +2360,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the metadata of one random other bank account because the account does not exist", API1_2_1, GetCounterpartyMetadata){ @@ -2373,7 +2373,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -2402,7 +2402,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the public alias of one random other bank account because the user does not have enough privileges", API1_2_1, GetPublicAlias){ @@ -2416,7 +2416,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the public alias of one random other bank account because the view does not exist", API1_2_1, GetPublicAlias){ @@ -2430,7 +2430,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the public alias of one random other bank account because the account does not exist", API1_2_1, GetPublicAlias){ @@ -2444,7 +2444,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -2479,7 +2479,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the alias should not be changed") val getReply = getThePublicAliasForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] @@ -2498,7 +2498,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the alias should not be changed") val getReply = getThePublicAliasForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] @@ -2517,7 +2517,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the alias should not be changed") val getReply = getThePublicAliasForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] @@ -2535,7 +2535,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -2570,7 +2570,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the alias should not be changed") val getReply = getThePublicAliasForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] @@ -2589,7 +2589,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the public alias for a random other bank account because the account does not exist", API1_2_1, PutPublicAlias){ @@ -2603,7 +2603,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -2697,7 +2697,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the private alias of one random other bank account because the user does not have enough privileges", API1_2_1, GetPrivateAlias){ @@ -2711,7 +2711,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the private alias of one random other bank account because the view does not exist", API1_2_1, GetPrivateAlias){ @@ -2725,7 +2725,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the private alias of one random other bank account because the account does not exist", API1_2_1, GetPrivateAlias){ @@ -2739,7 +2739,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -2774,7 +2774,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the alias should not be changed") val getReply = getThePrivateAliasForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] @@ -2793,7 +2793,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the alias should not be changed") val getReply = getThePrivateAliasForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] @@ -2812,7 +2812,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the alias should not be changed") val getReply = getThePrivateAliasForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] @@ -2830,7 +2830,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -2865,7 +2865,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the alias should not be changed") val getReply = getThePrivateAliasForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] @@ -2884,7 +2884,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the private alias for a random other bank account because the account does not exist", API1_2_1, PutPrivateAlias){ @@ -2898,7 +2898,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -2997,7 +2997,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the information should not be changed") val moreInfo = getMoreInfoForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomInfo should not equal (moreInfo) @@ -3015,7 +3015,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the information should not be changed") val moreInfo = getMoreInfoForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomInfo should not equal (moreInfo) @@ -3033,7 +3033,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the information should not be changed") val moreInfo = getMoreInfoForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomInfo should not equal (moreInfo) @@ -3050,7 +3050,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -3084,7 +3084,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the information should not be changed") val moreInfo = getMoreInfoForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomInfo should not equal (moreInfo) @@ -3102,7 +3102,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the information for a random other bank account because the account does not exist", API1_2_1, PutMoreInfo){ @@ -3116,7 +3116,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -3215,7 +3215,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the url should not be changed") val url = getUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) @@ -3233,7 +3233,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the url should not be changed") val url = getUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) @@ -3251,7 +3251,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the url should not be changed") val url = getUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) @@ -3268,7 +3268,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -3302,7 +3302,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the url should not be changed") val url = getUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) @@ -3320,7 +3320,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the url for a random other bank account because the account does not exist", API1_2_1, PutURL){ @@ -3334,7 +3334,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -3433,7 +3433,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the image url should not be changed") val url = getImageUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomImageURL should not equal (url) @@ -3451,7 +3451,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the image url should not be changed") val url = getImageUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomImageURL should not equal (url) @@ -3469,7 +3469,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the image url should not be changed") val url = getImageUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomImageURL should not equal (url) @@ -3486,7 +3486,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -3520,7 +3520,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the image url should not be changed") val url = getImageUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomImageURL should not equal (url) @@ -3538,7 +3538,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the image url for a random other bank account because the account does not exist", API1_2_1, PutImageURL){ @@ -3552,7 +3552,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -3651,7 +3651,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the open corporates url should not be changed") val url = getOpenCorporatesUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) @@ -3669,7 +3669,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the open corporates url should not be changed") val url = getOpenCorporatesUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) @@ -3687,7 +3687,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the open corporates url should not be changed") val url = getOpenCorporatesUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) @@ -3704,7 +3704,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -3738,7 +3738,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the open corporates url should not be changed") val url = getOpenCorporatesUrlForOneCounterparty(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) @@ -3756,7 +3756,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the open corporates url for a random other bank account because the account does not exist", API1_2_1, PutOpenCorporatesURL){ @@ -3770,7 +3770,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -3870,7 +3870,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the corporate location for one random other bank account because the coordinates don't exist", API1_2_1, PostCorporateLocation){ @@ -3885,7 +3885,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the corporate location for a random other bank account because the user does not have enough privileges", API1_2_1, PostCorporateLocation){ @@ -3900,7 +3900,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the corporate location for a random other bank account because the view does not exist", API1_2_1, PostCorporateLocation){ @@ -3915,7 +3915,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the corporate location for a random other bank account because the account does not exist", API1_2_1, PostCorporateLocation){ @@ -3929,7 +3929,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -3964,7 +3964,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the corporate location for a random other bank account due to a missing token", API1_2_1, PutCorporateLocation){ @@ -3979,7 +3979,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the corporate location for a random other bank account because the user does not have enough privileges", API1_2_1, PutCorporateLocation){ @@ -3994,7 +3994,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the corporate location for a random other bank account because the account does not exist", API1_2_1, PutCorporateLocation){ @@ -4008,7 +4008,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -4108,7 +4108,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the physical location for a random other bank account due to a missing token", API1_2_1, PostPhysicalLocation){ @@ -4123,7 +4123,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the physical location for a random other bank account because the user does not have enough privileges", API1_2_1, PostPhysicalLocation){ @@ -4138,7 +4138,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the physical location for a random other bank account because the view does not exist", API1_2_1, PostPhysicalLocation){ @@ -4153,7 +4153,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the physical location for a random other bank account because the account does not exist", API1_2_1, PostPhysicalLocation){ @@ -4167,7 +4167,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -4202,7 +4202,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the physical location for a random other bank account due to a missing token", API1_2_1, PutPhysicalLocation){ @@ -4217,7 +4217,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the physical location for a random other bank account because the user does not have enough privileges", API1_2_1, PutPhysicalLocation){ @@ -4232,7 +4232,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the physical location for a random other bank account because the account does not exist", API1_2_1, PutPhysicalLocation){ @@ -4246,7 +4246,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -4768,7 +4768,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the narrative of one random transaction because the user does not have enough privileges", API1_2_1, GetNarrative){ @@ -4782,7 +4782,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the narrative of one random transaction because the view does not exist", API1_2_1, GetNarrative){ @@ -4796,7 +4796,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the narrative of one random transaction because the transaction does not exist", API1_2_1, GetNarrative){ @@ -4809,7 +4809,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -4844,7 +4844,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the narrative should not be added") val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theNarrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] @@ -4863,7 +4863,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the narrative should not be added") val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theNarrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] @@ -4882,7 +4882,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the narrative should not be added") val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theNarrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] @@ -4900,7 +4900,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -4935,7 +4935,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the narrative should not be changed") val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val narrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] @@ -4954,7 +4954,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the narrative should not be changed") val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val narrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] @@ -4973,7 +4973,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -5070,7 +5070,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the comments of one random transaction because the user does not have enough privileges", API1_2_1, GetComments){ @@ -5084,7 +5084,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the comments of one random transaction because the view does not exist", API1_2_1, GetComments){ @@ -5098,7 +5098,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the comments of one random transaction because the transaction does not exist", API1_2_1, GetComments){ @@ -5111,7 +5111,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -5149,7 +5149,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the comment should not be added") val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theCommentsAfterThePost = getReply.body.extract[TransactionCommentsJSON].comments @@ -5173,7 +5173,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the comment should not be added") val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theCommentsAfterThePost = getReply.body.extract[TransactionCommentsJSON].comments @@ -5196,7 +5196,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the comment should not be added") val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theCommentsAfterThePost = getReply.body.extract[TransactionCommentsJSON].comments @@ -5218,7 +5218,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -5413,7 +5413,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the tags of one random transaction because the user does not have enough privileges", API1_2_1, GetTags){ @@ -5427,7 +5427,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the tags of one random transaction because the view does not exist", API1_2_1, GetTags){ @@ -5441,7 +5441,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the tags of one random transaction because the transaction does not exist", API1_2_1, GetTags){ @@ -5454,7 +5454,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -5491,7 +5491,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the tag should not be added") val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theTagsAfterThePost = getReply.body.extract[TransactionTagsJSON].tags @@ -5514,7 +5514,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the tag should not be added") val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theTagsAfterThePost = getReply.body.extract[TransactionTagsJSON].tags @@ -5537,7 +5537,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the tag should not be added") val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theTagsAfterThePost = getReply.body.extract[TransactionTagsJSON].tags @@ -5559,7 +5559,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -5753,7 +5753,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the images of one random transaction because the user does not have enough privileges", API1_2_1, GetImages){ @@ -5767,7 +5767,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the images of one random transaction because the view does not exist", API1_2_1, GetImages){ @@ -5781,7 +5781,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the images of one random transaction because the transaction does not exist", API1_2_1, GetImages){ @@ -5794,7 +5794,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -5831,7 +5831,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the image should not be added") val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theImagesAfterThePost = getReply.body.extract[TransactionImagesJSON].images @@ -5854,7 +5854,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the image should not be added") val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theImagesAfterThePost = getReply.body.extract[TransactionImagesJSON].images @@ -5877,7 +5877,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) And("the image should not be added") val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theImagesAfterThePost = getReply.body.extract[TransactionImagesJSON].images @@ -5899,7 +5899,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -6096,7 +6096,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the where of one random transaction because the user does not have enough privileges", API1_2_1, GetWhere){ @@ -6112,7 +6112,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the where of one random transaction because the view does not exist", API1_2_1, GetWhere){ @@ -6128,7 +6128,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the where of one random transaction because the transaction does not exist", API1_2_1, GetWhere){ @@ -6141,7 +6141,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -6177,7 +6177,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the where for a random transaction due to a missing token", API1_2_1, PostWhere){ @@ -6192,7 +6192,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the where for a random transaction because the user does not have enough privileges", API1_2_1, PostWhere){ @@ -6207,7 +6207,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the where for a random transaction because the view does not exist", API1_2_1, PostWhere){ @@ -6222,7 +6222,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") postReply.code should equal (404) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not post the where for a random transaction because the transaction does not exist", API1_2_1, PostWhere){ @@ -6236,7 +6236,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") - postReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + postReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -6271,7 +6271,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the where for a random transaction due to a missing token", API1_2_1, PutWhere){ @@ -6286,7 +6286,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the where for a random transaction because the user does not have enough privileges", API1_2_1, PutWhere){ @@ -6301,7 +6301,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update the where for a random transaction because the transaction does not exist", API1_2_1, PutWhere){ @@ -6315,7 +6315,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") - putReply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + putReply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -6481,7 +6481,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get get the other bank account of a random transaction because the user does not have enough privileges", API1_2_1, GetTransactionAccount){ @@ -6495,7 +6495,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get the other bank account of a random transaction because the view does not exist", API1_2_1, GetTransactionAccount){ @@ -6509,7 +6509,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 404 code") reply.code should equal (404) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not get get the other bank account of a random transaction because the transaction does not exist", API1_2_1, GetTransactionAccount){ @@ -6522,7 +6522,7 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } } diff --git a/src/test/scala/code/api/v1_4_0/CustomerTest.scala b/src/test/scala/code/api/v1_4_0/CustomerTest.scala index 1642895be..eb717a828 100644 --- a/src/test/scala/code/api/v1_4_0/CustomerTest.scala +++ b/src/test/scala/code/api/v1_4_0/CustomerTest.scala @@ -96,7 +96,7 @@ class CustomerTest extends V200ServerSetup with DefaultUsers { Then("We should get a 400") secondResponsePost.code should equal(400) And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists) - secondResponsePost.body.extract[ErrorMessage].error should equal (ErrorMessages.CustomerNumberAlreadyExists) + secondResponsePost.body.extract[ErrorMessage].message should equal (ErrorMessages.CustomerNumberAlreadyExists) And("User is linked to 1 customer") UserCustomerLink.userCustomerLink.vend.getUserCustomerLinksByUserId(customerPostJSON1.user_id).size should equal(1) @@ -126,7 +126,7 @@ class CustomerTest extends V200ServerSetup with DefaultUsers { Then("We should get a 400") secondResponsePost3.code should equal(400) And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists) - secondResponsePost3.body.extract[ErrorMessage].error should equal (ErrorMessages.CustomerNumberAlreadyExists) + secondResponsePost3.body.extract[ErrorMessage].message should equal (ErrorMessages.CustomerNumberAlreadyExists) And("User is linked to 3 customers") UserCustomerLink.userCustomerLink.vend.getUserCustomerLinksByUserId(customerPostJSON3.user_id).size should equal(3) } diff --git a/src/test/scala/code/api/v2_0_0/AccountTest.scala b/src/test/scala/code/api/v2_0_0/AccountTest.scala index 998bffff6..e7b987aaf 100644 --- a/src/test/scala/code/api/v2_0_0/AccountTest.scala +++ b/src/test/scala/code/api/v2_0_0/AccountTest.scala @@ -120,7 +120,7 @@ class AccountTest extends V200ServerSetup with DefaultUsers { And("We should get a 400") responsePut.code should equal(400) And("We should have the error massage") - val error: String = (responsePut.body \ "error") match { + val error: String = (responsePut.body \ "message") match { case JString(i) => i case _ => "" } diff --git a/src/test/scala/code/api/v2_0_0/CustomerTest.scala b/src/test/scala/code/api/v2_0_0/CustomerTest.scala index 39a901228..0b7c7cd66 100644 --- a/src/test/scala/code/api/v2_0_0/CustomerTest.scala +++ b/src/test/scala/code/api/v2_0_0/CustomerTest.scala @@ -68,7 +68,7 @@ class CustomerTest extends V200ServerSetup with DefaultUsers { Then("We should get a 400") secondResponsePost.code should equal(400) And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists) - secondResponsePost.body.extract[ErrorMessage].error should equal (ErrorMessages.CustomerNumberAlreadyExists) + secondResponsePost.body.extract[ErrorMessage].message should equal (ErrorMessages.CustomerNumberAlreadyExists) And("User is linked to 1 customer") UserCustomerLink.userCustomerLink.vend.getUserCustomerLinksByUserId(customerPostJSON.user_id).size should equal(1) @@ -98,7 +98,7 @@ class CustomerTest extends V200ServerSetup with DefaultUsers { Then("We should get a 400") secondResponsePost4.code should equal(400) And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists) - secondResponsePost4.body.extract[ErrorMessage].error should equal (ErrorMessages.CustomerNumberAlreadyExists) + secondResponsePost4.body.extract[ErrorMessage].message should equal (ErrorMessages.CustomerNumberAlreadyExists) And("User is linked to 3 customers") UserCustomerLink.userCustomerLink.vend.getUserCustomerLinksByUserId(customerPostJSON.user_id).size should equal(3) diff --git a/src/test/scala/code/api/v2_0_0/EntitlementTests.scala b/src/test/scala/code/api/v2_0_0/EntitlementTests.scala index 9c274f7d6..5b84f335e 100644 --- a/src/test/scala/code/api/v2_0_0/EntitlementTests.scala +++ b/src/test/scala/code/api/v2_0_0/EntitlementTests.scala @@ -30,7 +30,7 @@ class EntitlementTests extends V200ServerSetup with DefaultUsers { Then("We should get a 400") responseGet.code should equal(400) And("We should get a message: " + ErrorMessages.UserNotLoggedIn) - responseGet.body.extract[ErrorMessage].error should equal (ErrorMessages.UserNotLoggedIn) + responseGet.body.extract[ErrorMessage].message should equal (ErrorMessages.UserNotLoggedIn) } @@ -41,7 +41,7 @@ class EntitlementTests extends V200ServerSetup with DefaultUsers { Then("We should get a 40") responseGet.code should equal(403) And("We should get a message: " + s"$CanGetEntitlementsForAnyUserAtAnyBank entitlement required") - responseGet.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetEntitlementsForAnyUserAtAnyBank) + responseGet.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetEntitlementsForAnyUserAtAnyBank) } scenario("We try to get entitlements with credentials - getEntitlements") { @@ -63,7 +63,7 @@ class EntitlementTests extends V200ServerSetup with DefaultUsers { Then("We should get a 400") responseDelete.code should equal(400) And("We should get a message: " + ErrorMessages.UserNotSuperAdmin) - responseDelete.body.extract[ErrorMessage].error should equal (ErrorMessages.UserNotSuperAdmin) + responseDelete.body.extract[ErrorMessage].message should equal (ErrorMessages.UserNotSuperAdmin) } } diff --git a/src/test/scala/code/api/v2_0_0/TransactionRequestsTest.scala b/src/test/scala/code/api/v2_0_0/TransactionRequestsTest.scala index 541cc7c3b..ebcda9cf4 100644 --- a/src/test/scala/code/api/v2_0_0/TransactionRequestsTest.scala +++ b/src/test/scala/code/api/v2_0_0/TransactionRequestsTest.scala @@ -356,7 +356,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers { response.code should equal(400) //created a transaction request, check some return values. As type is SANDBOX_TAN and value is < 1000, we expect no challenge - val error: String = (response.body \ "error") match { + val error: String = (response.body \ "message") match { case JString(i) => i case _ => "" } @@ -416,7 +416,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers { response.code should equal(400) //created a transaction request, check some return values. As type is SANDBOX_TAN and value is < 1000, we expect no challenge - val error: String = (response.body \ "error") match { + val error: String = (response.body \ "message") match { case JString(i) => i case _ => "" } diff --git a/src/test/scala/code/api/v2_1_0/CreateTransactionTypeTest.scala b/src/test/scala/code/api/v2_1_0/CreateTransactionTypeTest.scala index 531416aee..fe2501aed 100644 --- a/src/test/scala/code/api/v2_1_0/CreateTransactionTypeTest.scala +++ b/src/test/scala/code/api/v2_1_0/CreateTransactionTypeTest.scala @@ -42,7 +42,7 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers { Then("We should get a 400") responsePut.code should equal(400) And("We should get a message: " + ErrorMessages.InsufficientAuthorisationToCreateTransactionType) - responsePut.body.extract[ErrorMessage].error should equal (ErrorMessages.InsufficientAuthorisationToCreateTransactionType) + responsePut.body.extract[ErrorMessage].message should equal (ErrorMessages.InsufficientAuthorisationToCreateTransactionType) } scenario("We try to get all roles with Authentication - Create Transaction Type...") { @@ -113,7 +113,7 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers { And("We should get a 400") responsePut2.code should equal(400) And("We should get a message: " + ErrorMessages.CreateTransactionTypeInsertError) - responsePut2.body.extract[ErrorMessage].error should equal (ErrorMessages.CreateTransactionTypeInsertError) + responsePut2.body.extract[ErrorMessage].message should equal (ErrorMessages.CreateTransactionTypeInsertError) Then("insert new data and We make the request") @@ -131,7 +131,7 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers { And("We should get a 400") responsePut3.code should equal(400) And("We should get a message: " + ErrorMessages.CreateTransactionTypeUpdateError) - responsePut3.body.extract[ErrorMessage].error should equal (ErrorMessages.CreateTransactionTypeUpdateError) + responsePut3.body.extract[ErrorMessage].message should equal (ErrorMessages.CreateTransactionTypeUpdateError) } } /** diff --git a/src/test/scala/code/api/v2_1_0/CustomerTest.scala b/src/test/scala/code/api/v2_1_0/CustomerTest.scala index 4e9aefb3e..e19256f80 100644 --- a/src/test/scala/code/api/v2_1_0/CustomerTest.scala +++ b/src/test/scala/code/api/v2_1_0/CustomerTest.scala @@ -82,7 +82,7 @@ class CustomerTest extends V210ServerSetup with DefaultUsers { Then("We should get a 400") secondResponsePost.code should equal(400) And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists) - secondResponsePost.body.extract[ErrorMessage].error should equal (ErrorMessages.CustomerNumberAlreadyExists) + secondResponsePost.body.extract[ErrorMessage].message should equal (ErrorMessages.CustomerNumberAlreadyExists) And("User is linked to 1 customer") UserCustomerLink.userCustomerLink.vend.getUserCustomerLinksByUserId(customerPostJSON.user_id).size should equal(1) @@ -112,7 +112,7 @@ class CustomerTest extends V210ServerSetup with DefaultUsers { Then("We should get a 400") secondResponsePost4.code should equal(400) And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists) - secondResponsePost4.body.extract[ErrorMessage].error should equal (ErrorMessages.CustomerNumberAlreadyExists) + secondResponsePost4.body.extract[ErrorMessage].message should equal (ErrorMessages.CustomerNumberAlreadyExists) And("User is linked to 3 customers") UserCustomerLink.userCustomerLink.vend.getUserCustomerLinksByUserId(customerPostJSON.user_id).size should equal(3) } diff --git a/src/test/scala/code/api/v2_1_0/EntitlementTests.scala b/src/test/scala/code/api/v2_1_0/EntitlementTests.scala index 3674a48e4..e16d58639 100644 --- a/src/test/scala/code/api/v2_1_0/EntitlementTests.scala +++ b/src/test/scala/code/api/v2_1_0/EntitlementTests.scala @@ -24,7 +24,7 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers { Then("We should get a 400") responseGet.code should equal(400) And("We should get a message: " + ErrorMessages.UserNotLoggedIn) - responseGet.body.extract[ErrorMessage].error should equal (ErrorMessages.UserNotLoggedIn) + responseGet.body.extract[ErrorMessage].message should equal (ErrorMessages.UserNotLoggedIn) } @@ -46,7 +46,7 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers { Then("We should get a 400") responseGet.code should equal(400) And("We should get a message: " + ErrorMessages.UserNotLoggedIn) - responseGet.body.extract[ErrorMessage].error should equal (ErrorMessages.UserNotLoggedIn) + responseGet.body.extract[ErrorMessage].message should equal (ErrorMessages.UserNotLoggedIn) } @@ -61,7 +61,7 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers { Nil val requiredEntitlementsTxt = requiredEntitlements.mkString(" or ") And("We should get a message: " + s"$requiredEntitlementsTxt entitlements required") - responseGet.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + requiredEntitlementsTxt) + responseGet.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + requiredEntitlementsTxt) } scenario("We try to get entitlements with credentials - getEntitlementsByBankAndUser") { diff --git a/src/test/scala/code/api/v2_1_0/TransactionRequestsTest.scala b/src/test/scala/code/api/v2_1_0/TransactionRequestsTest.scala index 38d63ea53..6c81d0b67 100644 --- a/src/test/scala/code/api/v2_1_0/TransactionRequestsTest.scala +++ b/src/test/scala/code/api/v2_1_0/TransactionRequestsTest.scala @@ -2,7 +2,7 @@ package code.api.v2_1_0 import java.util.UUID -import code.api.ChargePolicy +import code.api.{ChargePolicy, ErrorMessage} import code.api.util.APIUtil.OAuth._ import code.api.util.ApiRole.CanCreateAnyTransactionRequest import code.api.util.ErrorMessages._ @@ -302,8 +302,7 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers { response.code should equal(400) Then("We should have the error message") - val error = for {JObject(o) <- response.body; JField("error", JString(error)) <- o} yield error - error should contain(ErrorMessages.UserNotLoggedIn) + response.body.extract[ErrorMessage].message should startWith(ErrorMessages.UserNotLoggedIn) } } @@ -324,7 +323,7 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers { response.code should equal(400) Then("We should have the error: " + ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest) - val error: String = (response.body \ "error").values.toString + val error: String = (response.body \ "message").values.toString error should equal(ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest) } } @@ -368,10 +367,9 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers { Then("we should get a 400 created code") response.code should equal(400) - - Then("We should have the error message") - val error: List[String] = for {JObject(o) <- response.body; JField("error", JString(error)) <- o} yield error - error(0) should include(ErrorMessages.InvalidTransactionRequestType) + + response.body.extract[ErrorMessage].message should startWith(ErrorMessages.InvalidTransactionRequestType) + } } diff --git a/src/test/scala/code/api/v2_1_0/UpdateConsumerRedirectUrlTest.scala b/src/test/scala/code/api/v2_1_0/UpdateConsumerRedirectUrlTest.scala index 165383d87..521f2c393 100644 --- a/src/test/scala/code/api/v2_1_0/UpdateConsumerRedirectUrlTest.scala +++ b/src/test/scala/code/api/v2_1_0/UpdateConsumerRedirectUrlTest.scala @@ -32,7 +32,7 @@ class UpdateConsumerRedirectUrlTest extends V210ServerSetup with DefaultUsers { println(responsePut.body) responsePut.code should equal(403) - val error = (responsePut.body \ "error" ) match { + val error = (responsePut.body \ "message" ) match { case JString(i) => i case _ => "" } @@ -54,7 +54,7 @@ class UpdateConsumerRedirectUrlTest extends V210ServerSetup with DefaultUsers { Then("We should get a 400") responsePut.code should equal(400) - val error = (responsePut.body \ "error" ) match { + val error = (responsePut.body \ "message" ) match { case JString(i) => i case _ => "" } diff --git a/src/test/scala/code/api/v2_1_0/UserTests.scala b/src/test/scala/code/api/v2_1_0/UserTests.scala index db484451e..503f73ec1 100644 --- a/src/test/scala/code/api/v2_1_0/UserTests.scala +++ b/src/test/scala/code/api/v2_1_0/UserTests.scala @@ -25,7 +25,7 @@ class UserTests extends V210ServerSetup with User1AllPrivileges { Then("We should get a 400") responseGet.code should equal(400) And("We should get a message: " + ErrorMessages.UserNotLoggedIn) - responseGet.body.extract[ErrorMessage].error should equal (ErrorMessages.UserNotLoggedIn) + responseGet.body.extract[ErrorMessage].message should equal (ErrorMessages.UserNotLoggedIn) } @@ -37,7 +37,7 @@ class UserTests extends V210ServerSetup with User1AllPrivileges { Then("We should get a 200") responseGet.code should equal(403) And("We should get a message: " + ErrorMessages.UserHasMissingRoles) - responseGet.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetAnyUser) + responseGet.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetAnyUser) } diff --git a/src/test/scala/code/api/v2_2_0/API2_2_0Test.scala b/src/test/scala/code/api/v2_2_0/API2_2_0Test.scala index aa6602409..e175a77dc 100644 --- a/src/test/scala/code/api/v2_2_0/API2_2_0Test.scala +++ b/src/test/scala/code/api/v2_2_0/API2_2_0Test.scala @@ -193,7 +193,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("We will not get the list of the available views on a bank account due to insufficient privileges", API2_2, GetViews) { @@ -205,7 +205,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } feature("Create a view on a bank account - v2.2.0"){ @@ -235,7 +235,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("We will not create a view on a bank account due to insufficient privileges", API2_2, PostView) { @@ -248,7 +248,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("We will not create a view because the bank account does not exist", API2_2, PostView) { @@ -260,7 +260,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("We will not create a view because the view already exists", API2_2, PostView) { @@ -274,7 +274,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("can not create the System View") { @@ -286,7 +286,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -379,7 +379,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU reply.code should equal(400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update a view on a bank account due to insufficient privileges", API2_2, PutView) { @@ -397,7 +397,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU reply.code should equal(400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we can not update a System view on a bank account") { @@ -417,7 +417,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } diff --git a/src/test/scala/code/api/v2_2_0/CreateCounterpartyTest.scala b/src/test/scala/code/api/v2_2_0/CreateCounterpartyTest.scala index f85a7d3ef..0044677e1 100644 --- a/src/test/scala/code/api/v2_2_0/CreateCounterpartyTest.scala +++ b/src/test/scala/code/api/v2_2_0/CreateCounterpartyTest.scala @@ -1,5 +1,6 @@ package code.api.v2_2_0 +import code.api.ErrorMessage import code.api.ResourceDocs1_4_0.SwaggerDefinitionsJSON import code.api.util.APIUtil.OAuth._ import code.api.util.ErrorMessages @@ -97,8 +98,7 @@ class CreateCounterpartyTest extends V220ServerSetup with DefaultUsers { Then("We should get a 400") responsePost.code should equal(400) - val error = for { JObject(o) <- responsePost.body; JField("error", JString(error)) <- o } yield error - error.toString contains (ErrorMessages.AccountNotFound) should be (true) + responsePost.body.extract[ErrorMessage].message should startWith(ErrorMessages.AccountNotFound) } scenario("counterparty is not unique for name/bank_id/account_id/view_id") { @@ -120,9 +120,8 @@ class CreateCounterpartyTest extends V220ServerSetup with DefaultUsers { Then("We should get a 400 and check the error massage") responsePost.code should equal(400) - - val error = for { JObject(o) <- responsePost.body; JField("error", JString(error)) <- o } yield error - error.toString contains (ErrorMessages.CounterpartyAlreadyExists) should be (true) + + responsePost.body.extract[ErrorMessage].message should startWith(ErrorMessages.CounterpartyAlreadyExists) } } diff --git a/src/test/scala/code/api/v3_0_0/AccountTest.scala b/src/test/scala/code/api/v3_0_0/AccountTest.scala index 8fe2f1ec7..8570c735b 100644 --- a/src/test/scala/code/api/v3_0_0/AccountTest.scala +++ b/src/test/scala/code/api/v3_0_0/AccountTest.scala @@ -39,7 +39,7 @@ class AccountTest extends V300ServerSetup { And("We should get a 403") responseGet.code should equal(403) - compactRender(responseGet.body \ "error").replaceAll("\"", "") should equal(FirehoseViewsNotAllowedOnThisInstance +" or " + UserHasMissingRoles + CanUseFirehoseAtAnyBank ) + compactRender(responseGet.body \ "message").replaceAll("\"", "") should equal(FirehoseViewsNotAllowedOnThisInstance +" or " + UserHasMissingRoles + CanUseFirehoseAtAnyBank ) }} diff --git a/src/test/scala/code/api/v3_0_0/BranchesTest.scala b/src/test/scala/code/api/v3_0_0/BranchesTest.scala index 204583b71..132f8dd3d 100644 --- a/src/test/scala/code/api/v3_0_0/BranchesTest.scala +++ b/src/test/scala/code/api/v3_0_0/BranchesTest.scala @@ -260,7 +260,7 @@ class BranchesTest extends V300ServerSetup with DefaultUsers { Then("We should get a 400 and correct response jons format") response300.code should equal(400) response300.body.extract[BranchesJsonV300] - json.compactRender(response300.body \ "error").replaceAll("\"", "") should include (ErrorMessages.BranchesNotFound) + json.compactRender(response300.body \ "message").replaceAll("\"", "") should include (ErrorMessages.BranchesNotFound) } } diff --git a/src/test/scala/code/api/v3_0_0/TransactionsTest.scala b/src/test/scala/code/api/v3_0_0/TransactionsTest.scala index 17175278e..cb8d17e7b 100644 --- a/src/test/scala/code/api/v3_0_0/TransactionsTest.scala +++ b/src/test/scala/code/api/v3_0_0/TransactionsTest.scala @@ -75,7 +75,7 @@ class TransactionsTest extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("error should be " + ErrorMessages.FilterSortDirectionError) - reply.body.extract[ErrorMessage].error contains (ErrorMessages.FilterSortDirectionError) + reply.body.extract[ErrorMessage].message contains (ErrorMessages.FilterSortDirectionError) } scenario("we get all the transactions sorted by ASC", API300, GetTransactions, GetTransactionsWithParams) { Given("We will use an access token") @@ -157,7 +157,7 @@ class TransactionsTest extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("error should be " + ErrorMessages.FilterLimitError) - reply.body.extract[ErrorMessage].error contains (ErrorMessages.FilterLimitError) + reply.body.extract[ErrorMessage].message contains (ErrorMessages.FilterLimitError) } scenario("we don't get transactions due to wrong value (0) for limit parameter", API300, GetTransactions, GetTransactionsWithParams) { Given("We will use an access token") @@ -170,7 +170,7 @@ class TransactionsTest extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("error should be " + ErrorMessages.FilterLimitError) - reply.body.extract[ErrorMessage].error contains (ErrorMessages.FilterLimitError) + reply.body.extract[ErrorMessage].message contains (ErrorMessages.FilterLimitError) } scenario("we don't get transactions due to wrong value (-100) for limit parameter", API300, GetTransactions, GetTransactionsWithParams) { Given("We will use an access token") @@ -183,7 +183,7 @@ class TransactionsTest extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("error should be " + ErrorMessages.FilterLimitError) - reply.body.extract[ErrorMessage].error contains (ErrorMessages.FilterLimitError) + reply.body.extract[ErrorMessage].message contains (ErrorMessages.FilterLimitError) } scenario("we get only 5 transactions due to the limit parameter value", API300, GetTransactions, GetTransactionsWithParams) { Given("We will use an access token") @@ -210,7 +210,7 @@ class TransactionsTest extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("error should be " + ErrorMessages.FilterDateFormatError) - reply.body.extract[ErrorMessage].error contains (ErrorMessages.FilterDateFormatError) + reply.body.extract[ErrorMessage].message contains (ErrorMessages.FilterDateFormatError) } scenario("we get transactions from a previous date with the right format", API300, GetTransactions, GetTransactionsWithParams) { Given("We will use an access token") @@ -283,7 +283,7 @@ class TransactionsTest extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("error should be " + ErrorMessages.FilterDateFormatError) - reply.body.extract[ErrorMessage].error contains (ErrorMessages.FilterDateFormatError) + reply.body.extract[ErrorMessage].message contains (ErrorMessages.FilterDateFormatError) } scenario("we get transactions from a previous (to_date) date with the right format", API300, GetTransactions, GetTransactionsWithParams) { Given("We will use an access token") @@ -348,7 +348,7 @@ class TransactionsTest extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("error should be " + ErrorMessages.FilterOffersetError) - reply.body.extract[ErrorMessage].error contains (ErrorMessages.FilterOffersetError) + reply.body.extract[ErrorMessage].message contains (ErrorMessages.FilterOffersetError) } scenario("we don't get transactions due to the (2000) for offset parameter", API300, GetTransactions, GetTransactionsWithParams) { Given("We will use an access token") @@ -375,7 +375,7 @@ class TransactionsTest extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("error should be " + ErrorMessages.FilterOffersetError) - reply.body.extract[ErrorMessage].error contains (ErrorMessages.FilterOffersetError) + reply.body.extract[ErrorMessage].message contains (ErrorMessages.FilterOffersetError) } scenario("we get only 5 transactions due to the offset parameter value", API300, GetTransactions, GetTransactionsWithParams) { Given("We will use an access token") @@ -403,7 +403,7 @@ class TransactionsTest extends V300ServerSetup { And("We should get a 403") responseGet.code should equal(403) - compactRender(responseGet.body \ "error").replaceAll("\"", "") should equal(FirehoseViewsNotAllowedOnThisInstance +" or " + UserHasMissingRoles + CanUseFirehoseAtAnyBank ) + compactRender(responseGet.body \ "message").replaceAll("\"", "") should equal(FirehoseViewsNotAllowedOnThisInstance +" or " + UserHasMissingRoles + CanUseFirehoseAtAnyBank ) }} diff --git a/src/test/scala/code/api/v3_0_0/UserTest.scala b/src/test/scala/code/api/v3_0_0/UserTest.scala index 86746ff6e..44884378e 100644 --- a/src/test/scala/code/api/v3_0_0/UserTest.scala +++ b/src/test/scala/code/api/v3_0_0/UserTest.scala @@ -26,7 +26,7 @@ class UserTest extends V300ServerSetup with DefaultUsers { Then("We should get a 400") responseGet.code should equal(400) And("We should get a message: " + ErrorMessages.UserNotLoggedIn) - responseGet.body.extract[ErrorMessage].error should equal (ErrorMessages.UserNotLoggedIn) + responseGet.body.extract[ErrorMessage].message should equal (ErrorMessages.UserNotLoggedIn) } @@ -38,7 +38,7 @@ class UserTest extends V300ServerSetup with DefaultUsers { Then("We should get a 200") responseGet.code should equal(403) And("We should get a message: " + UserHasMissingRoles + CanGetAnyUser) - responseGet.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetAnyUser) + responseGet.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetAnyUser) } @@ -69,7 +69,7 @@ class UserTest extends V300ServerSetup with DefaultUsers { And("We should get a 403") responseGet.code should equal(403) - responseGet.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetAnyUser) + responseGet.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetAnyUser) } scenario("We try to get all user data without required role " + CanGetAnyUser){ @@ -80,7 +80,7 @@ class UserTest extends V300ServerSetup with DefaultUsers { And("We should get a 403") responseGet.code should equal(403) - responseGet.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetAnyUser) + responseGet.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetAnyUser) } scenario("We try to get user data by USER_ID without required role " + CanGetAnyUser){ @@ -91,7 +91,7 @@ class UserTest extends V300ServerSetup with DefaultUsers { And("We should get a 403") responseGet.code should equal(403) - responseGet.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetAnyUser) + responseGet.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetAnyUser) } scenario("We try to get user data by USERNAME without required role " + CanGetAnyUser){ @@ -102,7 +102,7 @@ class UserTest extends V300ServerSetup with DefaultUsers { And("We should get a 403") responseGet.code should equal(403) - responseGet.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetAnyUser) + responseGet.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetAnyUser) } scenario("We create an user and get it by EMAIL and USER_ID") { diff --git a/src/test/scala/code/api/v3_0_0/ViewsTests.scala b/src/test/scala/code/api/v3_0_0/ViewsTests.scala index d42934b56..0627a66cb 100644 --- a/src/test/scala/code/api/v3_0_0/ViewsTests.scala +++ b/src/test/scala/code/api/v3_0_0/ViewsTests.scala @@ -117,7 +117,7 @@ class ViewsTests extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("No Views") { @@ -130,7 +130,7 @@ class ViewsTests extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -162,7 +162,7 @@ class ViewsTests extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("no views") { @@ -174,7 +174,7 @@ class ViewsTests extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("no existing account") { @@ -185,7 +185,7 @@ class ViewsTests extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("view already exists") { @@ -198,7 +198,7 @@ class ViewsTests extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("can not create the System View") { @@ -210,7 +210,7 @@ class ViewsTests extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } @@ -303,7 +303,7 @@ class ViewsTests extends V300ServerSetup { reply.code should equal(400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we will not update a view on a bank account due to insufficient privileges") { @@ -320,7 +320,7 @@ class ViewsTests extends V300ServerSetup { reply.code should equal(400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } scenario("we can not update a System view on a bank account") { @@ -341,7 +341,7 @@ class ViewsTests extends V300ServerSetup { Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") - reply.body.extract[ErrorMessage].error.nonEmpty should equal (true) + reply.body.extract[ErrorMessage].message.nonEmpty should equal (true) } } diff --git a/src/test/scala/code/api/v3_0_0/WarehouseTest.scala b/src/test/scala/code/api/v3_0_0/WarehouseTest.scala index 295457e04..15de5b5b2 100644 --- a/src/test/scala/code/api/v3_0_0/WarehouseTest.scala +++ b/src/test/scala/code/api/v3_0_0/WarehouseTest.scala @@ -34,7 +34,7 @@ class WarehouseTest extends V300ServerSetup with DefaultUsers { And("We should get a 403") responsePost.code should equal(403) - compactRender(responsePost.body \ "error").replaceAll("\"", "") should equal(UserHasMissingRoles + CanSearchWarehouse) + compactRender(responsePost.body \ "message").replaceAll("\"", "") should equal(UserHasMissingRoles + CanSearchWarehouse) } } diff --git a/src/test/scala/code/api/v3_0_0/WarehouseTestAsync.scala b/src/test/scala/code/api/v3_0_0/WarehouseTestAsync.scala index f42217156..a156a83dc 100644 --- a/src/test/scala/code/api/v3_0_0/WarehouseTestAsync.scala +++ b/src/test/scala/code/api/v3_0_0/WarehouseTestAsync.scala @@ -39,7 +39,7 @@ class WarehouseTestAsync extends V300ServerSetupAsync with DefaultUsers { responsePost map { r => r.code should equal(403) - compactRender(r.body \ "error").replaceAll("\"", "") should equal(UserHasMissingRoles + CanSearchWarehouse) + compactRender(r.body \ "message").replaceAll("\"", "") should equal(UserHasMissingRoles + CanSearchWarehouse) } } diff --git a/src/test/scala/code/api/v3_1_0/ConsumerTest.scala b/src/test/scala/code/api/v3_1_0/ConsumerTest.scala index 1f251617e..5162a412a 100644 --- a/src/test/scala/code/api/v3_1_0/ConsumerTest.scala +++ b/src/test/scala/code/api/v3_1_0/ConsumerTest.scala @@ -81,7 +81,7 @@ class ConsumerTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will Get Consumers for current user", ApiEndpoint2, VersionOfApi) { When("We make a request v3.1.0") diff --git a/src/test/scala/code/api/v3_1_0/CustomerAddressTest.scala b/src/test/scala/code/api/v3_1_0/CustomerAddressTest.scala index be57abbcd..ab75a2c21 100644 --- a/src/test/scala/code/api/v3_1_0/CustomerAddressTest.scala +++ b/src/test/scala/code/api/v3_1_0/CustomerAddressTest.scala @@ -76,7 +76,7 @@ class CustomerAddressTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will call the Add endpoint without a proper role", ApiEndpoint1, VersionOfApi) { When("We make a request v3.1.0") @@ -85,7 +85,7 @@ class CustomerAddressTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanCreateCustomer) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanCreateCustomer) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanCreateCustomer) } scenario("We will call the Get endpoint without a user credentials", ApiEndpoint2, VersionOfApi) { @@ -95,7 +95,7 @@ class CustomerAddressTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will call the Get endpoint without a proper role", ApiEndpoint2, VersionOfApi) { When("We make a request v3.1.0") @@ -104,7 +104,7 @@ class CustomerAddressTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanGetCustomer) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetCustomer) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetCustomer) } scenario("We will call the Delete endpoint without a user credentials", ApiEndpoint3, VersionOfApi) { @@ -114,7 +114,7 @@ class CustomerAddressTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will call the Delete endpoint without a proper role", ApiEndpoint3, VersionOfApi) { When("We make a request v3.1.0") @@ -123,7 +123,7 @@ class CustomerAddressTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanCreateCustomer) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanCreateCustomer) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanCreateCustomer) } scenario("We will call the Add, Get and Delete endpoints with user credentials and role", ApiEndpoint1, ApiEndpoint2, ApiEndpoint3, VersionOfApi) { @@ -134,7 +134,7 @@ class CustomerAddressTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + CustomerNotFoundByCustomerId) - response310.body.extract[ErrorMessage].error should startWith (CustomerNotFoundByCustomerId) + response310.body.extract[ErrorMessage].message should startWith (CustomerNotFoundByCustomerId) Entitlement.entitlement.vend.addEntitlement(bankId, resourceUser1.userId, CanCreateCustomer.toString) When("We try to create the customer v3.1.0") diff --git a/src/test/scala/code/api/v3_1_0/CustomerTest.scala b/src/test/scala/code/api/v3_1_0/CustomerTest.scala index 12a1bd74a..30bcdb9cf 100644 --- a/src/test/scala/code/api/v3_1_0/CustomerTest.scala +++ b/src/test/scala/code/api/v3_1_0/CustomerTest.scala @@ -75,7 +75,7 @@ class CustomerTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } } @@ -88,7 +88,7 @@ class CustomerTest extends V310ServerSetup { response310.code should equal(403) val errorMsg = UserHasMissingRoles + canCreateCustomer + " or " + canCreateCustomerAtAnyBank And("error should be " + errorMsg) - response310.body.extract[ErrorMessage].error should equal (errorMsg) + response310.body.extract[ErrorMessage].message should equal (errorMsg) } scenario("We will call the endpoint with a user credentials and a proper role", ApiEndpoint3, VersionOfApi) { Entitlement.entitlement.vend.addEntitlement(bankId, resourceUser1.userId, CanCreateCustomer.toString) @@ -121,7 +121,7 @@ class CustomerTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanGetCustomer) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetCustomer) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetCustomer) } scenario("We will call the endpoint with the proper Role " + canGetCustomer, ApiEndpoint, VersionOfApi) { Entitlement.entitlement.vend.addEntitlement(bankId, resourceUser1.userId, CanGetCustomer.toString) @@ -131,7 +131,7 @@ class CustomerTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + CustomerNotFoundByCustomerId) - response310.body.extract[ErrorMessage].error should startWith (CustomerNotFoundByCustomerId) + response310.body.extract[ErrorMessage].message should startWith (CustomerNotFoundByCustomerId) } } @@ -143,7 +143,7 @@ class CustomerTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } } @@ -155,7 +155,7 @@ class CustomerTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanGetCustomer) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetCustomer) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetCustomer) } scenario("We will call the endpoint with the proper Role " + canGetCustomer, ApiEndpoint2, VersionOfApi) { Entitlement.entitlement.vend.addEntitlement(bankId, resourceUser1.userId, CanGetCustomer.toString) @@ -165,7 +165,7 @@ class CustomerTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + CustomerNotFound) - response310.body.extract[ErrorMessage].error should startWith (CustomerNotFound) + response310.body.extract[ErrorMessage].message should startWith (CustomerNotFound) } } diff --git a/src/test/scala/code/api/v3_1_0/FundsAvailableTest.scala b/src/test/scala/code/api/v3_1_0/FundsAvailableTest.scala index 517589eb7..853e57472 100644 --- a/src/test/scala/code/api/v3_1_0/FundsAvailableTest.scala +++ b/src/test/scala/code/api/v3_1_0/FundsAvailableTest.scala @@ -59,7 +59,7 @@ class FundsAvailableTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } } @@ -75,7 +75,7 @@ class FundsAvailableTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanCheckFundsAvailable) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanCheckFundsAvailable) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanCheckFundsAvailable) } scenario("We will check available funds with a proper Role " + canCheckFundsAvailable + " but without params", ApiEndpoint, VersionOfApi) { @@ -90,19 +90,19 @@ class FundsAvailableTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + MissingQueryParams) - response310.body.extract[ErrorMessage].error should startWith (MissingQueryParams) + response310.body.extract[ErrorMessage].message should startWith (MissingQueryParams) val response310_amount = makeGetRequest(request310 < "1")) Then("We should get a 400") response310_amount.code should equal(400) And("error should be " + MissingQueryParams) - response310_amount.body.extract[ErrorMessage].error should startWith (MissingQueryParams) + response310_amount.body.extract[ErrorMessage].message should startWith (MissingQueryParams) val response310_ccy = makeGetRequest(request310 < "EUR")) Then("We should get a 400") response310_ccy.code should equal(400) And("error should be " + MissingQueryParams) - response310_ccy.body.extract[ErrorMessage].error should startWith (MissingQueryParams) + response310_ccy.body.extract[ErrorMessage].message should startWith (MissingQueryParams) } scenario("We will check available funds with a proper Role " + canCheckFundsAvailable + " and params", ApiEndpoint, VersionOfApi) { @@ -122,14 +122,14 @@ class FundsAvailableTest extends V310ServerSetup { Then("We should get a 400") response310_invalic_ccy.code should equal(400) And("error should be " + InvalidISOCurrencyCode) - response310_invalic_ccy.body.extract[ErrorMessage].error should equal(InvalidISOCurrencyCode) + response310_invalic_ccy.body.extract[ErrorMessage].message should equal(InvalidISOCurrencyCode) When("We make a request v3.1.0 with a Role " + canCheckFundsAvailable + " and all params but amount is invalid") val response310_amount_ccy = makeGetRequest(request310 < "EUR", "amount" -> "bb")) Then("We should get a 400") response310_amount_ccy.code should equal(400) And("error should be " + InvalidAmount) - response310_amount_ccy.body.extract[ErrorMessage].error should startWith (InvalidAmount) + response310_amount_ccy.body.extract[ErrorMessage].message should startWith (InvalidAmount) } } diff --git a/src/test/scala/code/api/v3_1_0/GetAdapterInfoTest.scala b/src/test/scala/code/api/v3_1_0/GetAdapterInfoTest.scala index e8fdb57bd..2df380663 100644 --- a/src/test/scala/code/api/v3_1_0/GetAdapterInfoTest.scala +++ b/src/test/scala/code/api/v3_1_0/GetAdapterInfoTest.scala @@ -53,7 +53,7 @@ class GetAdapterInfoTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + NotImplemented) - response310.body.extract[ErrorMessage].error should include (NotImplemented + "getAdapterInfoFuture") + response310.body.extract[ErrorMessage].message should include (NotImplemented + "getAdapterInfoFuture") } } diff --git a/src/test/scala/code/api/v3_1_0/RateLimitTest.scala b/src/test/scala/code/api/v3_1_0/RateLimitTest.scala index 5b87ac930..9e9916b52 100644 --- a/src/test/scala/code/api/v3_1_0/RateLimitTest.scala +++ b/src/test/scala/code/api/v3_1_0/RateLimitTest.scala @@ -77,7 +77,7 @@ class RateLimitTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will try to set calls limit per minute without a proper Role " + ApiRole.canSetCallLimits, ApiEndpoint, VersionOfApi) { When("We make a request v3.1.0 without a Role " + ApiRole.canSetCallLimits) @@ -88,7 +88,7 @@ class RateLimitTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanSetCallLimits) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanSetCallLimits) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanSetCallLimits) } scenario("We will try to set calls limit per minute with a proper Role " + ApiRole.canSetCallLimits, ApiEndpoint, VersionOfApi) { When("We make a request v3.1.0 with a Role " + ApiRole.canSetCallLimits) @@ -139,7 +139,7 @@ class RateLimitTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will try to get calls limit per minute without a proper Role " + ApiRole.canReadCallLimits, ApiEndpoint2, VersionOfApi) { When("We make a request v3.1.0 without a Role " + ApiRole.canReadCallLimits) @@ -150,7 +150,7 @@ class RateLimitTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanReadCallLimits) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanReadCallLimits) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanReadCallLimits) } scenario("We will try to get calls limit per minute with a proper Role " + ApiRole.canReadCallLimits, ApiEndpoint2, VersionOfApi) { When("We make a request v3.1.0 with a Role " + ApiRole.canReadCallLimits) diff --git a/src/test/scala/code/api/v3_1_0/RefreshObpDateTest.scala b/src/test/scala/code/api/v3_1_0/RefreshObpDateTest.scala index 837dc85d9..295b3fb94 100644 --- a/src/test/scala/code/api/v3_1_0/RefreshObpDateTest.scala +++ b/src/test/scala/code/api/v3_1_0/RefreshObpDateTest.scala @@ -56,7 +56,7 @@ class RefreshUserTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanRefreshUser) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanRefreshUser) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanRefreshUser) } diff --git a/src/test/scala/code/api/v3_1_0/TaxResidenceTest.scala b/src/test/scala/code/api/v3_1_0/TaxResidenceTest.scala index 147689973..5c2e18e0a 100644 --- a/src/test/scala/code/api/v3_1_0/TaxResidenceTest.scala +++ b/src/test/scala/code/api/v3_1_0/TaxResidenceTest.scala @@ -63,7 +63,7 @@ class TaxResidenceTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } } feature("Get the Tax Residence of the Customer specified by CUSTOMER_ID v3.1.0 - Unauthorized access") { @@ -74,7 +74,7 @@ class TaxResidenceTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } } feature("Delete the Tax Residence of the Customer specified by a TAX_RESIDENCE_ID v3.1.0 - Unauthorized access") { @@ -85,7 +85,7 @@ class TaxResidenceTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } } @@ -98,7 +98,7 @@ class TaxResidenceTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanCreateTaxResidence) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanCreateTaxResidence) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanCreateTaxResidence) } scenario("We will call the endpoint with the proper Role " + canCreateTaxResidence, ApiEndpoint1, VersionOfApi) { Entitlement.entitlement.vend.addEntitlement(bankId, resourceUser1.userId, CanCreateTaxResidence.toString) @@ -108,7 +108,7 @@ class TaxResidenceTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + CustomerNotFoundByCustomerId) - response310.body.extract[ErrorMessage].error should startWith (CustomerNotFoundByCustomerId) + response310.body.extract[ErrorMessage].message should startWith (CustomerNotFoundByCustomerId) } scenario("We will call the endpoint with the proper Role " + canCreateTaxResidence + " and an existing customer", ApiEndpoint1, VersionOfApi) { Entitlement.entitlement.vend.addEntitlement(bankId, resourceUser1.userId, CanCreateCustomer.toString) @@ -160,7 +160,7 @@ class TaxResidenceTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanGetTaxResidence) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetTaxResidence) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetTaxResidence) } scenario("We will call the endpoint with the proper Role " + canGetTaxResidence, ApiEndpoint2, VersionOfApi) { Entitlement.entitlement.vend.addEntitlement(bankId, resourceUser1.userId, CanGetTaxResidence.toString) @@ -170,7 +170,7 @@ class TaxResidenceTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + CustomerNotFoundByCustomerId) - response310.body.extract[ErrorMessage].error should startWith (CustomerNotFoundByCustomerId) + response310.body.extract[ErrorMessage].message should startWith (CustomerNotFoundByCustomerId) } } @@ -183,7 +183,7 @@ class TaxResidenceTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanDeleteTaxResidence) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanDeleteTaxResidence) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanDeleteTaxResidence) } scenario("We will call the endpoint with the proper Role " + canDeleteTaxResidence, ApiEndpoint3, VersionOfApi) { Entitlement.entitlement.vend.addEntitlement(bankId, resourceUser1.userId, CanDeleteTaxResidence.toString) @@ -193,7 +193,7 @@ class TaxResidenceTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + CustomerNotFoundByCustomerId) - response310.body.extract[ErrorMessage].error should startWith (CustomerNotFoundByCustomerId) + response310.body.extract[ErrorMessage].message should startWith (CustomerNotFoundByCustomerId) } } diff --git a/src/test/scala/code/api/v3_1_0/TransactionRequestTest.scala b/src/test/scala/code/api/v3_1_0/TransactionRequestTest.scala index bfca5d18f..42e42206b 100644 --- a/src/test/scala/code/api/v3_1_0/TransactionRequestTest.scala +++ b/src/test/scala/code/api/v3_1_0/TransactionRequestTest.scala @@ -58,7 +58,7 @@ class TransactionRequestTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will Get Transaction Requests - user is logged in", ApiEndpoint1, VersionOfApi) { When("We make a request v3.1.0") diff --git a/src/test/scala/code/api/v3_1_0/TransactionTest.scala b/src/test/scala/code/api/v3_1_0/TransactionTest.scala index 5f4dffabe..3d00f8ca9 100644 --- a/src/test/scala/code/api/v3_1_0/TransactionTest.scala +++ b/src/test/scala/code/api/v3_1_0/TransactionTest.scala @@ -59,7 +59,7 @@ class TransactionTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will Get Transaction by Id - user is logged in", ApiEndpoint1, VersionOfApi) { When("We make a request v3.1.0") diff --git a/src/test/scala/code/api/v3_1_0/UserAuthContextTest.scala b/src/test/scala/code/api/v3_1_0/UserAuthContextTest.scala index 5109a02f1..f324ac97b 100644 --- a/src/test/scala/code/api/v3_1_0/UserAuthContextTest.scala +++ b/src/test/scala/code/api/v3_1_0/UserAuthContextTest.scala @@ -64,7 +64,7 @@ class UserAuthContextTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will call the Add endpoint without a proper role", ApiEndpoint1, VersionOfApi) { When("We make a request v3.1.0") @@ -73,7 +73,7 @@ class UserAuthContextTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanCreateUserAuthContext) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanCreateUserAuthContext) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanCreateUserAuthContext) } scenario("We will call the Get endpoint without a user credentials", ApiEndpoint2, VersionOfApi) { @@ -83,7 +83,7 @@ class UserAuthContextTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will call the Get endpoint without a proper role", ApiEndpoint2, VersionOfApi) { When("We make a request v3.1.0") @@ -92,7 +92,7 @@ class UserAuthContextTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanGetUserAuthContext) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetUserAuthContext) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetUserAuthContext) } scenario("We will call the deleteUserAuthContexts endpoint without a user credentials", ApiEndpoint3, VersionOfApi) { @@ -102,7 +102,7 @@ class UserAuthContextTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will call the deleteUserAuthContexts endpoint without a proper role", ApiEndpoint3, VersionOfApi) { When("We make a request v3.1.0") @@ -111,7 +111,7 @@ class UserAuthContextTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanDeleteUserAuthContext) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanDeleteUserAuthContext) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanDeleteUserAuthContext) } scenario("We will call the deleteUserAuthContextById endpoint without a user credentials", ApiEndpoint4, VersionOfApi) { @@ -121,7 +121,7 @@ class UserAuthContextTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } scenario("We will call the deleteUserAuthContextById endpoint without a proper role", ApiEndpoint4, VersionOfApi) { When("We make a request v3.1.0") @@ -130,7 +130,7 @@ class UserAuthContextTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanDeleteUserAuthContext) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanDeleteUserAuthContext) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanDeleteUserAuthContext) } scenario("We will call the Add, Get and Delete endpoints with user credentials and role", ApiEndpoint1, ApiEndpoint2, ApiEndpoint3, ApiEndpoint4, VersionOfApi) { diff --git a/src/test/scala/code/api/v3_1_0/WebhooksTest.scala b/src/test/scala/code/api/v3_1_0/WebhooksTest.scala index c701b58a4..1c489a41a 100644 --- a/src/test/scala/code/api/v3_1_0/WebhooksTest.scala +++ b/src/test/scala/code/api/v3_1_0/WebhooksTest.scala @@ -65,7 +65,7 @@ class WebhooksTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } } @@ -79,7 +79,7 @@ class WebhooksTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanCreateWebhook) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanCreateWebhook) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanCreateWebhook) } scenario("We will try to create the web hook with a proper Role " + canCreateWebhook + " but without proper trigger name", ApiEndpoint2, VersionOfApi) { @@ -92,7 +92,7 @@ class WebhooksTest extends V310ServerSetup { response310.code should equal(400) val failMsg = IncorrectTriggerName + postJsonIncorrectTriggerName.trigger_name + ". Possible values are " + ApiTrigger.availableTriggers.sorted.mkString(", ") And("error should be " + failMsg) - response310.body.extract[ErrorMessage].error should include (failMsg) + response310.body.extract[ErrorMessage].message should include (failMsg) } scenario("We will try to create the web hook with a proper Role " + canCreateWebhook, ApiEndpoint2, VersionOfApi) { @@ -117,7 +117,7 @@ class WebhooksTest extends V310ServerSetup { Then("We should get a 400") response310.code should equal(400) And("error should be " + UserNotLoggedIn) - response310.body.extract[ErrorMessage].error should equal (UserNotLoggedIn) + response310.body.extract[ErrorMessage].message should equal (UserNotLoggedIn) } } @@ -130,7 +130,7 @@ class WebhooksTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanGetWebhooks) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanGetWebhooks) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanGetWebhooks) } scenario("We will try to get web hooks with a proper Role " + canGetWebhooks, ApiEndpoint1, VersionOfApi) { val bankId = randomBankId @@ -154,7 +154,7 @@ class WebhooksTest extends V310ServerSetup { Then("We should get a 403") response310.code should equal(403) And("error should be " + UserHasMissingRoles + CanUpdateWebhook) - response310.body.extract[ErrorMessage].error should equal (UserHasMissingRoles + CanUpdateWebhook) + response310.body.extract[ErrorMessage].message should equal (UserHasMissingRoles + CanUpdateWebhook) } scenario("We will try to Update an Account Web Hook with a proper Role " + canUpdateWebhook, ApiEndpoint3, VersionOfApi) { val bankId = randomBankId From 386c40e99bffef018832567d7c9237201b8746bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Wed, 16 Jan 2019 10:15:24 +0100 Subject: [PATCH 2/3] OAuth2 Google's POC --- src/main/scala/code/api/OAuth2.scala | 184 ++++++++++++++++++--------- 1 file changed, 125 insertions(+), 59 deletions(-) diff --git a/src/main/scala/code/api/OAuth2.scala b/src/main/scala/code/api/OAuth2.scala index 04f509e65..7f22771da 100644 --- a/src/main/scala/code/api/OAuth2.scala +++ b/src/main/scala/code/api/OAuth2.scala @@ -30,6 +30,8 @@ import code.api.util.{APIUtil, CallContext, ErrorMessages, JwtUtil} import code.model.User import code.users.Users import code.util.Helper.MdcLoggable +import com.nimbusds.jwt.JWTClaimsSet +import com.nimbusds.openid.connect.sdk.claims.IDTokenClaimsSet import net.liftweb.common._ import net.liftweb.http.rest.RestHelper @@ -51,28 +53,6 @@ object OAuth2Handshake extends RestHelper with MdcLoggable { valueOfAuthReqHeaderField } - private def verifyJwt(jwt: String) = { - APIUtil.getPropsAsBoolValue("oauth2.jwt.use.ssl", false) match { - case true => - JwtUtil.verifyRsaSignedJwt(jwt) - case false => - JwtUtil.verifyHmacSignedJwt(jwt) - } - } - - private def validateAccessToken(accessToken: String) = { - APIUtil.getPropsValue("oauth2.jwk_set.url") match { - case Full(url) => - JwtUtil.validateAccessToken(accessToken, url) - case ParamFailure(a, b, c, apiFailure : APIFailure) => - ParamFailure(a, b, c, apiFailure : APIFailure) - case Failure(msg, t, c) => - Failure(msg, t, c) - case _ => - Failure(ErrorMessages.Oauth2ThereIsNoUrlOfJwkSet) - } - } - /* Method for Old Style Endpoints */ @@ -80,17 +60,32 @@ object OAuth2Handshake extends RestHelper with MdcLoggable { APIUtil.getPropsAsBoolValue("allow_oauth2_login", true) match { case true => val value = getValueOfOAuh2HeaderField(sc) - validateAccessToken(value) match { - case Full(_) => - val username = JwtUtil.getSubject(value).getOrElse("") - (Users.users.vend.getUserByUserName(username), Some(sc)) - case ParamFailure(a, b, c, apiFailure : APIFailure) => - (ParamFailure(a, b, c, apiFailure : APIFailure), Some(sc)) - case Failure(msg, t, c) => - (Failure(msg, t, c), Some(sc)) - case _ => - (Failure(ErrorMessages.Oauth2IJwtCannotBeVerified), Some(sc)) + if (Google.isIssuer(value)) { + Google.validateIdToken(value) match { + case Full(_) => + val user = Google.getOrCreateResourceUser(value) + (user, Some(sc)) + case ParamFailure(a, b, c, apiFailure : APIFailure) => + (ParamFailure(a, b, c, apiFailure : APIFailure), Some(sc)) + case Failure(msg, t, c) => + (Failure(msg, t, c), Some(sc)) + case _ => + (Failure(ErrorMessages.Oauth2IJwtCannotBeVerified), Some(sc)) + } + } else { + MITREId.validateAccessToken(value) match { + case Full(_) => + val username = JwtUtil.getSubject(value).getOrElse("") + (Users.users.vend.getUserByUserName(username), Some(sc)) + case ParamFailure(a, b, c, apiFailure : APIFailure) => + (ParamFailure(a, b, c, apiFailure : APIFailure), Some(sc)) + case Failure(msg, t, c) => + (Failure(msg, t, c), Some(sc)) + case _ => + (Failure(ErrorMessages.Oauth2IJwtCannotBeVerified), Some(sc)) + } } + case false => (Failure(ErrorMessages.Oauth2IsNotAllowed), Some(sc)) } @@ -102,40 +97,111 @@ object OAuth2Handshake extends RestHelper with MdcLoggable { APIUtil.getPropsAsBoolValue("allow_oauth2_login", true) match { case true => val value = getValueOfOAuh2HeaderField(sc) - validateAccessToken(value) match { - case Full(_) => - val username = JwtUtil.getSubject(value).getOrElse("") - for { - user <- Users.users.vend.getUserByUserNameFuture(username) - } yield { - (user, Some(sc)) - } - case ParamFailure(a, b, c, apiFailure : APIFailure) => - Future((ParamFailure(a, b, c, apiFailure : APIFailure), Some(sc))) - case Failure(msg, t, c) => - Future((Failure(msg, t, c), Some(sc))) - case _ => - Future((Failure(ErrorMessages.Oauth2IJwtCannotBeVerified), Some(sc))) + if (Google.isIssuer(value)) { + Google.validateIdToken(value) match { + case Full(_) => + for { + user <- Google.getOrCreateResourceUserFuture(value) + } yield { + (user, Some(sc)) + } + case ParamFailure(a, b, c, apiFailure : APIFailure) => + Future((ParamFailure(a, b, c, apiFailure : APIFailure), Some(sc))) + case Failure(msg, t, c) => + Future((Failure(msg, t, c), Some(sc))) + case _ => + Future((Failure(ErrorMessages.Oauth2IJwtCannotBeVerified), Some(sc))) + } + } else { + MITREId.validateAccessToken(value) match { + case Full(_) => + val username = JwtUtil.getSubject(value).getOrElse("") + for { + user <- Users.users.vend.getUserByUserNameFuture(username) + } yield { + (user, Some(sc)) + } + case ParamFailure(a, b, c, apiFailure : APIFailure) => + Future((ParamFailure(a, b, c, apiFailure : APIFailure), Some(sc))) + case Failure(msg, t, c) => + Future((Failure(msg, t, c), Some(sc))) + case _ => + Future((Failure(ErrorMessages.Oauth2IJwtCannotBeVerified), Some(sc))) + } } case false => Future((Failure(ErrorMessages.Oauth2IsNotAllowed), Some(sc))) } } - /** - * This function creates user based on "iss" and "sub" fields - * It is mapped in next way: - * iss => ResourceUser.provider_ - * sub => ResourceUser.providerId - * @param cc CallContext - * @return Existing or New User - */ - def getOrCreateResourceUserFuture(cc: CallContext): Future[Box[User]] = { - val value = getValueOfOAuh2HeaderField(cc) - val sub = JwtUtil.getSubject(value).getOrElse("") - val iss = JwtUtil.getIssuer(value).getOrElse("") - Users.users.vend.getOrCreateUserByProviderIdFuture(provider = iss, idGivenByProvider = sub) + + object MITREId { + def validateAccessToken(accessToken: String): Box[JWTClaimsSet] = { + APIUtil.getPropsValue("oauth2.jwk_set.url") match { + case Full(url) => + JwtUtil.validateAccessToken(accessToken, url) + case ParamFailure(a, b, c, apiFailure : APIFailure) => + ParamFailure(a, b, c, apiFailure : APIFailure) + case Failure(msg, t, c) => + Failure(msg, t, c) + case _ => + Failure(ErrorMessages.Oauth2ThereIsNoUrlOfJwkSet) + } + } } + + object Google { + def isIssuer(jwtToken: String): Boolean = { + JwtUtil.getIssuer(jwtToken).map(_.contains("accounts.google.com")).getOrElse(false) + } + def validateIdToken(idToken: String): Box[IDTokenClaimsSet] = { + APIUtil.getPropsValue("oauth2.jwk_set.url") match { + case Full(url) => + JwtUtil.validateIdToken(idToken, url) + case ParamFailure(a, b, c, apiFailure : APIFailure) => + ParamFailure(a, b, c, apiFailure : APIFailure) + case Failure(msg, t, c) => + Failure(msg, t, c) + case _ => + Failure(ErrorMessages.Oauth2ThereIsNoUrlOfJwkSet) + } + } + /** New Style Endpoints + * This function creates user based on "iss" and "sub" fields + * It is mapped in next way: + * iss => ResourceUser.provider_ + * sub => ResourceUser.providerId + * @param idToken + * @return an existing or a new user + */ + def getOrCreateResourceUserFuture(idToken: String): Future[Box[User]] = { + val subject = JwtUtil.getSubject(idToken).getOrElse("") + val issuer = JwtUtil.getIssuer(idToken).getOrElse("") + Users.users.vend.getOrCreateUserByProviderIdFuture(provider = issuer, idGivenByProvider = subject) + } + /** Old Style Endpoints + * This function creates user based on "iss" and "sub" fields + * It is mapped in next way: + * iss => ResourceUser.provider_ + * sub => ResourceUser.providerId + * @param idToken + * @return an existing or a new user + */ + def getOrCreateResourceUser(idToken: String): Box[User] = { + val subject = JwtUtil.getSubject(idToken).getOrElse("") + val issuer = JwtUtil.getIssuer(idToken).getOrElse("") + Users.users.vend.getUserByProviderId(provider = issuer, idGivenByProvider = subject).or { // Find a user + Users.users.vend.createResourceUser( // Otherwise create a new one + provider = issuer, + providerId = Some(subject), + name = Some(subject), + email = None, + userId = None + ) + } + } + } + } \ No newline at end of file From 47b3f422719960df21fc829b8a1868f47cc3c794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Wed, 16 Jan 2019 13:11:31 +0100 Subject: [PATCH 3/3] OAuth2 Google - done --- src/main/scala/code/api/GatewayLogin.scala | 2 +- src/main/scala/code/api/OAuth2.scala | 18 +++++++++++++++--- .../code/remotedata/RemotedataUsers.scala | 4 ++-- .../code/remotedata/RemotedataUsersActor.scala | 6 +++--- src/main/scala/code/users/LiftUsers.scala | 10 +++++----- src/main/scala/code/users/Users.scala | 4 ++-- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/main/scala/code/api/GatewayLogin.scala b/src/main/scala/code/api/GatewayLogin.scala index 02ec48602..ca385a578 100755 --- a/src/main/scala/code/api/GatewayLogin.scala +++ b/src/main/scala/code/api/GatewayLogin.scala @@ -304,7 +304,7 @@ object GatewayLogin extends RestHelper with MdcLoggable { } case Full((s, accounts, callContextNew)) if getErrors(s).forall(_.equalsIgnoreCase("")) => // CBS returned response without any error logger.debug("CBS returned proper response") - Users.users.vend.getOrCreateUserByProviderIdFuture(provider = gateway, idGivenByProvider = username) map { + Users.users.vend.getOrCreateUserByProviderIdFuture(provider = gateway, idGivenByProvider = username, name = None, email = None) map { case Full(u) => val isFirst = getFieldFromPayloadJson(jwtPayload, "is_first") // Update user account views, only when is_first == true in the GatewayLogin token's payload . diff --git a/src/main/scala/code/api/OAuth2.scala b/src/main/scala/code/api/OAuth2.scala index 7f22771da..8b85b03a2 100644 --- a/src/main/scala/code/api/OAuth2.scala +++ b/src/main/scala/code/api/OAuth2.scala @@ -151,6 +151,13 @@ object OAuth2Handshake extends RestHelper with MdcLoggable { } object Google { + private def getClaim(name: String, idToken: String): Option[String] = { + val claim = JwtUtil.getClaim(name = name, jwtToken = idToken).asString() + claim match { + case null => None + case string => Some(string) + } + } def isIssuer(jwtToken: String): Boolean = { JwtUtil.getIssuer(jwtToken).map(_.contains("accounts.google.com")).getOrElse(false) } @@ -177,7 +184,12 @@ object OAuth2Handshake extends RestHelper with MdcLoggable { def getOrCreateResourceUserFuture(idToken: String): Future[Box[User]] = { val subject = JwtUtil.getSubject(idToken).getOrElse("") val issuer = JwtUtil.getIssuer(idToken).getOrElse("") - Users.users.vend.getOrCreateUserByProviderIdFuture(provider = issuer, idGivenByProvider = subject) + Users.users.vend.getOrCreateUserByProviderIdFuture( + provider = issuer, + idGivenByProvider = subject, + name = getClaim(name = "name", idToken = idToken).orElse(Some(subject)), + email = getClaim(name = "email", idToken = idToken) + ) } /** Old Style Endpoints * This function creates user based on "iss" and "sub" fields @@ -194,8 +206,8 @@ object OAuth2Handshake extends RestHelper with MdcLoggable { Users.users.vend.createResourceUser( // Otherwise create a new one provider = issuer, providerId = Some(subject), - name = Some(subject), - email = None, + name = getClaim(name = "name", idToken = idToken).orElse(Some(subject)), + email = getClaim(name = "email", idToken = idToken), userId = None ) } diff --git a/src/main/scala/code/remotedata/RemotedataUsers.scala b/src/main/scala/code/remotedata/RemotedataUsers.scala index 7de9a6fc6..4252adcba 100644 --- a/src/main/scala/code/remotedata/RemotedataUsers.scala +++ b/src/main/scala/code/remotedata/RemotedataUsers.scala @@ -35,8 +35,8 @@ object RemotedataUsers extends ObpActorInit with Users { def getUserByProviderIdFuture(provider : String, idGivenByProvider : String) : Future[Box[User]] = (actor ? cc.getUserByProviderIdFuture(provider, idGivenByProvider)).mapTo[Box[User]] - def getOrCreateUserByProviderIdFuture(provider : String, idGivenByProvider : String) : Future[Box[User]] = - (actor ? cc.getOrCreateUserByProviderIdFuture(provider, idGivenByProvider)).mapTo[Box[User]] + def getOrCreateUserByProviderIdFuture(provider : String, idGivenByProvider : String, name: Option[String], email: Option[String]) : Future[Box[User]] = + (actor ? cc.getOrCreateUserByProviderIdFuture(provider, idGivenByProvider, name, email)).mapTo[Box[User]] def getUserByUserId(userId : String) : Box[User] = getValueFromFuture( (actor ? cc.getUserByUserId(userId)).mapTo[Box[User]] diff --git a/src/main/scala/code/remotedata/RemotedataUsersActor.scala b/src/main/scala/code/remotedata/RemotedataUsersActor.scala index db5160caf..58da10b4a 100644 --- a/src/main/scala/code/remotedata/RemotedataUsersActor.scala +++ b/src/main/scala/code/remotedata/RemotedataUsersActor.scala @@ -36,9 +36,9 @@ class RemotedataUsersActor extends Actor with ObpActorHelper with MdcLoggable { logger.debug("getUserByProviderIdFuture(" + provider +"," + idGivenByProvider +")") sender ! (mapper.getUserByProviderId(provider, idGivenByProvider)) - case cc.getOrCreateUserByProviderIdFuture(provider : String, idGivenByProvider : String) => - logger.debug("getOrCreateUserByProviderIdFuture(" + provider +"," + idGivenByProvider +")") - sender ! (mapper.getOrCreateUserByProviderId(provider, idGivenByProvider)) + case cc.getOrCreateUserByProviderIdFuture(provider : String, idGivenByProvider : String, name: Option[String], email: Option[String]) => + logger.debug("getOrCreateUserByProviderIdFuture(" + provider +"," + idGivenByProvider + name + email +")") + sender ! (mapper.getOrCreateUserByProviderId(provider, idGivenByProvider, name, email)) case cc.getUserByUserId(userId: String) => logger.debug("getUserByUserId(" + userId +")") diff --git a/src/main/scala/code/users/LiftUsers.scala b/src/main/scala/code/users/LiftUsers.scala index 67e2e535d..be43dede9 100644 --- a/src/main/scala/code/users/LiftUsers.scala +++ b/src/main/scala/code/users/LiftUsers.scala @@ -42,20 +42,20 @@ object LiftUsers extends Users with MdcLoggable{ } } - def getOrCreateUserByProviderId(provider : String, idGivenByProvider : String) : Box[User] = { + def getOrCreateUserByProviderId(provider : String, idGivenByProvider : String, name: Option[String], email: Option[String]) : Box[User] = { Users.users.vend.getUserByProviderId(provider = provider, idGivenByProvider = idGivenByProvider).or { // Find a user Users.users.vend.createResourceUser( // Otherwise create a new one provider = provider, providerId = Some(idGivenByProvider), - name = Some(idGivenByProvider), - email = None, + name = name, + email = email, userId = None ) } } - def getOrCreateUserByProviderIdFuture(provider : String, idGivenByProvider : String) : Future[Box[User]] = { + def getOrCreateUserByProviderIdFuture(provider : String, idGivenByProvider : String, name: Option[String], email: Option[String]) : Future[Box[User]] = { Future { - getOrCreateUserByProviderId(provider, idGivenByProvider) + getOrCreateUserByProviderId(provider, idGivenByProvider, name, email) } } diff --git a/src/main/scala/code/users/Users.scala b/src/main/scala/code/users/Users.scala index 73e2c45b5..eaac05368 100644 --- a/src/main/scala/code/users/Users.scala +++ b/src/main/scala/code/users/Users.scala @@ -33,7 +33,7 @@ trait Users { def getUserByProviderId(provider : String, idGivenByProvider : String) : Box[User] def getUserByProviderIdFuture(provider : String, idGivenByProvider : String) : Future[Box[User]] - def getOrCreateUserByProviderIdFuture(provider : String, idGivenByProvider : String) : Future[Box[User]] + def getOrCreateUserByProviderIdFuture(provider : String, idGivenByProvider : String, name: Option[String], email: Option[String]) : Future[Box[User]] //resourceuser has two ids: id(Long)and userid_(String), this method use userid_(String) def getUserByUserId(userId : String) : Box[User] @@ -68,7 +68,7 @@ class RemotedataUsersCaseClasses { case class getResourceUserByResourceUserIdFuture(id : Long) case class getUserByProviderId(provider : String, idGivenByProvider : String) case class getUserByProviderIdFuture(provider : String, idGivenByProvider : String) - case class getOrCreateUserByProviderIdFuture(provider : String, idGivenByProvider : String) + case class getOrCreateUserByProviderIdFuture(provider : String, idGivenByProvider : String, name: Option[String], email: Option[String]) case class getUserByUserId(userId : String) case class getUserByUserIdFuture(userId : String) case class getUsersByUserIdsFuture(userId : List[String])