From c6595ebbf09bfe8a7dfd1c12904bf7156a03e50c Mon Sep 17 00:00:00 2001 From: Ayoub BENALI Date: Fri, 19 Jul 2013 14:37:06 +0200 Subject: [PATCH] removed duplication in the test file. --- src/main/scala/code/util/APIUtil.scala | 6 + src/test/scala/code/api/API12Test.scala | 1764 ++++++++--------------- 2 files changed, 592 insertions(+), 1178 deletions(-) diff --git a/src/main/scala/code/util/APIUtil.scala b/src/main/scala/code/util/APIUtil.scala index af2bcfa03..e5dddbcdc 100644 --- a/src/main/scala/code/util/APIUtil.scala +++ b/src/main/scala/code/util/APIUtil.scala @@ -148,6 +148,12 @@ object APIUtil { sign(consumer, Some(token), Some(verifier), None) /** sign a request with a consumer and a token, e.g. an OAuth-signed API request */ def <@ (consumer: Consumer, token: Token): Request = sign(consumer, Some(token), None, None) + def <@ (consumerAndToken: Option[(Consumer,Token)]): Request = { + consumerAndToken match { + case Some(cAndt) => sign(cAndt._1, Some(cAndt._2), None, None) + case _ => rb + } + } /** Sign request by reading Post (<<) and query string parameters */ private def sign(consumer: Consumer, token: Option[Token], verifier: Option[String], callback: Option[String]) = { diff --git a/src/test/scala/code/api/API12Test.scala b/src/test/scala/code/api/API12Test.scala index 680117e49..8060c06a7 100644 --- a/src/test/scala/code/api/API12Test.scala +++ b/src/test/scala/code/api/API12Test.scala @@ -95,7 +95,7 @@ class API1_2Test extends ServerSetup{ // create the access token lazy val tokenDuration = weeks(4) - lazy val user1 = + lazy val obpuser1 = OBPUser.create. email("testuser1@example.com"). password(randomString(10)). @@ -110,7 +110,7 @@ class API1_2Test extends ServerSetup{ HostedAccount.findAll.map(bankAccount => { Privilege.create. account(bankAccount). - user(user1). + user(obpuser1). saveMe }) for{ @@ -128,7 +128,7 @@ class API1_2Test extends ServerSetup{ OBPToken.create. tokenType(Access). consumerId(testConsumer.id). - userId(user1.email). + userId(obpuser1.email). key(randomString(40).toLowerCase). secret(randomString(40).toLowerCase). duration(tokenDuration). @@ -139,7 +139,7 @@ class API1_2Test extends ServerSetup{ lazy val token = new Token(testToken.key, testToken.secret) // create a user for test purposes - lazy val user2 = + lazy val obpuser2 = OBPUser.create. email("testuser2@example.com"). password(randomString(10)). @@ -153,7 +153,7 @@ class API1_2Test extends ServerSetup{ OBPToken.create. tokenType(Access). consumerId(testConsumer.id). - userId(user2.email). + userId(obpuser2.email). key(randomString(40).toLowerCase). secret(randomString(40).toLowerCase). duration(tokenDuration). @@ -164,7 +164,7 @@ class API1_2Test extends ServerSetup{ lazy val token2 = new Token(testToken2.key, testToken2.secret) // create a user for test purposes - lazy val user3 = + lazy val obpuser3 = OBPUser.create. email("testuser3@example.com"). password(randomString(10)). @@ -178,7 +178,7 @@ class API1_2Test extends ServerSetup{ OBPToken.create. tokenType(Access). consumerId(testConsumer.id). - userId(user3.email). + userId(obpuser3.email). key(randomString(40).toLowerCase). secret(randomString(40).toLowerCase). duration(tokenDuration). @@ -188,6 +188,9 @@ class API1_2Test extends ServerSetup{ lazy val token3 = new Token(testToken3.key, testToken3.secret) + val user1 = Some((consumer, token)) + val user2 = Some((consumer, token2)) + val user3 = Some((consumer, token3)) /************************* test tags ************************/ @@ -286,19 +289,19 @@ class API1_2Test extends ServerSetup{ } def randomPrivateAccount(bankId : String) : AccountJSON = { - val accountsJson = getPrivateAccounts(bankId).body.extract[AccountsJSON].accounts + val accountsJson = getPrivateAccounts(bankId, user1).body.extract[AccountsJSON].accounts val randomPosition = nextInt(accountsJson.size) accountsJson(randomPosition) } def randomAccountPermission(bankId : String, accountId : String) : PermissionJSON = { - val persmissionsInfo = getAccountPermissions(bankId, accountId).body.extract[PermissionsJSON] + val persmissionsInfo = getAccountPermissions(bankId, accountId, user1).body.extract[PermissionsJSON] val randomPermission = nextInt(persmissionsInfo.permissions.size) persmissionsInfo.permissions(randomPermission) } def randomOtherBankAccount(bankId : String, accountId : String, viewId : String): OtherAccountJSON = { - val otherAccounts = getTheOtherBankAccounts(bankId, accountId, viewId).body.extract[OtherAccountsJSON].other_accounts + val otherAccounts = getTheOtherBankAccounts(bankId, accountId, viewId, user1).body.extract[OtherAccountsJSON].other_accounts otherAccounts(nextInt(otherAccounts.size)) } @@ -314,14 +317,14 @@ class API1_2Test extends ServerSetup{ } def randomTransaction(bankId : String, accountId : String, viewId: String) : TransactionJSON = { - val transactionsJson = getTransactions(bankId, accountId, viewId).body.extract[TransactionsJSON].transactions + val transactionsJson = getTransactions(bankId, accountId, viewId, user1).body.extract[TransactionsJSON].transactions val randomPosition = nextInt(transactionsJson.size) transactionsJson(randomPosition) } def randomViewsIdsToGrant(bankId : String, accountId : String) : List[String]= { //get the view ids of the available views on the bank accounts - val viewsIds = getAccountViews(bankId, accountId).body.extract[ViewsJSON].views.map(_.id) + val viewsIds = getAccountViews(bankId, accountId, user1).body.extract[ViewsJSON].views.map(_.id) //choose randomly some view ids to grant val (viewsIdsToGrant, _) = viewsIds.splitAt(nextInt(viewsIds.size) + 1) viewsIdsToGrant @@ -357,23 +360,13 @@ class API1_2Test extends ServerSetup{ makeGetRequest(request) } - def getPrivateAccounts(bankId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / "private" <@(consumer,token) + def getPrivateAccounts(bankId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / "private" <@(consumerAndToken) makeGetRequest(request) } - def getBankAccounts(bankId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" - makeGetRequest(request) - } - - def getBankAccountsWithToken(bankId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" <@(consumer,token) - makeGetRequest(request) - } - - def getPrivateAccountsWithOutToken(bankId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / "private" + def getBankAccounts(bankId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" <@(consumerAndToken) makeGetRequest(request) } @@ -382,929 +375,343 @@ class API1_2Test extends ServerSetup{ makeGetRequest(request) } - def getPrivateBankAccountDetails(bankId : String, accountId : String, viewId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "account" <@(consumer,token) + def getPrivateBankAccountDetails(bankId : String, accountId : String, viewId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "account" <@(consumerAndToken) makeGetRequest(request) } - def getAccountViews(bankId : String, accountId : String): APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "views" <@(consumer,token) + def getAccountViews(bankId : String, accountId : String, consumerAndToken: Option[(Consumer, Token)]): APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "views" <@(consumerAndToken) makeGetRequest(request) } - def getAccountViewsWithoutToken(bankId : String, accountId : String): APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "views" - makeGetRequest(request) - } - - def getAccountViewsWithoutOwnerAccess(bankId : String, accountId : String): APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "views" <@(consumer,token3) - makeGetRequest(request) - } - - def postView(bankId: String, accountId: String, view: ViewCreationJSON): APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "views").POST <@(consumer,token) + def postView(bankId: String, accountId: String, view: ViewCreationJSON, consumerAndToken: Option[(Consumer, Token)]): APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "views").POST <@(consumerAndToken) makePostRequest(request, write(view)) } - def postViewWithoutToken(bankId: String, accountId: String, view: ViewCreationJSON): APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "views").POST - makePostRequest(request, write(view)) - } - - def postViewWithoutOwnerAccess(bankId: String, accountId: String, view: ViewCreationJSON): APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "views").POST <@(consumer,token3) - makePostRequest(request, write(view)) - } - - def deleteView(bankId: String, accountId: String, viewId: String): APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "views" / viewId).DELETE <@(consumer,token) + def deleteView(bankId: String, accountId: String, viewId: String, consumerAndToken: Option[(Consumer, Token)]): APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "views" / viewId).DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteViewWithoutToken(bankId: String, accountId: String, viewId: String): APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "views" / viewId).DELETE - makeDeleteRequest(request) - } - - def deleteViewWithoutOwnerAccess(bankId: String, accountId: String, viewId: String): APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "views" / viewId).DELETE <@(consumer,token3) - makeDeleteRequest(request) - } - - def getAccountPermissions(bankId : String, accountId : String): APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions" <@(consumer,token) + def getAccountPermissions(bankId : String, accountId : String, consumerAndToken: Option[(Consumer, Token)]): APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions" <@(consumerAndToken) makeGetRequest(request) } - def getAccountPermissionsWithoutToken(bankId : String, accountId : String) : APIResponse= { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions" + def getUserAccountPermission(bankId : String, accountId : String, userId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse= { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId <@(consumerAndToken) makeGetRequest(request) } - def getAccountPermissionsWithoutOwnerAccess(bankId : String, accountId : String) : APIResponse= { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions" <@(consumer,token2) - makeGetRequest(request) - } - - def getUserAccountPermission(bankId : String, accountId : String, userId : String) : APIResponse= { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId <@(consumer,token) - makeGetRequest(request) - } - - def getUserAccountPermissionWithoutToken(bankId : String, accountId : String, userId : String) : APIResponse= { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId - makeGetRequest(request) - } - - def grantUserAccessToView(bankId : String, accountId : String, userId : String, viewId : String) : APIResponse= { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views" / viewId).POST.<@(consumer,token) + def grantUserAccessToView(bankId : String, accountId : String, userId : String, viewId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse= { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views" / viewId).POST <@(consumerAndToken) makePostRequest(request) } - def grantUserAccessToViewWithWrongUser(bankId : String, accountId : String, userId : String, viewId : String) : APIResponse= { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views" / viewId).POST.<@(consumer,token3) - makePostRequest(request) - } - - def grantUserAccessToViews(bankId : String, accountId : String, userId : String, viewIds : List[String]) : APIResponse= { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views").POST.<@(consumer,token) + def grantUserAccessToViews(bankId : String, accountId : String, userId : String, viewIds : List[String], consumerAndToken: Option[(Consumer, Token)]) : APIResponse= { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views").POST <@(consumerAndToken) val viewsJson = ViewIdsJson(viewIds) makePostRequest(request, write(viewsJson)) } - def grantUserAccessToViewsWithWrongUser(bankId : String, accountId : String, userId : String, viewIds : List[String]) : APIResponse= { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views").POST.<@(consumer,token3) - val viewsJson = ViewIdsJson(viewIds) - makePostRequest(request, write(viewsJson)) - } - - def revokeUserAccessToView(bankId : String, accountId : String, userId : String, viewId : String) : APIResponse= { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views" / viewId).DELETE.<@(consumer,token) + def revokeUserAccessToView(bankId : String, accountId : String, userId : String, viewId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse= { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views" / viewId).DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def revokeUserAccessToViewWithoutOwnerAccess(bankId : String, accountId : String, userId : String, viewId : String) : APIResponse= { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views" / viewId).DELETE.<@(consumer,token3) + def revokeUserAccessToAllViews(bankId : String, accountId : String, userId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse= { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def revokeUserAccessToAllViews(bankId : String, accountId : String, userId : String) : APIResponse= { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views").DELETE.<@(consumer,token) - makeDeleteRequest(request) - } - - def revokeUserAccessToAllViewsWithoutOwnerAccess(bankId : String, accountId : String, userId : String) : APIResponse= { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / "permissions"/ userId / "views" ).DELETE.<@(consumer,token3) - makeDeleteRequest(request) - } - - def getTheOtherBankAccounts(bankId : String, accountId : String, viewId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" <@(consumer,token) + def getTheOtherBankAccounts(bankId : String, accountId : String, viewId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" <@(consumerAndToken) makeGetRequest(request) } - def getTheOtherBankAccountsWithoutToken(bankId : String, accountId : String, viewId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" + def getTheOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId <@(consumerAndToken) makeGetRequest(request) } - def getTheOtherBankAccountsWithWrongUser(bankId : String, accountId : String, viewId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" <@(consumer,token3) + def getMetadataOfOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "metadata" <@(consumerAndToken) makeGetRequest(request) } - def getTheOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId <@(consumer,token) + def getThePublicAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias" <@(consumerAndToken) makeGetRequest(request) } - def getTheOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId - makeGetRequest(request) - } - - def getTheOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId <@(consumer,token3) - makeGetRequest(request) - } - - def getMetadataOfOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "metadata" <@(consumer,token) - makeGetRequest(request) - } - - def getMetadataOfOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "metadata" - makeGetRequest(request) - } - - def getMetadataOfOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "metadata" <@(consumer,token3) - makeGetRequest(request) - } - - def getThePublicAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias" <@(consumer, token) - makeGetRequest(request) - } - - def getThePublicAliasForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias" - makeGetRequest(request) - } - - def getThePublicAliasForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias" <@(consumer, token3) - makeGetRequest(request) - } - - def postAPublicAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias").POST <@(consumer,token) + def postAPublicAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias").POST <@(consumerAndToken) val aliasJson = AliasJSON(alias) makePostRequest(request, write(aliasJson)) } - def postAPublicAliasForAnOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias" - val aliasJson = AliasJSON(alias) - makePostRequest(request, write(aliasJson)) - } - - def postAPublicAliasForAnOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias").POST <@(consumer,token3) - val aliasJson = AliasJSON(alias) - makePostRequest(request, write(aliasJson)) - } - - def updateThePublicAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias").PUT <@(consumer, token) + def updateThePublicAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias").PUT <@(consumerAndToken) val aliasJson = AliasJSON(alias) makePutRequest(request, write(aliasJson)) } - def updateThePublicAliasForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias" - val aliasJson = AliasJSON(alias) - makePutRequest(request, write(aliasJson)) - } - - def updateThePublicAliasForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias").PUT <@(consumer, token3) - val aliasJson = AliasJSON(alias) - makePutRequest(request, write(aliasJson)) - } - - def deleteThePublicAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias").DELETE <@(consumer, token) + def deleteThePublicAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteThePublicAliasForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias" - makeDeleteRequest(request) - } - - def deleteThePublicAliasForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "public_alias").DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getThePrivateAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias" <@(consumer, token) + def getThePrivateAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias" <@(consumerAndToken) makeGetRequest(request) } - def getThePrivateAliasForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias" - makeGetRequest(request) - } - - def getThePrivateAliasForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias" <@(consumer, token3) - makeGetRequest(request) - } - - def postAPrivateAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias").POST <@(consumer,token) + def postAPrivateAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias").POST <@(consumerAndToken) val aliasJson = AliasJSON(alias) makePostRequest(request, write(aliasJson)) } - def postAPrivateAliasForAnOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias" - val aliasJson = AliasJSON(alias) - makePostRequest(request, write(aliasJson)) - } - - def postAPrivateAliasForAnOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias").POST <@(consumer,token3) - val aliasJson = AliasJSON(alias) - makePostRequest(request, write(aliasJson)) - } - - def updateThePrivateAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias").PUT <@(consumer, token) + def updateThePrivateAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias").PUT <@(consumerAndToken) val aliasJson = AliasJSON(alias) makePutRequest(request, write(aliasJson)) } - def updateThePrivateAliasForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias" - val aliasJson = AliasJSON(alias) - makePutRequest(request, write(aliasJson)) - } - - def updateThePrivateAliasForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, alias : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias").PUT <@(consumer, token3) - val aliasJson = AliasJSON(alias) - makePutRequest(request, write(aliasJson)) - } - - def deleteThePrivateAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias").DELETE <@(consumer, token) + def deleteThePrivateAliasForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteThePrivateAliasForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias" - makeDeleteRequest(request) + def getMoreInfoForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : String = { + getMetadataOfOneOtherBankAccount(bankId,accountId,viewId,otherBankAccountId,consumerAndToken).body.extract[OtherAccountMetadataJSON].more_info } - def deleteThePrivateAliasForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "private_alias").DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getMoreInfoForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : String = { - getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId).body.extract[OtherAccountMetadataJSON].more_info - } - - def postMoreInfoForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, moreInfo : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info").POST <@(consumer,token) + def postMoreInfoForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, moreInfo : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info").POST <@(consumerAndToken) val moreInfoJson = MoreInfoJSON(moreInfo) makePostRequest(request, write(moreInfoJson)) } - def postMoreInfoForAnOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, moreInfo : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info" - val moreInfoJson = MoreInfoJSON(moreInfo) - makePostRequest(request, write(moreInfoJson)) - } - - def postMoreInfoForAnOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, moreInfo : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info").POST <@(consumer,token3) - val moreInfoJson = MoreInfoJSON(moreInfo) - makePostRequest(request, write(moreInfoJson)) - } - - def updateMoreInfoForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, moreInfo : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info").PUT <@(consumer, token) + def updateMoreInfoForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, moreInfo : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info").PUT <@(consumerAndToken) val moreInfoJson = MoreInfoJSON(moreInfo) makePutRequest(request, write(moreInfoJson)) } - def updateMoreInfoForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, moreInfo : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info" - val moreInfoJson = MoreInfoJSON(moreInfo) - makePutRequest(request, write(moreInfoJson)) - } - - def updateMoreInfoForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, moreInfo : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info").PUT <@(consumer, token3) - val moreInfoJson = MoreInfoJSON(moreInfo) - makePutRequest(request, write(moreInfoJson)) - } - - def deleteMoreInfoForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info").DELETE <@(consumer, token) + def deleteMoreInfoForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteMoreInfoForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info" - makeDeleteRequest(request) + def getUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : String = { + getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId,consumerAndToken).body.extract[OtherAccountMetadataJSON].URL } - def deleteMoreInfoForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "more_info").DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : String = { - getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId).body.extract[OtherAccountMetadataJSON].URL - } - - def postUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, url : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url").POST <@(consumer,token) + def postUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, url : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url").POST <@(consumerAndToken) val urlJson = UrlJSON(url) makePostRequest(request, write(urlJson)) } - def postUrlForAnOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, url : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url" - val urlJson = UrlJSON(url) - makePostRequest(request, write(urlJson)) - } - - def postUrlForAnOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, url : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url").POST <@(consumer,token3) - val urlJson = UrlJSON(url) - makePostRequest(request, write(urlJson)) - } - - def updateUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, url : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url").PUT <@(consumer, token) + def updateUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, url : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url").PUT <@(consumerAndToken) val urlJson = UrlJSON(url) makePutRequest(request, write(urlJson)) } - def updateUrlForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, url : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url" - val urlJson = UrlJSON(url) - makePutRequest(request, write(urlJson)) - } - - def updateUrlForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, url : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url").PUT <@(consumer, token3) - val urlJson = UrlJSON(url) - makePutRequest(request, write(urlJson)) - } - - def deleteUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url").DELETE <@(consumer, token) + def deleteUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteUrlForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url" - makeDeleteRequest(request) + def getImageUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : String = { + getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId,consumerAndToken).body.extract[OtherAccountMetadataJSON].image_URL } - def deleteUrlForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "url").DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getImageUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : String = { - getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId).body.extract[OtherAccountMetadataJSON].image_URL - } - - def postImageUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, imageUrl : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url").POST <@(consumer,token) + def postImageUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, imageUrl : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url").POST <@(consumerAndToken) val imageUrlJson = ImageUrlJSON(imageUrl) makePostRequest(request, write(imageUrlJson)) } - def postImageUrlForAnOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, imageUrl : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url" - val imageUrlJson = ImageUrlJSON(imageUrl) - makePostRequest(request, write(imageUrlJson)) - } - - def postImageUrlForAnOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, imageUrl : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url").POST <@(consumer,token3) - val imageUrlJson = ImageUrlJSON(imageUrl) - makePostRequest(request, write(imageUrlJson)) - } - - def updateImageUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, imageUrl : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url").PUT <@(consumer, token) + def updateImageUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, imageUrl : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url").PUT <@(consumerAndToken) val imageUrlJson = ImageUrlJSON(imageUrl) makePutRequest(request, write(imageUrlJson)) } - def updateImageUrlForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, imageUrl : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url" - val imageUrlJson = UrlJSON(imageUrl) - makePutRequest(request, write(imageUrlJson)) - } - - def updateImageUrlForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, imageUrl : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url").PUT <@(consumer, token3) - val imageUrlJson = UrlJSON(imageUrl) - makePutRequest(request, write(imageUrlJson)) - } - - def deleteImageUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url").DELETE <@(consumer, token) + def deleteImageUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteImageUrlForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url" - makeDeleteRequest(request) + def getOpenCorporatesUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : String = { + getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId, consumerAndToken).body.extract[OtherAccountMetadataJSON].open_corporates_URL } - def deleteImageUrlForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "image_url").DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getOpenCorporatesUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : String = { - getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId).body.extract[OtherAccountMetadataJSON].open_corporates_URL - } - - def postOpenCorporatesUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, openCorporateUrl : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url").POST <@(consumer,token) + def postOpenCorporatesUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, openCorporateUrl : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url").POST <@(consumerAndToken) val openCorporateUrlJson = OpenCorporateUrlJSON(openCorporateUrl) makePostRequest(request, write(openCorporateUrlJson)) } - def postOpenCorporatesUrlForAnOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, openCorporateUrl : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url" - val openCorporateUrlJson = OpenCorporateUrlJSON(openCorporateUrl) - makePostRequest(request, write(openCorporateUrlJson)) - } - - def postOpenCorporatesUrlForAnOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, openCorporateUrl : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url").POST <@(consumer,token3) - val openCorporateUrlJson = OpenCorporateUrlJSON(openCorporateUrl) - makePostRequest(request, write(openCorporateUrlJson)) - } - - def updateOpenCorporatesUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, openCorporateUrl : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url").PUT <@(consumer, token) + def updateOpenCorporatesUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, openCorporateUrl : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url").PUT <@(consumerAndToken) val openCorporateUrlJson = OpenCorporateUrlJSON(openCorporateUrl) makePutRequest(request, write(openCorporateUrlJson)) } - def updateOpenCorporatesUrlForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, openCorporateUrl : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url" - val openCorporateUrlJson = OpenCorporateUrlJSON(openCorporateUrl) - makePutRequest(request, write(openCorporateUrlJson)) - } - - def updateOpenCorporatesUrlForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, openCorporateUrl : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url").PUT <@(consumer, token3) - val openCorporateUrlJson = OpenCorporateUrlJSON(openCorporateUrl) - makePutRequest(request, write(openCorporateUrlJson)) - } - - def deleteOpenCorporatesUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url").DELETE <@(consumer, token) + def deleteOpenCorporatesUrlForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteOpenCorporatesUrlForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url" - makeDeleteRequest(request) + def getCorporateLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : LocationJSON = { + getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId, consumerAndToken).body.extract[OtherAccountMetadataJSON].corporate_location } - def deleteOpenCorporatesUrlForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "open_corporates_url").DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getCorporateLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : LocationJSON = { - getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId).body.extract[OtherAccountMetadataJSON].corporate_location - } - - def postCorporateLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, corporateLocation : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location").POST <@(consumer,token) + def postCorporateLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, corporateLocation : LocationPlainJSON, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location").POST <@(consumerAndToken) val corpLocationJson = CorporateLocationJSON(corporateLocation) makePostRequest(request, write(corpLocationJson)) } - def postCorporateLocationForAnOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, corporateLocation : LocationPlainJSON) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location" - val corpLocationJson = CorporateLocationJSON(corporateLocation) - makePostRequest(request, write(corpLocationJson)) - } - - def postCorporateLocationForAnOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, corporateLocation : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location").POST <@(consumer,token3) - val corpLocationJson = CorporateLocationJSON(corporateLocation) - makePostRequest(request, write(corpLocationJson)) - } - - def updateCorporateLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, corporateLocation : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location").PUT <@(consumer, token) + def updateCorporateLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, corporateLocation : LocationPlainJSON, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location").PUT <@(consumerAndToken) val corpLocationJson = CorporateLocationJSON(corporateLocation) makePutRequest(request, write(corpLocationJson)) } - def updateCorporateLocationForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, corporateLocation : LocationPlainJSON) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location" - val corpLocationJson = CorporateLocationJSON(corporateLocation) - makePutRequest(request, write(corpLocationJson)) - } - - def updateCorporateLocationForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, corporateLocation : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location").PUT <@(consumer, token3) - val corpLocationJson = CorporateLocationJSON(corporateLocation) - makePutRequest(request, write(corpLocationJson)) - } - - def deleteCorporateLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location").DELETE <@(consumer, token) + def deleteCorporateLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteCorporateLocationForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location" - makeDeleteRequest(request) + def getPhysicalLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : LocationJSON = { + getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId, consumerAndToken).body.extract[OtherAccountMetadataJSON].physical_location } - def deleteCorporateLocationForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "corporate_location").DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getPhysicalLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : LocationJSON = { - getMetadataOfOneOtherBankAccount(bankId,accountId, viewId,otherBankAccountId).body.extract[OtherAccountMetadataJSON].physical_location - } - - def postPhysicalLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, physicalLocation : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location").POST <@(consumer,token) + def postPhysicalLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, physicalLocation : LocationPlainJSON, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location").POST <@(consumerAndToken) val physLocationJson = PhysicalLocationJSON(physicalLocation) makePostRequest(request, write(physLocationJson)) } - def postPhysicalLocationForAnOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, physicalLocation : LocationPlainJSON) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location" - val physLocationJson = PhysicalLocationJSON(physicalLocation) - makePostRequest(request, write(physLocationJson)) - } - - def postPhysicalLocationForAnOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, physicalLocation : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location").POST <@(consumer,token3) - val physLocationJson = PhysicalLocationJSON(physicalLocation) - makePostRequest(request, write(physLocationJson)) - } - - def updatePhysicalLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, physicalLocation : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location").PUT <@(consumer, token) + def updatePhysicalLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, physicalLocation : LocationPlainJSON, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location").PUT <@(consumerAndToken) val physLocationJson = PhysicalLocationJSON(physicalLocation) makePutRequest(request, write(physLocationJson)) } - def updatePhysicalLocationForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, physicalLocation : LocationPlainJSON) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location" - val physLocationJson = PhysicalLocationJSON(physicalLocation) - makePutRequest(request, write(physLocationJson)) - } - - def updatePhysicalLocationForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, physicalLocation : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location").PUT <@(consumer, token3) - val physLocationJson = PhysicalLocationJSON(physicalLocation) - makePutRequest(request, write(physLocationJson)) - } - - def deletePhysicalLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location").DELETE <@(consumer, token) + def deletePhysicalLocationForOneOtherBankAccount(bankId : String, accountId : String, viewId : String, otherBankAccountId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deletePhysicalLocationForOneOtherBankAccountWithoutToken(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location" - makeDeleteRequest(request) - } - - def deletePhysicalLocationForOneOtherBankAccountWithWrongUser(bankId : String, accountId : String, viewId : String, otherBankAccountId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "other_accounts" / otherBankAccountId / "physical_location").DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getTransactions(bankId : String, accountId : String, viewId : String): APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" <@(consumer,token) + def getTransactions(bankId : String, accountId : String, viewId : String, consumerAndToken: Option[(Consumer, Token)]): APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" <@(consumerAndToken) makeGetRequest(request) } - def getTransaction(bankId : String, accountId : String, viewId : String, transactionId : String): APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "transaction" <@(consumer,token) + def getTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, consumerAndToken: Option[(Consumer, Token)]): APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "transaction" <@(consumerAndToken) makeGetRequest(request) } - def getTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String): APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "transaction" + def getNarrativeForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative" <@(consumerAndToken) makeGetRequest(request) } - def getTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String): APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "transaction" <@(consumer,token3) - makeGetRequest(request) - } - - def getNarrativeForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative" <@(consumer, token) - makeGetRequest(request) - } - - def getNarrativeForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative" - makeGetRequest(request) - } - - def getNarrativeForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative" <@(consumer, token3) - makeGetRequest(request) - } - - def postNarrativeForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, narrative: String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative").POST <@(consumer,token) + def postNarrativeForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, narrative: String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative").POST <@(consumerAndToken) val narrativeJson = TransactionNarrativeJSON(narrative) makePostRequest(request, write(narrativeJson)) } - def postNarrativeForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String, narrative: String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative" - val narrativeJson = TransactionNarrativeJSON(narrative) - makePostRequest(request, write(narrativeJson)) - } - - def postNarrativeForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String, narrative: String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative").POST <@(consumer,token3) - val narrativeJson = TransactionNarrativeJSON(narrative) - makePostRequest(request, write(narrativeJson)) - } - - def updateNarrativeForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, narrative: String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative").PUT <@(consumer, token) + def updateNarrativeForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, narrative: String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative").PUT <@(consumerAndToken) val narrativeJson = TransactionNarrativeJSON(narrative) makePutRequest(request, write(narrativeJson)) } - def updateNarrativeForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String, narrative: String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative" - val narrativeJson = TransactionNarrativeJSON(narrative) - makePutRequest(request, write(narrativeJson)) - } - - def updateNarrativeForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String, narrative: String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative").PUT <@(consumer, token3) - val narrativeJson = TransactionNarrativeJSON(narrative) - makePutRequest(request, write(narrativeJson)) - } - - def deleteNarrativeForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative").DELETE <@(consumer, token) + def deleteNarrativeForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteNarrativeForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative" - makeDeleteRequest(request) - } - - def deleteNarrativeForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "narrative").DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getCommentsForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments" <@(consumer, token) + def getCommentsForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments" <@(consumerAndToken) makeGetRequest(request) } - def getCommentsForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments" - makeGetRequest(request) - } - - def getCommentsForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments" <@(consumer, token3) - makeGetRequest(request) - } - - def postCommentForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, comment: PostTransactionCommentJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments").POST <@(consumer,token) + def postCommentForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, comment: PostTransactionCommentJSON, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments").POST <@(consumerAndToken) makePostRequest(request, write(comment)) } - def postCommentForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String, comment: PostTransactionCommentJSON) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments" - makePostRequest(request, write(comment)) - } - - def postCommentForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String, comment: PostTransactionCommentJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments").POST <@(consumer,token3) - makePostRequest(request, write(comment)) - } - - def deleteCommentForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, commentId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments" / commentId).DELETE <@(consumer, token) + def deleteCommentForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, commentId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments" / commentId).DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteCommentForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String, commentId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments" / commentId - makeDeleteRequest(request) - } - - def deleteCommentForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String, commentId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "comments" / commentId).DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getTagsForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags" <@(consumer, token) + def getTagsForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags" <@(consumerAndToken) makeGetRequest(request) } - def getTagsForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags" - makeGetRequest(request) - } - - def getTagsForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags" <@(consumer, token3) - makeGetRequest(request) - } - - def postTagForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, tag: PostTransactionTagJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags").POST <@(consumer,token) + def postTagForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, tag: PostTransactionTagJSON, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags").POST <@(consumerAndToken) makePostRequest(request, write(tag)) } - def postTagForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String, tag: PostTransactionTagJSON) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags" - makePostRequest(request, write(tag)) - } - - def postTagForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String, tag: PostTransactionTagJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags").POST <@(consumer,token3) - makePostRequest(request, write(tag)) - } - - def deleteTagForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, tagId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags" / tagId).DELETE <@(consumer, token) + def deleteTagForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, tagId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags" / tagId).DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteTagForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String, tagId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags" / tagId - makeDeleteRequest(request) - } - - def deleteTagForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String, tagId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "tags" / tagId).DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getImagesForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images" <@(consumer, token) + def getImagesForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images" <@(consumerAndToken) makeGetRequest(request) } - def getImagesForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images" - makeGetRequest(request) - } - - def getImagesForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images" <@(consumer, token3) - makeGetRequest(request) - } - - def postImageForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, image: PostTransactionImageJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images").POST <@(consumer,token) + def postImageForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, image: PostTransactionImageJSON, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images").POST <@(consumerAndToken) makePostRequest(request, write(image)) } - def postImageForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String, image: PostTransactionImageJSON) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images" - makePostRequest(request, write(image)) - } - - def postImageForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String, image: PostTransactionImageJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images").POST <@(consumer,token3) - makePostRequest(request, write(image)) - } - - def deleteImageForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, imageId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images" / imageId).DELETE <@(consumer, token) + def deleteImageForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, imageId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images" / imageId).DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteImageForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String, imageId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images" / imageId - makeDeleteRequest(request) - } - - def deleteImageForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String, imageId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "images" / imageId).DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getWhereForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where" <@(consumer, token) + def getWhereForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where" <@(consumerAndToken) makeGetRequest(request) } - def getWhereForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where" - makeGetRequest(request) - } - - def getWhereForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where" <@(consumer, token3) - makeGetRequest(request) - } - - def postWhereForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, where : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where").POST <@(consumer,token) + def postWhereForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, where : LocationPlainJSON, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where").POST <@(consumerAndToken) val whereJson = PostTransactionWhereJSON(where) makePostRequest(request, write(whereJson)) } - def postWhereForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String, where : LocationPlainJSON) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where" - val whereJson = PostTransactionWhereJSON(where) - makePostRequest(request, write(whereJson)) - } - - def postWhereForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String, where : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where").POST <@(consumer,token3) - val whereJson = PostTransactionWhereJSON(where) - makePostRequest(request, write(whereJson)) - } - - def updateWhereForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, where : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where").PUT <@(consumer, token) + def updateWhereForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, where : LocationPlainJSON, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where").PUT <@(consumerAndToken) val whereJson = PostTransactionWhereJSON(where) makePutRequest(request, write(whereJson)) } - def updateWhereForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String, where : LocationPlainJSON) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where" - val whereJson = PostTransactionWhereJSON(where) - makePutRequest(request, write(whereJson)) - } - - def updateWhereForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String, where : LocationPlainJSON) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where").PUT <@(consumer, token3) - val whereJson = PostTransactionWhereJSON(where) - makePutRequest(request, write(whereJson)) - } - - def deleteWhereForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where").DELETE <@(consumer, token) + def deleteWhereForOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where").DELETE <@(consumerAndToken) makeDeleteRequest(request) } - def deleteWhereForOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where" - makeDeleteRequest(request) - } - - def deleteWhereForOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = (v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "metadata" / "where").DELETE <@(consumer, token3) - makeDeleteRequest(request) - } - - def getTheOtherBankAccountOfOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "other_account" <@(consumer, token) - makeGetRequest(request) - } - - def getTheOtherBankAccountOfOneTransactionWithoutToken(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "other_account" - makeGetRequest(request) - } - - def getTheOtherBankAccountOfOneTransactionWithWrongUser(bankId : String, accountId : String, viewId : String, transactionId : String) : APIResponse = { - val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "other_account" <@(consumer, token3) + def getTheOtherBankAccountOfOneTransaction(bankId : String, accountId : String, viewId : String, transactionId : String, consumerAndToken: Option[(Consumer, Token)]) : APIResponse = { + val request = v1_2Request / "banks" / bankId / "accounts" / accountId / viewId / "transactions" / transactionId / "other_account" <@(consumerAndToken) makeGetRequest(request) } @@ -1363,7 +770,7 @@ class API1_2Test extends ServerSetup{ scenario("we get only the public bank accounts", API1_2, GetBankAccounts) { Given("We will not use an access token") When("the request is sent") - val reply = getBankAccounts(randomBank) + val reply = getBankAccounts(randomBank, None) Then("we should get a 200 ok code") reply.code should equal (200) val publicAccountsInfo = reply.body.extract[AccountsJSON] @@ -1381,7 +788,7 @@ class API1_2Test extends ServerSetup{ scenario("we get the bank accounts the user have access to", API1_2, GetBankAccounts) { Given("We will use an access token") When("the request is sent") - val reply = getBankAccountsWithToken(randomBank) + val reply = getBankAccounts(randomBank, user1) Then("we should get a 200 ok code") reply.code should equal (200) val accountsInfo = reply.body.extract[AccountsJSON] @@ -1417,7 +824,7 @@ class API1_2Test extends ServerSetup{ scenario("we get the private bank accounts", API1_2, GetPrivateBankAccounts) { Given("We will use an access token") When("the request is sent") - val reply = getPrivateAccounts(randomBank) + val reply = getPrivateAccounts(randomBank, user1) Then("we should get a 200 ok code") reply.code should equal (200) And("some fields should not be empty") @@ -1430,7 +837,7 @@ class API1_2Test extends ServerSetup{ scenario("we don't get the private bank accounts", API1_2, GetPrivateBankAccounts) { Given("We will not use an access token") When("the request is sent") - val reply = getPrivateAccountsWithOutToken(randomBank) + val reply = getPrivateAccounts(randomBank, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1463,7 +870,7 @@ class API1_2Test extends ServerSetup{ val randomPosition = nextInt(bankAccount.views_available.size) val view = bankAccount.views_available.toList(randomPosition) When("the request is sent") - val reply = getPrivateBankAccountDetails(bankId, bankAccount.id, view.id) + val reply = getPrivateBankAccountDetails(bankId, bankAccount.id, view.id, user1) Then("we should get a 200 ok code") reply.code should equal (200) val privateAccountDetails = reply.body.extract[ModeratedAccountJSON] @@ -1480,7 +887,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getAccountViews(bankId, bankAccount.id) + val reply = getAccountViews(bankId, bankAccount.id, user1) Then("we should get a 200 ok code") reply.code should equal (200) reply.body.extract[ViewsJSON] @@ -1491,7 +898,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getAccountViewsWithoutToken(bankId, bankAccount.id) + val reply = getAccountViews(bankId, bankAccount.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1503,7 +910,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getAccountViewsWithoutOwnerAccess(bankId, bankAccount.id) + val reply = getAccountViews(bankId, bankAccount.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1515,15 +922,15 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val viewsBefore = getAccountViews(bankId, bankAccount.id).body.extract[ViewsJSON].views + val viewsBefore = getAccountViews(bankId, bankAccount.id, user1).body.extract[ViewsJSON].views val view = randomView(true, "") When("the request is sent") - val reply = postView(bankId, bankAccount.id, view) + val reply = postView(bankId, bankAccount.id, view, user1) Then("we should get a 201 code") reply.code should equal (201) reply.body.extract[ViewJSON] And("we should get a new view") - val viewsAfter = getAccountViews(bankId, bankAccount.id).body.extract[ViewsJSON].views + val viewsAfter = getAccountViews(bankId, bankAccount.id, user1).body.extract[ViewsJSON].views viewsBefore.size should equal (viewsAfter.size -1) } @@ -1533,7 +940,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomView(true, "") When("the request is sent") - val reply = postViewWithoutToken(bankId, bankAccount.id, view) + val reply = postView(bankId, bankAccount.id, view, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1546,7 +953,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomView(true, "") When("the request is sent") - val reply = postViewWithoutOwnerAccess(bankId, bankAccount.id, view) + val reply = postView(bankId, bankAccount.id, view, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1558,26 +965,27 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val view = randomView(true, "") When("the request is sent") - val reply = postViewWithoutOwnerAccess(bankId, randomString(3), view) + val reply = postView(bankId, randomString(3), view, user1) 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) } } + feature("Delete a view on a bank account"){ scenario("we will delete a view on a bank account", API1_2, DeleteView) { Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val view = postView(bankId, bankAccount.id, randomView(true, "")).body.extract[ViewJSON] - val viewsBefore = getAccountViews(bankId, bankAccount.id).body.extract[ViewsJSON].views + val view = postView(bankId, bankAccount.id, randomView(true, ""), user1).body.extract[ViewJSON] + val viewsBefore = getAccountViews(bankId, bankAccount.id, user1).body.extract[ViewsJSON].views When("the request is sent") - val reply = deleteView(bankId, bankAccount.id, view.id) + val reply = deleteView(bankId, bankAccount.id, view.id, user1) Then("we should get a 204 code") reply.code should equal (204) And("the views should be updated") - val viewsAfter = getAccountViews(bankId, bankAccount.id).body.extract[ViewsJSON].views + val viewsAfter = getAccountViews(bankId, bankAccount.id, user1).body.extract[ViewsJSON].views viewsBefore.size should equal (viewsAfter.size +1) } @@ -1587,7 +995,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = deleteViewWithoutToken(bankId, bankAccount.id, view) + val reply = deleteView(bankId, bankAccount.id, view, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1600,7 +1008,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = deleteViewWithoutOwnerAccess(bankId, bankAccount.id, view) + val reply = deleteView(bankId, bankAccount.id, view, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1612,7 +1020,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = deleteView(bankId, bankAccount.id, randomString(3)) + val reply = deleteView(bankId, bankAccount.id, randomString(3), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1626,7 +1034,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getAccountPermissions(bankId, bankAccount.id) + val reply = getAccountPermissions(bankId, bankAccount.id, user1) Then("we should get a 200 ok code") reply.code should equal (200) reply.body.extract[PermissionsJSON] @@ -1637,7 +1045,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getAccountPermissionsWithoutToken(bankId, bankAccount.id) + val reply = getAccountPermissions(bankId, bankAccount.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1649,7 +1057,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getAccountPermissionsWithoutOwnerAccess(bankId, bankAccount.id) + val reply = getAccountPermissions(bankId, bankAccount.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1665,7 +1073,7 @@ class API1_2Test extends ServerSetup{ val permission = randomAccountPermission(bankId, bankAccount.id) val userID = permission.user.id When("the request is sent") - val reply = getUserAccountPermission(bankId, bankAccount.id, userID) + val reply = getUserAccountPermission(bankId, bankAccount.id, userID, user1) Then("we should get a 200 ok code") reply.code should equal (200) val viewsInfo = reply.body.extract[ViewsJSON] @@ -1680,7 +1088,7 @@ class API1_2Test extends ServerSetup{ val permission = randomAccountPermission(bankId, bankAccount.id) val userID = permission.user.id When("the request is sent") - val reply = getUserAccountPermissionWithoutToken(bankId, bankAccount.id, userID) + val reply = getUserAccountPermission(bankId, bankAccount.id, userID, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1692,7 +1100,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getUserAccountPermission(bankId, bankAccount.id, randomString(5)) + val reply = getUserAccountPermission(bankId, bankAccount.id, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1706,8 +1114,8 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val userId = user2.email - val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount)) + val userId = obpuser2.email + val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount), user1) Then("we should get a 201 ok code") reply.code should equal (201) val viewInfo = reply.body.extract[ViewJSON] @@ -1720,7 +1128,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = grantUserAccessToView(bankId, bankAccount.id, randomString(5), randomViewPermalink(bankId, bankAccount)) + val reply = grantUserAccessToView(bankId, bankAccount.id, randomString(5), randomViewPermalink(bankId, bankAccount), user1) Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") @@ -1731,9 +1139,9 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId = user2.email + val userId = obpuser2.email When("the request is sent") - val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomString(5)) + val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomString(5), user1) Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") @@ -1744,9 +1152,9 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId = user2.email + val userId = obpuser2.email When("the request is sent") - val reply = grantUserAccessToViewWithWrongUser(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount)) + val reply = grantUserAccessToView(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount), user3) Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") @@ -1759,10 +1167,10 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId = user3.email + val userId = obpuser3.email val viewsIdsToGrant = randomViewsIdsToGrant(bankId, bankAccount.id) When("the request is sent") - val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant) + val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1) Then("we should get a 201 ok code") reply.code should equal (201) val viewsInfo = reply.body.extract[ViewsJSON] @@ -1771,7 +1179,7 @@ class API1_2Test extends ServerSetup{ And("the granted views should be the same") viewsIdsToGrant.toSet should equal(viewsInfo.views.map(_.id).toSet) //we revoke access to the granted views for the next tests - revokeUserAccessToAllViews(bankId, bankAccount.id, userId) + revokeUserAccessToAllViews(bankId, bankAccount.id, userId, user1) } scenario("we cannot grant a user access to a list of views on an bank account because the user does not exist", API1_2, PostPermissions) { @@ -1781,7 +1189,7 @@ class API1_2Test extends ServerSetup{ val userId = randomString(5) val viewsIdsToGrant= randomViewsIdsToGrant(bankId, bankAccount.id) When("the request is sent") - val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant) + val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1) Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") @@ -1792,10 +1200,10 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId = user3.email + val userId = obpuser3.email val viewsIdsToGrant= List(randomString(3),randomString(3)) When("the request is sent") - val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant) + val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1) Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") @@ -1806,10 +1214,10 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId = user3.email + val userId = obpuser3.email val viewsIdsToGrant= randomViewsIdsToGrant(bankId, bankAccount.id) ++ List(randomString(3),randomString(3)) When("the request is sent") - val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant) + val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1) Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") @@ -1820,10 +1228,10 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId = user3.email + val userId = obpuser3.email val viewsIdsToGrant= randomViewsIdsToGrant(bankId, bankAccount.id) ++ List(randomString(3),randomString(3)) When("the request is sent") - val reply = grantUserAccessToViewsWithWrongUser(bankId, bankAccount.id, userId, viewsIdsToGrant) + val reply = grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user3) Then("we should get a 400 ok code") reply.code should equal (400) And("we should get an error message") @@ -1836,12 +1244,12 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId = user2.email + val userId = obpuser2.email val viewId = randomViewPermalink(bankId, bankAccount) val viewsIdsToGrant = viewId :: Nil - grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant) + grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1) When("the request is sent") - val reply = revokeUserAccessToView(bankId, bankAccount.id, userId, viewId) + val reply = revokeUserAccessToView(bankId, bankAccount.id, userId, viewId, user1) Then("we should get a 204 no content code") reply.code should equal (204) } @@ -1851,7 +1259,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = revokeUserAccessToView(bankId, bankAccount.id, randomString(5), randomViewPermalink(bankId, bankAccount)) + val reply = revokeUserAccessToView(bankId, bankAccount.id, randomString(5), randomViewPermalink(bankId, bankAccount), user1) Then("we should get a 400 ok code") reply.code should equal (400) } @@ -1860,9 +1268,9 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId =user2.email + val userId =obpuser2.email When("the request is sent") - val reply = revokeUserAccessToView(bankId, bankAccount.id, userId, randomString(5)) + val reply = revokeUserAccessToView(bankId, bankAccount.id, userId, randomString(5), user1) Then("we should get a 400 ok code") reply.code should equal (400) } @@ -1871,9 +1279,9 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId = user2.email + val userId = obpuser2.email When("the request is sent") - val reply = revokeUserAccessToViewWithoutOwnerAccess(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount)) + val reply = revokeUserAccessToView(bankId, bankAccount.id, userId, randomViewPermalink(bankId, bankAccount), user3) Then("we should get a 400 ok code") reply.code should equal (400) } @@ -1883,12 +1291,12 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId = user2.email + val userId = obpuser2.email val viewId = randomViewPermalink(bankId, bankAccount) val viewsIdsToGrant = viewId :: Nil - grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant) + grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1) When("the request is sent") - val reply = revokeUserAccessToAllViews(bankId, bankAccount.id, userId) + val reply = revokeUserAccessToAllViews(bankId, bankAccount.id, userId, user1) Then("we should get a 204 no content code") reply.code should equal (204) } @@ -1898,7 +1306,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = revokeUserAccessToAllViews(bankId, bankAccount.id, randomString(5)) + val reply = revokeUserAccessToAllViews(bankId, bankAccount.id, randomString(5), user1) Then("we should get a 400 ok code") reply.code should equal (400) } @@ -1907,12 +1315,12 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val userId = user2.email + val userId = obpuser2.email val viewId = randomViewPermalink(bankId, bankAccount) val viewsIdsToGrant = viewId :: Nil - grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant) + grantUserAccessToViews(bankId, bankAccount.id, userId, viewsIdsToGrant, user1) When("the request is sent") - val reply = revokeUserAccessToAllViewsWithoutOwnerAccess(bankId, bankAccount.id, userId) + val reply = revokeUserAccessToAllViews(bankId, bankAccount.id, userId, user3) Then("we should get a 400 ok code") reply.code should equal (400) } @@ -1924,7 +1332,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getTheOtherBankAccounts(bankId, bankAccount.id, randomViewPermalink(bankId, bankAccount)) + val reply = getTheOtherBankAccounts(bankId, bankAccount.id, randomViewPermalink(bankId, bankAccount), user1) Then("we should get a 200 code") reply.code should equal (200) val accountsJson = reply.body.extract[OtherAccountsJSON] @@ -1939,7 +1347,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getTheOtherBankAccountsWithoutToken(bankId, bankAccount.id, randomViewPermalink(bankId, bankAccount)) + val reply = getTheOtherBankAccounts(bankId, bankAccount.id, randomViewPermalink(bankId, bankAccount), None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1951,7 +1359,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getTheOtherBankAccountsWithWrongUser(bankId, bankAccount.id, randomViewPermalink(bankId, bankAccount)) + val reply = getTheOtherBankAccounts(bankId, bankAccount.id, randomViewPermalink(bankId, bankAccount), user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1963,7 +1371,7 @@ class API1_2Test extends ServerSetup{ val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) When("the request is sent") - val reply = getTheOtherBankAccounts(bankId, bankAccount.id, randomString(5)) + val reply = getTheOtherBankAccounts(bankId, bankAccount.id, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -1979,7 +1387,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTheOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getTheOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 200 code") reply.code should equal (200) val accountJson = reply.body.extract[OtherAccountJSON] @@ -1994,7 +1402,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTheOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getTheOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2008,7 +1416,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTheOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getTheOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2021,7 +1429,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, randomViewPermalink(bankId, bankAccount)) When("the request is sent") - val reply = getTheOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id) + val reply = getTheOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2034,7 +1442,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getTheOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val reply = getTheOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2050,7 +1458,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getMetadataOfOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getMetadataOfOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 200 code") reply.code should equal (200) And("some fields should not be empty") @@ -2064,7 +1472,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getMetadataOfOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getMetadataOfOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2078,7 +1486,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getMetadataOfOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getMetadataOfOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2092,7 +1500,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getMetadataOfOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id) + val reply = getMetadataOfOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2105,7 +1513,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getMetadataOfOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val reply = getMetadataOfOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2121,7 +1529,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 200 code") reply.code should equal (200) reply.body.extract[AliasJSON] @@ -2134,7 +1542,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getThePublicAliasForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2148,7 +1556,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getThePublicAliasForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2162,7 +1570,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id) + val reply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2176,7 +1584,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val reply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2193,12 +1601,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomAlias = randomString(5) - val postReply = postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val postReply = postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[SuccessMessage] And("the alias should be changed") - val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should equal (theAliasAfterThePost.alias) } @@ -2211,13 +1619,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) When("the request is sent") - val postReply = postAPublicAliasForAnOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val postReply = postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, None) 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) And("the alias should not be changed") - val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should not equal (theAliasAfterThePost.alias) } @@ -2230,13 +1638,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) When("the request is sent") - val postReply = postAPublicAliasForAnOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val postReply = postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user3) 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) And("the alias should not be changed") - val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should not equal (theAliasAfterThePost.alias) } @@ -2249,13 +1657,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) When("the request is sent") - val postReply = postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomAlias) + val postReply = postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomAlias, user1) 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) And("the alias should not be changed") - val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should not equal (theAliasAfterThePost.alias) } @@ -2267,7 +1675,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomAlias = randomString(5) When("the request is sent") - val postReply = postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomAlias) + val postReply = postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomAlias, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -2284,12 +1692,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomAlias = randomString(5) - val putReply = updateThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val putReply = updateThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user1) Then("we should get a 200 code") putReply.code should equal (200) putReply.body.extract[SuccessMessage] And("the alias should be changed") - val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should equal (theAliasAfterThePost.alias) } @@ -2302,13 +1710,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) When("the request is sent") - val putReply = updateThePublicAliasForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val putReply = updateThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, None) 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) And("the alias should not be changed") - val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should not equal (theAliasAfterThePost.alias) } @@ -2321,7 +1729,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) When("the request is sent") - val putReply = updateThePublicAliasForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val putReply = updateThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user3) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -2335,7 +1743,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomAlias = randomString(5) When("the request is sent") - val putReply = updateThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomAlias) + val putReply = updateThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomAlias, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -2351,13 +1759,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) - postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user1) When("the delete request is sent") - val deleteReply = deleteThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) And("the public alias should be null") - val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterTheDelete : AliasJSON = getReply.body.extract[AliasJSON] theAliasAfterTheDelete.alias should equal (null) } @@ -2368,13 +1776,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) - postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user1) When("the delete request is sent") - val deleteReply = deleteThePublicAliasForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) And("the public alias should not be null") - val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterTheDelete : AliasJSON = getReply.body.extract[AliasJSON] theAliasAfterTheDelete.alias should not equal (null) } @@ -2385,13 +1793,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) - postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + postAPublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user1) When("the delete request is sent") - val deleteReply = deleteThePublicAliasForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) And("the public alias should not be null") - val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterTheDelete : AliasJSON = getReply.body.extract[AliasJSON] theAliasAfterTheDelete.alias should not equal (null) } @@ -2402,7 +1810,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomAlias = randomString(5) When("the delete request is sent") - val deleteReply = deleteThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val deleteReply = deleteThePublicAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -2416,7 +1824,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 200 code") reply.code should equal (200) reply.body.extract[AliasJSON] @@ -2429,7 +1837,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getThePrivateAliasForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2443,7 +1851,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getThePrivateAliasForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val reply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2457,7 +1865,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") - val reply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id) + val reply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2471,7 +1879,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val reply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -2488,12 +1896,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomAlias = randomString(5) - val postReply = postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val postReply = postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[SuccessMessage] And("the alias should be changed") - val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should equal (theAliasAfterThePost.alias) } @@ -2506,13 +1914,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) When("the request is sent") - val postReply = postAPrivateAliasForAnOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val postReply = postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, None) 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) And("the alias should not be changed") - val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should not equal (theAliasAfterThePost.alias) } @@ -2525,13 +1933,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) When("the request is sent") - val postReply = postAPrivateAliasForAnOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val postReply = postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user3) 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) And("the alias should not be changed") - val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should not equal (theAliasAfterThePost.alias) } @@ -2544,13 +1952,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) When("the request is sent") - val postReply = postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomAlias) + val postReply = postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomAlias, user1) 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) And("the alias should not be changed") - val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should not equal (theAliasAfterThePost.alias) } @@ -2562,7 +1970,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomAlias = randomString(5) When("the request is sent") - val postReply = postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomAlias) + val postReply = postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomAlias, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -2579,12 +1987,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomAlias = randomString(5) - val putReply = updateThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val putReply = updateThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user1) Then("we should get a 200 code") putReply.code should equal (200) putReply.body.extract[SuccessMessage] And("the alias should be changed") - val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should equal (theAliasAfterThePost.alias) } @@ -2597,13 +2005,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) When("the request is sent") - val putReply = updateThePrivateAliasForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val putReply = updateThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, None) 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) And("the alias should not be changed") - val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterThePost : AliasJSON = getReply.body.extract[AliasJSON] randomAlias should not equal (theAliasAfterThePost.alias) } @@ -2616,7 +2024,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) When("the request is sent") - val putReply = updateThePrivateAliasForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + val putReply = updateThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user3) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -2630,7 +2038,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomAlias = randomString(5) When("the request is sent") - val putReply = updateThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomAlias) + val putReply = updateThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomAlias, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -2646,13 +2054,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) - postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user1) When("the delete request is sent") - val deleteReply = deleteThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) And("the Private alias should be null") - val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterTheDelete : AliasJSON = getReply.body.extract[AliasJSON] theAliasAfterTheDelete.alias should equal (null) } @@ -2663,13 +2071,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) - postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user1) When("the delete request is sent") - val deleteReply = deleteThePrivateAliasForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) And("the Private alias should not be null") - val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterTheDelete : AliasJSON = getReply.body.extract[AliasJSON] theAliasAfterTheDelete.alias should not equal (null) } @@ -2680,13 +2088,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomAlias = randomString(5) - postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias) + postAPrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomAlias, user1) When("the delete request is sent") - val deleteReply = deleteThePrivateAliasForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) And("the Private alias should not be null") - val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val getReply = getThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) val theAliasAfterTheDelete : AliasJSON = getReply.body.extract[AliasJSON] theAliasAfterTheDelete.alias should not equal (null) } @@ -2697,7 +2105,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomAlias = randomString(5) When("the delete request is sent") - val deleteReply = deleteThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val deleteReply = deleteThePrivateAliasForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -2712,12 +2120,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomInfo = randomString(20) - val postReply = postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo) + val postReply = postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[SuccessMessage] And("the information should be changed") - val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomInfo should equal (moreInfo) } @@ -2729,13 +2137,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomInfo = randomString(20) When("the request is sent") - val postReply = postMoreInfoForAnOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo) + val postReply = postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo, None) 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) And("the information should not be changed") - val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomInfo should not equal (moreInfo) } @@ -2747,13 +2155,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomInfo = randomString(20) When("the request is sent") - val postReply = postMoreInfoForAnOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo) + val postReply = postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo, user3) 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) And("the information should not be changed") - val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomInfo should not equal (moreInfo) } @@ -2765,13 +2173,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomInfo = randomString(20) When("the request is sent") - val postReply = postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomInfo) + val postReply = postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomInfo, user1) 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) And("the information should not be changed") - val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomInfo should not equal (moreInfo) } @@ -2782,7 +2190,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomInfo = randomString(20) When("the request is sent") - val postReply = postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomInfo) + val postReply = postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomInfo, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -2799,12 +2207,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomInfo = randomString(20) - val putReply = updateMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo) + val putReply = updateMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo, user1) Then("we should get a 200 code") putReply.code should equal (200) putReply.body.extract[SuccessMessage] And("the information should be changed") - val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomInfo should equal (moreInfo) } @@ -2816,13 +2224,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomInfo = randomString(20) When("the request is sent") - val putReply = updateMoreInfoForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo) + val putReply = updateMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo, None) 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) And("the information should not be changed") - val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val moreInfo = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomInfo should not equal (moreInfo) } @@ -2834,7 +2242,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomInfo = randomString(20) When("the request is sent") - val putReply = updateMoreInfoForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo) + val putReply = updateMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo, user3) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -2848,7 +2256,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomInfo = randomString(20) When("the request is sent") - val putReply = updateMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomInfo) + val putReply = updateMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomInfo, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -2864,13 +2272,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomInfo = randomString(20) - postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo) + postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo, user1) When("the delete request is sent") - val deleteReply = deleteMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) And("the info should be null") - val infoAfterDelete = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val infoAfterDelete = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) infoAfterDelete should equal (null) } @@ -2881,13 +2289,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomInfo = randomString(20) - postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo) + postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo, user1) When("the delete request is sent") - val deleteReply = deleteMoreInfoForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) And("the info should not be null") - val infoAfterDelete = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val infoAfterDelete = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) infoAfterDelete should not equal (null) } @@ -2898,13 +2306,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomInfo = randomString(20) - postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo) + postMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomInfo, user1) When("the delete request is sent") - val deleteReply = deleteMoreInfoForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) And("the info should not be null") - val infoAfterDelete = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val infoAfterDelete = getMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) infoAfterDelete should not equal (null) } @@ -2915,7 +2323,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomInfo = randomString(20) When("the delete request is sent") - val deleteReply = deleteMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val deleteReply = deleteMoreInfoForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -2930,12 +2338,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomURL = randomString(20) - val postReply = postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val postReply = postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[SuccessMessage] And("the url should be changed") - val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should equal (url) } @@ -2947,13 +2355,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) When("the request is sent") - val postReply = postUrlForAnOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val postReply = postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, None) 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) And("the url should not be changed") - val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) } @@ -2965,13 +2373,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) When("the request is sent") - val postReply = postUrlForAnOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val postReply = postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, None) 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) And("the url should not be changed") - val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) } @@ -2983,13 +2391,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) When("the request is sent") - val postReply = postUrlForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomURL) + val postReply = postUrlForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomURL, user1) 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) And("the url should not be changed") - val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) } @@ -3000,7 +2408,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomURL = randomString(20) When("the request is sent") - val postReply = postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomURL) + val postReply = postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomURL, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3017,12 +2425,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomURL = randomString(20) - val putReply = updateUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val putReply = updateUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user1) Then("we should get a 200 code") putReply.code should equal (200) putReply.body.extract[SuccessMessage] And("the url should be changed") - val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should equal (url) } @@ -3034,13 +2442,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) When("the request is sent") - val putReply = updateUrlForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val putReply = updateUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, None) 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) And("the url should not be changed") - val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) } @@ -3052,7 +2460,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) When("the request is sent") - val putReply = updateUrlForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val putReply = updateUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user3) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3066,7 +2474,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomURL = randomString(20) When("the request is sent") - val putReply = updateUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomURL) + val putReply = updateUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomURL, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3082,13 +2490,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) - postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user1) When("the delete request is sent") - val deleteReply = deleteUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) And("the url should be null") - val urlAfterDelete = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val urlAfterDelete = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) urlAfterDelete should equal (null) } @@ -3099,13 +2507,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) - postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user1) When("the delete request is sent") - val deleteReply = deleteUrlForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) And("the url should not be null") - val urlAfterDelete = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val urlAfterDelete = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) urlAfterDelete should not equal (null) } @@ -3116,13 +2524,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) - postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + postUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user1) When("the delete request is sent") - val deleteReply = deleteUrlForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) And("the url should not be null") - val urlAfterDelete = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val urlAfterDelete = getUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) urlAfterDelete should not equal (null) } @@ -3133,7 +2541,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomURL = randomString(20) When("the delete request is sent") - val deleteReply = deleteUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val deleteReply = deleteUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -3148,12 +2556,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomImageURL = randomString(20) - val postReply = postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL) + val postReply = postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[SuccessMessage] And("the image url should be changed") - val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomImageURL should equal (url) } @@ -3165,13 +2573,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomImageURL = randomString(20) When("the request is sent") - val postReply = postImageUrlForAnOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL) + val postReply = postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL, None) 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) And("the image url should not be changed") - val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomImageURL should not equal (url) } @@ -3183,13 +2591,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomImageURL = randomString(20) When("the request is sent") - val postReply = postImageUrlForAnOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL) + val postReply = postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL, user3) 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) And("the image url should not be changed") - val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomImageURL should not equal (url) } @@ -3201,13 +2609,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomImageURL = randomString(20) When("the request is sent") - val postReply = postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomImageURL) + val postReply = postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomImageURL, user1) 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) And("the image url should not be changed") - val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomImageURL should not equal (url) } @@ -3218,7 +2626,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomImageURL = randomString(20) When("the request is sent") - val postReply = postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomImageURL) + val postReply = postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomImageURL, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3235,12 +2643,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomImageURL = randomString(20) - val putReply = updateImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL) + val putReply = updateImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL, user1) Then("we should get a 200 code") putReply.code should equal (200) putReply.body.extract[SuccessMessage] And("the image url should be changed") - val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomImageURL should equal (url) } @@ -3252,13 +2660,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomImageURL = randomString(20) When("the request is sent") - val putReply = updateImageUrlForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL) + val putReply = updateImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL, None) 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) And("the image url should not be changed") - val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomImageURL should not equal (url) } @@ -3270,7 +2678,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomImageURL = randomString(20) When("the request is sent") - val putReply = updateImageUrlForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL) + val putReply = updateImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL, user3) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3284,7 +2692,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomImageURL = randomString(20) When("the request is sent") - val putReply = updateImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomImageURL) + val putReply = updateImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomImageURL, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3300,13 +2708,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomImageURL = randomString(20) - postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL) + postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL, user1) When("the delete request is sent") - val deleteReply = deleteImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) And("the image url should be null") - val urlAfterDelete = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val urlAfterDelete = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) urlAfterDelete should equal (null) } @@ -3317,13 +2725,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomImageURL = randomString(20) - postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL) + postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL, user1) When("the delete request is sent") - val deleteReply = deleteImageUrlForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) And("the image url should not be null") - val urlAfterDelete = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val urlAfterDelete = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) urlAfterDelete should not equal (null) } @@ -3334,13 +2742,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomImageURL = randomString(20) - postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL) + postImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomImageURL, user1) When("the delete request is sent") - val deleteReply = deleteImageUrlForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) And("the image url should not be null") - val urlAfterDelete = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val urlAfterDelete = getImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) urlAfterDelete should not equal (null) } @@ -3351,7 +2759,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomImageURL = randomString(20) When("the delete request is sent") - val deleteReply = deleteImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val deleteReply = deleteImageUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -3366,12 +2774,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomURL = randomString(20) - val postReply = postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val postReply = postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[SuccessMessage] And("the open corporates url should be changed") - val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should equal (url) } @@ -3383,13 +2791,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) When("the request is sent") - val postReply = postOpenCorporatesUrlForAnOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val postReply = postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, None) 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) And("the open corporates url should not be changed") - val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) } @@ -3401,13 +2809,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) When("the request is sent") - val postReply = postOpenCorporatesUrlForAnOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val postReply = postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user3) 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) And("the open corporates url should not be changed") - val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) } @@ -3419,13 +2827,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) When("the request is sent") - val postReply = postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomURL) + val postReply = postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomURL, user1) 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) And("the open corporates url should not be changed") - val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) } @@ -3436,7 +2844,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomURL = randomString(20) When("the request is sent") - val postReply = postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomURL) + val postReply = postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomURL, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3453,12 +2861,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomURL = randomString(20) - val putReply = updateOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val putReply = updateOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user1) Then("we should get a 200 code") putReply.code should equal (200) putReply.body.extract[SuccessMessage] And("the open corporates url should be changed") - val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should equal (url) } @@ -3470,13 +2878,13 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) When("the request is sent") - val putReply = updateOpenCorporatesUrlForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val putReply = updateOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, None) 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) And("the open corporates url should not be changed") - val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val url = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomURL should not equal (url) } @@ -3488,7 +2896,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) When("the request is sent") - val putReply = updateOpenCorporatesUrlForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + val putReply = updateOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user3) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3502,7 +2910,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomURL = randomString(20) When("the request is sent") - val putReply = updateOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomURL) + val putReply = updateOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomURL, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3518,13 +2926,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) - postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user1) When("the delete request is sent") - val deleteReply = deleteOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) And("the open corporates url should be null") - val urlAfterDelete = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val urlAfterDelete = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) urlAfterDelete should equal (null) } @@ -3535,13 +2943,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) - postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user1) When("the delete request is sent") - val deleteReply = deleteOpenCorporatesUrlForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) And("the open corporates url should not be null") - val urlAfterDelete = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val urlAfterDelete = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) urlAfterDelete should not equal (null) } @@ -3552,13 +2960,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomURL = randomString(20) - postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL) + postOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomURL, user1) When("the delete request is sent") - val deleteReply = deleteOpenCorporatesUrlForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) And("the open corporates url should not be null") - val urlAfterDelete = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val urlAfterDelete = getOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) urlAfterDelete should not equal (null) } @@ -3569,7 +2977,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomURL = randomString(20) When("the delete request is sent") - val deleteReply = deleteOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val deleteReply = deleteOpenCorporatesUrlForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -3584,12 +2992,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val postReply = postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[SuccessMessage] And("the corporate location should be changed") - val location = getCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val location = getCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomLoc.latitude should equal (location.latitude) randomLoc.longitude should equal (location.longitude) } @@ -3602,7 +3010,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postCorporateLocationForAnOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val postReply = postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, None) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3617,7 +3025,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) var randomLoc = JSONFactory.createLocationPlainJSON(400,200) When("the request is sent") - val postReply = postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val postReply = postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3632,7 +3040,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postCorporateLocationForAnOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val postReply = postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user3) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3647,7 +3055,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomLoc) + val postReply = postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomLoc, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3661,7 +3069,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomLoc = randomLocation When("the request is sent") - val postReply = postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomLoc) + val postReply = postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomLoc, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3678,12 +3086,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomLoc = randomLocation - val putReply = updateCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val putReply = updateCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) Then("we should get a 200 code") putReply.code should equal (200) putReply.body.extract[SuccessMessage] And("the corporate location should be changed") - val location = getCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val location = getCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomLoc.latitude should equal (location.latitude) randomLoc.longitude should equal (location.longitude) } @@ -3696,7 +3104,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) var randomLoc = JSONFactory.createLocationPlainJSON(400,200) When("the request is sent") - val putReply = updateCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val putReply = updateCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3711,7 +3119,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val putReply = updateCorporateLocationForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val putReply = updateCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, None) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3726,7 +3134,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val putReply = updateCorporateLocationForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val putReply = updateCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user3) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3740,7 +3148,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomLoc = randomLocation When("the request is sent") - val putReply = updateCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomLoc) + val putReply = updateCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomLoc, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3756,13 +3164,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation - postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) When("the delete request is sent") - val deleteReply = deleteCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) And("the corporate location should be null") - val locationAfterDelete = getCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val locationAfterDelete = getCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) locationAfterDelete should equal (null) } @@ -3773,13 +3181,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation - postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) When("the delete request is sent") - val deleteReply = deleteCorporateLocationForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) And("the corporate location should not be null") - val locationAfterDelete = getCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val locationAfterDelete = getCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) locationAfterDelete should not equal (null) } @@ -3790,13 +3198,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation - postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + postCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) When("the delete request is sent") - val deleteReply = deleteCorporateLocationForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deleteCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) And("the corporate location should not be null") - val locationAfterDelete = getCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val locationAfterDelete = getCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) locationAfterDelete should not equal (null) } @@ -3807,7 +3215,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomLoc = randomLocation When("the delete request is sent") - val deleteReply = deleteCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val deleteReply = deleteCorporateLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -3822,12 +3230,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val postReply = postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[SuccessMessage] And("the physical location should be changed") - val location = getPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val location = getPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomLoc.latitude should equal (location.latitude) randomLoc.longitude should equal (location.longitude) } @@ -3840,7 +3248,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) var randomLoc = JSONFactory.createLocationPlainJSON(400,200) When("the request is sent") - val postReply = postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val postReply = postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3855,7 +3263,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postPhysicalLocationForAnOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val postReply = postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, None) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3870,7 +3278,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postPhysicalLocationForAnOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val postReply = postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user3) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3885,7 +3293,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomLoc) + val postReply = postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, randomString(5), otherBankAccount.id, randomLoc, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3899,7 +3307,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomLoc = randomLocation When("the request is sent") - val postReply = postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomLoc) + val postReply = postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomLoc, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -3916,12 +3324,12 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) When("the request is sent") val randomLoc = randomLocation - val putReply = updatePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val putReply = updatePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) Then("we should get a 200 code") putReply.code should equal (200) putReply.body.extract[SuccessMessage] And("the physical location should be changed") - val location = getPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val location = getPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) randomLoc.latitude should equal (location.latitude) randomLoc.longitude should equal (location.longitude) } @@ -3934,7 +3342,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) var randomLoc = JSONFactory.createLocationPlainJSON(400,200) When("the request is sent") - val putReply = updatePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val putReply = updatePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3949,7 +3357,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val putReply = updatePhysicalLocationForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val putReply = updatePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, None) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3964,7 +3372,7 @@ class API1_2Test extends ServerSetup{ val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val putReply = updatePhysicalLocationForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + val putReply = updatePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user3) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3978,7 +3386,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomLoc = randomLocation When("the request is sent") - val putReply = updatePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomLoc) + val putReply = updatePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), randomLoc, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -3994,13 +3402,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation - postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) When("the delete request is sent") - val deleteReply = deletePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deletePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) And("the physical location should be null") - val locationAfterDelete = getPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val locationAfterDelete = getPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) locationAfterDelete should equal (null) } @@ -4011,13 +3419,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation - postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) When("the delete request is sent") - val deleteReply = deletePhysicalLocationForOneOtherBankAccountWithoutToken(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deletePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) And("the physical location should not be null") - val locationAfterDelete = getPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val locationAfterDelete = getPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) locationAfterDelete should not equal (null) } @@ -4028,13 +3436,13 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val otherBankAccount = randomOtherBankAccount(bankId, bankAccount.id, view) val randomLoc = randomLocation - postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc) + postPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, randomLoc, user1) When("the delete request is sent") - val deleteReply = deletePhysicalLocationForOneOtherBankAccountWithWrongUser(bankId, bankAccount.id, view, otherBankAccount.id) + val deleteReply = deletePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) And("the physical location should not be null") - val locationAfterDelete = getPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id) + val locationAfterDelete = getPhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, otherBankAccount.id, user1) locationAfterDelete should not equal (null) } @@ -4045,7 +3453,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomLoc = randomLocation When("the delete request is sent") - val deleteReply = deletePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val deleteReply = deletePhysicalLocationForOneOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4058,7 +3466,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getTransactions(bankId,bankAccount.id,view) + val reply = getTransactions(bankId,bankAccount.id,view, user1) Then("we should get a 200 ok code") reply.code should equal (200) val transactions = reply.body.extract[TransactionsJSON] @@ -4068,7 +3476,7 @@ class API1_2Test extends ServerSetup{ Given("We will use an access token") When("the request is sent") val bankId = randomBank - val reply = getTransactions(bankId,randomString(5),randomString(5)) + val reply = getTransactions(bankId,randomString(5),randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) } @@ -4078,7 +3486,7 @@ class API1_2Test extends ServerSetup{ When("the request is sent") val bankId = randomBank val bankAccount : AccountJSON = randomPrivateAccount(bankId) - val reply = getTransactions(bankId,bankAccount.id,randomString(5)) + val reply = getTransactions(bankId,bankAccount.id,randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) } @@ -4092,7 +3500,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTransaction(bankId, bankAccount.id, view, transaction.id) + val reply = getTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 200 ok code") reply.code should equal (200) reply.body.extract[TransactionJSON] @@ -4105,7 +3513,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id) + val reply = getTransaction(bankId, bankAccount.id, view, transaction.id, None) Then("we should get a 400 code") reply.code should equal (400) } @@ -4117,7 +3525,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id) + val reply = getTransaction(bankId, bankAccount.id, view, transaction.id, user3) Then("we should get a 400 code") reply.code should equal (400) } @@ -4129,7 +3537,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTransactionWithoutToken(bankId, randomString(5), view, transaction.id) + val reply = getTransaction(bankId, randomString(5), view, transaction.id, user1) Then("we should get a 400 code") reply.code should equal (400) } @@ -4141,7 +3549,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTransactionWithoutToken(bankId, bankAccount.id, randomString(5), transaction.id) + val reply = getTransaction(bankId, bankAccount.id, randomString(5), transaction.id, user1) Then("we should get a 400 code") reply.code should equal (400) } @@ -4152,7 +3560,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getTransactionWithoutToken(bankId, bankAccount.id, view, randomString(5)) + val reply = getTransaction(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) } @@ -4167,7 +3575,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val reply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 200 code") reply.code should equal (200) reply.body.extract[TransactionNarrativeJSON] @@ -4180,7 +3588,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getNarrativeForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id) + val reply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4194,7 +3602,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getNarrativeForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id) + val reply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4208,7 +3616,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getNarrativeForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id) + val reply = getNarrativeForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4221,7 +3629,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, randomString(5)) + val reply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4238,12 +3646,12 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") val randomNarrative = randomString(20) - val postReply = postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative) + val postReply = postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[SuccessMessage] And("the narrative should be added") - val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theNarrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] randomNarrative should equal (theNarrativeAfterThePost.narrative) } @@ -4256,13 +3664,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomNarrative = randomString(20) When("the request is sent") - val postReply = postNarrativeForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id, randomNarrative) + val postReply = postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, None) 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) And("the narrative should not be added") - val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theNarrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] randomNarrative should not equal (theNarrativeAfterThePost.narrative) } @@ -4275,13 +3683,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomNarrative = randomString(20) When("the request is sent") - val postReply = postNarrativeForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, randomNarrative) + val postReply = postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, user3) 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) And("the narrative should not be added") - val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theNarrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] randomNarrative should not equal (theNarrativeAfterThePost.narrative) } @@ -4294,13 +3702,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomNarrative = randomString(20) When("the request is sent") - val postReply = postNarrativeForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, randomNarrative) + val postReply = postNarrativeForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, randomNarrative, user1) 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) And("the narrative should not be added") - val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theNarrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] randomNarrative should not equal (theNarrativeAfterThePost.narrative) } @@ -4312,7 +3720,7 @@ class API1_2Test extends ServerSetup{ val view = "owner" val randomNarrative = randomString(20) When("the request is sent") - val postReply = postNarrativeForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomNarrative) + val postReply = postNarrativeForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomNarrative, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -4329,12 +3737,12 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") val randomNarrative = randomString(20) - val putReply = updateNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative) + val putReply = updateNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, user1) Then("we should get a 200 code") putReply.code should equal (200) putReply.body.extract[SuccessMessage] And("the narrative should be changed") - val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val narrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] randomNarrative should equal (narrativeAfterThePost.narrative) } @@ -4347,13 +3755,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomNarrative = randomString(20) When("the request is sent") - val putReply = updateNarrativeForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id, randomNarrative) + val putReply = updateNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, None) 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) And("the narrative should not be changed") - val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val narrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] randomNarrative should not equal (narrativeAfterThePost.narrative) } @@ -4366,13 +3774,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomNarrative = randomString(20) When("the request is sent") - val putReply = updateNarrativeForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, randomNarrative) + val putReply = updateNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, user3) 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) And("the narrative should not be changed") - val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val narrativeAfterThePost : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] randomNarrative should not equal (narrativeAfterThePost.narrative) } @@ -4385,7 +3793,7 @@ class API1_2Test extends ServerSetup{ val transactionId = randomString(5) val randomNarrative = randomString(20) When("the request is sent") - val putReply = updateNarrativeForOneTransaction(bankId, bankAccount.id, view, transactionId, randomNarrative) + val putReply = updateNarrativeForOneTransaction(bankId, bankAccount.id, view, transactionId, randomNarrative, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -4401,13 +3809,13 @@ class API1_2Test extends ServerSetup{ val view = "owner" val transaction = randomTransaction(bankId, bankAccount.id, view) val randomNarrative = randomString(20) - postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative) + postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, user1) When("the delete request is sent") - val deleteReply = deleteNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val deleteReply = deleteNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) And("the narrative should be null") - val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val narrativeAfterTheDelete : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] narrativeAfterTheDelete.narrative should equal (null) } @@ -4419,13 +3827,13 @@ class API1_2Test extends ServerSetup{ val view = "owner" val transaction = randomTransaction(bankId, bankAccount.id, view) val randomNarrative = randomString(20) - postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative) + postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, user1) When("the delete request is sent") - val deleteReply = deleteNarrativeForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id) + val deleteReply = deleteNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) And("the public narrative should not be null") - val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val narrativeAfterTheDelete : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] narrativeAfterTheDelete.narrative should not equal (null) } @@ -4437,13 +3845,13 @@ class API1_2Test extends ServerSetup{ val view = "owner" val transaction = randomTransaction(bankId, bankAccount.id, view) val randomNarrative = randomString(20) - postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative) + postNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomNarrative, user1) When("the delete request is sent") - val deleteReply = deleteNarrativeForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id) + val deleteReply = deleteNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) And("the narrative should not be null") - val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getNarrativeForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val narrativeAfterTheDelete : TransactionNarrativeJSON = getReply.body.extract[TransactionNarrativeJSON] narrativeAfterTheDelete.narrative should not equal (null) } @@ -4455,7 +3863,7 @@ class API1_2Test extends ServerSetup{ val view = "owner" val randomNarrative = randomString(20) When("the delete request is sent") - val deleteReply = deleteNarrativeForOneTransaction(bankId, bankAccount.id, view, randomString(5)) + val deleteReply = deleteNarrativeForOneTransaction(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4469,7 +3877,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val reply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 200 code") reply.code should equal (200) reply.body.extract[TransactionCommentsJSON] @@ -4482,7 +3890,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getCommentsForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id) + val reply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4496,7 +3904,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getCommentsForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id) + val reply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4510,7 +3918,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getCommentsForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id) + val reply = getCommentsForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4523,7 +3931,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getCommentsForOneTransaction(bankId, bankAccount.id, view, randomString(5)) + val reply = getCommentsForOneTransaction(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4540,12 +3948,12 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") val randomComment = PostTransactionCommentJSON(randomString(20)) - val postReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment) + val postReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[TransactionCommentJSON] And("the comment should be added") - val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theCommentsAfterThePost = getReply.body.extract[TransactionCommentsJSON].comments val theComment = theCommentsAfterThePost.find(_.value == randomComment.value) theComment.nonEmpty should equal (true) @@ -4561,13 +3969,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomComment = PostTransactionCommentJSON(randomString(20)) When("the request is sent") - val postReply = postCommentForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id, randomComment) + val postReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment, None) 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) And("the comment should not be added") - val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theCommentsAfterThePost = getReply.body.extract[TransactionCommentsJSON].comments val notFound = theCommentsAfterThePost.find(_.value == randomComment.value) match { case None => true @@ -4585,13 +3993,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomComment = PostTransactionCommentJSON(randomString(20)) When("the request is sent") - val postReply = postCommentForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, randomComment) + val postReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment, user3) 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) And("the comment should not be added") - val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theCommentsAfterThePost = getReply.body.extract[TransactionCommentsJSON].comments val notFound = theCommentsAfterThePost.find(_.value == randomComment.value) match { case None => true @@ -4608,13 +4016,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomComment = PostTransactionCommentJSON(randomString(20)) When("the request is sent") - val postReply = postCommentForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, randomComment) + val postReply = postCommentForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, randomComment, user1) 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) And("the comment should not be added") - val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getCommentsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theCommentsAfterThePost = getReply.body.extract[TransactionCommentsJSON].comments val notFound = theCommentsAfterThePost.find(_.value == randomComment.value) match { case None => true @@ -4630,7 +4038,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomComment = PostTransactionCommentJSON(randomString(20)) When("the request is sent") - val postReply = postCommentForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomComment) + val postReply = postCommentForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomComment, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -4646,10 +4054,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomComment = PostTransactionCommentJSON(randomString(20)) - val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment) + val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment, user1) val postedComment = postedReply.body.extract[TransactionCommentJSON] When("the delete request is sent") - val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedComment.id) + val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedComment.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) } @@ -4661,10 +4069,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomComment = PostTransactionCommentJSON(randomString(20)) - val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment) + val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment, user1) val postedComment = postedReply.body.extract[TransactionCommentJSON] When("the delete request is sent") - val deleteReply = deleteCommentForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id, postedComment.id) + val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedComment.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4676,10 +4084,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomComment = PostTransactionCommentJSON(randomString(20)) - val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment) + val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment, user1) val postedComment = postedReply.body.extract[TransactionCommentJSON] When("the delete request is sent") - val deleteReply = deleteCommentForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, postedComment.id) + val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedComment.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4691,10 +4099,10 @@ class API1_2Test extends ServerSetup{ val view = "public" val transaction = randomTransaction(bankId, bankAccount.id, view) val randomComment = PostTransactionCommentJSON(randomString(20)) - val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment) + val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment, user2) val postedComment = postedReply.body.extract[TransactionCommentJSON] When("the delete request is sent") - val deleteReply = deleteCommentForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, postedComment.id) + val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedComment.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4706,7 +4114,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the delete request is sent") - val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomString(5)) + val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4718,10 +4126,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomComment = PostTransactionCommentJSON(randomString(20)) - val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment) + val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment, user1) val postedComment = postedReply.body.extract[TransactionCommentJSON] When("the delete request is sent") - val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, view, randomString(5), postedComment.id) + val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, view, randomString(5), postedComment.id, user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4733,10 +4141,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomComment = PostTransactionCommentJSON(randomString(20)) - val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment) + val postedReply = postCommentForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomComment, user1) val postedComment = postedReply.body.extract[TransactionCommentJSON] When("the delete request is sent") - val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, postedComment.id) + val deleteReply = deleteCommentForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, postedComment.id, user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4750,7 +4158,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val reply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 200 code") reply.code should equal (200) reply.body.extract[TransactionTagsJSON] @@ -4763,7 +4171,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTagsForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id) + val reply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4777,7 +4185,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTagsForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id) + val reply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4791,7 +4199,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTagsForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id) + val reply = getTagsForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4804,7 +4212,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getTagsForOneTransaction(bankId, bankAccount.id, view, randomString(5)) + val reply = getTagsForOneTransaction(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -4821,12 +4229,12 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") val randomTag = PostTransactionTagJSON(randomString(5)) - val postReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag) + val postReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[TransactionTagJSON] And("the tag should be added") - val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theTagsAfterThePost = getReply.body.extract[TransactionTagsJSON].tags val theTag = theTagsAfterThePost.find(_.value == randomTag.value) theTag.nonEmpty should equal (true) @@ -4841,13 +4249,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomTag = PostTransactionTagJSON(randomString(5)) When("the request is sent") - val postReply = postTagForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id, randomTag) + val postReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag, None) 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) And("the tag should not be added") - val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theTagsAfterThePost = getReply.body.extract[TransactionTagsJSON].tags val notFound = theTagsAfterThePost.find(_.value == randomTag.value) match { case None => true @@ -4864,13 +4272,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomTag = PostTransactionTagJSON(randomString(5)) When("the request is sent") - val postReply = postTagForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, randomTag) + val postReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag, user3) 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) And("the tag should not be added") - val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theTagsAfterThePost = getReply.body.extract[TransactionTagsJSON].tags val notFound = theTagsAfterThePost.find(_.value == randomTag.value) match { case None => true @@ -4887,13 +4295,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomTag = PostTransactionTagJSON(randomString(5)) When("the request is sent") - val postReply = postTagForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, randomTag) + val postReply = postTagForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, randomTag, user1) 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) And("the tag should not be added") - val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getTagsForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theTagsAfterThePost = getReply.body.extract[TransactionTagsJSON].tags val notFound = theTagsAfterThePost.find(_.value == randomTag.value) match { case None => true @@ -4909,7 +4317,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomTag = PostTransactionTagJSON(randomString(5)) When("the request is sent") - val postReply = postTagForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomTag) + val postReply = postTagForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomTag, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -4925,10 +4333,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomTag = PostTransactionTagJSON(randomString(5)) - val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag) + val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag, user1) val postedTag = postedReply.body.extract[TransactionTagJSON] When("the delete request is sent") - val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedTag.id) + val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedTag.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) } @@ -4940,10 +4348,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomTag = PostTransactionTagJSON(randomString(5)) - val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag) + val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag, user1) val postedTag = postedReply.body.extract[TransactionTagJSON] When("the delete request is sent") - val deleteReply = deleteTagForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id, postedTag.id) + val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedTag.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4955,10 +4363,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomTag = PostTransactionTagJSON(randomString(5)) - val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag) + val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag, user1) val postedTag = postedReply.body.extract[TransactionTagJSON] When("the delete request is sent") - val deleteReply = deleteTagForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, postedTag.id) + val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedTag.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4970,10 +4378,10 @@ class API1_2Test extends ServerSetup{ val view = "public" val transaction = randomTransaction(bankId, bankAccount.id, view) val randomTag = PostTransactionTagJSON(randomString(5)) - val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag) + val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag, user2) val postedTag = postedReply.body.extract[TransactionTagJSON] When("the delete request is sent") - val deleteReply = deleteTagForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, postedTag.id) + val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedTag.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4985,7 +4393,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the delete request is sent") - val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomString(5)) + val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -4997,10 +4405,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomTag = PostTransactionTagJSON(randomString(5)) - val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag) + val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag, user1) val postedTag = postedReply.body.extract[TransactionTagJSON] When("the delete request is sent") - val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, view, randomString(5), postedTag.id) + val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, view, randomString(5), postedTag.id, user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -5012,10 +4420,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomTag = PostTransactionTagJSON(randomString(5)) - val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag) + val postedReply = postTagForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomTag, user1) val postedTag = postedReply.body.extract[TransactionTagJSON] When("the delete request is sent") - val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, postedTag.id) + val deleteReply = deleteTagForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, postedTag.id, user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -5029,7 +4437,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val reply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 200 code") reply.code should equal (200) reply.body.extract[TransactionImagesJSON] @@ -5042,7 +4450,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getImagesForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id) + val reply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5056,7 +4464,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getImagesForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id) + val reply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5070,7 +4478,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getImagesForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id) + val reply = getImagesForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5083,7 +4491,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getImagesForOneTransaction(bankId, bankAccount.id, view, randomString(5)) + val reply = getImagesForOneTransaction(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5100,12 +4508,12 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") - val postReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage) + val postReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[TransactionImageJSON] And("the image should be added") - val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theImagesAfterThePost = getReply.body.extract[TransactionImagesJSON].images val theImage = theImagesAfterThePost.find(_.URL == randomImage.URL) theImage.nonEmpty should equal (true) @@ -5120,13 +4528,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") When("the request is sent") - val postReply = postImageForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id, randomImage) + val postReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage, None) 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) And("the image should not be added") - val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theImagesAfterThePost = getReply.body.extract[TransactionImagesJSON].images val notFound = theImagesAfterThePost.find(_.URL == randomImage.URL) match { case None => true @@ -5143,13 +4551,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") When("the request is sent") - val postReply = postImageForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, randomImage) + val postReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage, user3) 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) And("the image should not be added") - val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theImagesAfterThePost = getReply.body.extract[TransactionImagesJSON].images val notFound = theImagesAfterThePost.find(_.URL == randomImage.URL) match { case None => true @@ -5166,13 +4574,13 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") When("the request is sent") - val postReply = postImageForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, randomImage) + val postReply = postImageForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, randomImage, user1) 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) And("the image should not be added") - val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val getReply = getImagesForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) val theImagesAfterThePost = getReply.body.extract[TransactionImagesJSON].images val notFound = theImagesAfterThePost.find(_.URL == randomImage.URL) match { case None => true @@ -5188,7 +4596,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") When("the request is sent") - val postReply = postImageForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomImage) + val postReply = postImageForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomImage, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -5204,10 +4612,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") - val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage) + val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage, user1) val postedImage = postedReply.body.extract[TransactionImageJSON] When("the delete request is sent") - val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedImage.id) + val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedImage.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) } @@ -5219,10 +4627,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") - val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage) + val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage, user1) val postedImage = postedReply.body.extract[TransactionImageJSON] When("the delete request is sent") - val deleteReply = deleteImageForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id, postedImage.id) + val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedImage.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -5234,10 +4642,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") - val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage) + val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage, user1) val postedImage = postedReply.body.extract[TransactionImageJSON] When("the delete request is sent") - val deleteReply = deleteImageForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, postedImage.id) + val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedImage.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -5249,10 +4657,10 @@ class API1_2Test extends ServerSetup{ val view = "public" val transaction = randomTransaction(bankId, bankAccount.id, view) val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") - val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage) + val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage, user1) val postedImage = postedReply.body.extract[TransactionImageJSON] When("the delete request is sent") - val deleteReply = deleteImageForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, postedImage.id) + val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, postedImage.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -5264,7 +4672,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the delete request is sent") - val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomString(5)) + val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -5276,10 +4684,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") - val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage) + val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage, user1) val postedImage = postedReply.body.extract[TransactionImageJSON] When("the delete request is sent") - val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, view, randomString(5), postedImage.id) + val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, view, randomString(5), postedImage.id, user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -5291,10 +4699,10 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomImage = PostTransactionImageJSON(randomString(5),"http://www.mysuperimage.com") - val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage) + val postedReply = postImageForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomImage, user1) val postedImage = postedReply.body.extract[TransactionImageJSON] When("the delete request is sent") - val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, postedImage.id) + val deleteReply = deleteImageForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, postedImage.id, user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -5308,9 +4716,9 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation - postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user1) When("the request is sent") - val reply = getWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val reply = getWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 200 code") reply.code should equal (200) } @@ -5322,9 +4730,9 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation - postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, None) When("the request is sent") - val reply = getWhereForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id) + val reply = getWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5338,9 +4746,9 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation - postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user3) When("the request is sent") - val reply = getWhereForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id) + val reply = getWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5354,9 +4762,9 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation - postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user1) When("the request is sent") - val reply = getWhereForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id) + val reply = getWhereForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5369,7 +4777,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getWhereForOneTransaction(bankId, bankAccount.id, view, randomString(5)) + val reply = getWhereForOneTransaction(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5386,12 +4794,12 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + val postReply = postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user1) Then("we should get a 201 code") postReply.code should equal (201) postReply.body.extract[SuccessMessage] And("the where should be posted") - val location = getWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id).body.extract[TransactionWhereJSON] + val location = getWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1).body.extract[TransactionWhereJSON] randomLoc.latitude should equal (location.where.latitude) randomLoc.longitude should equal (location.where.longitude) location.where.user should not equal (null) @@ -5405,7 +4813,7 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) var randomLoc = JSONFactory.createLocationPlainJSON(400,200) When("the request is sent") - val postReply = postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + val postReply = postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -5420,7 +4828,7 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postWhereForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id, randomLoc) + val postReply = postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, None) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -5435,7 +4843,7 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postWhereForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, randomLoc) + val postReply = postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user3) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -5450,7 +4858,7 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val postReply = postWhereForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, randomLoc) + val postReply = postWhereForOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, randomLoc, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -5464,7 +4872,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomLoc = randomLocation When("the request is sent") - val postReply = postWhereForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomLoc) + val postReply = postWhereForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomLoc, user1) Then("we should get a 400 code") postReply.code should equal (400) And("we should get an error message") @@ -5481,12 +4889,12 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") val randomLoc = randomLocation - val putReply = updateWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + val putReply = updateWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user1) Then("we should get a 200 code") putReply.code should equal (200) putReply.body.extract[SuccessMessage] And("the where should be changed") - val location = getWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id).body.extract[TransactionWhereJSON] + val location = getWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1).body.extract[TransactionWhereJSON] randomLoc.latitude should equal (location.where.latitude) randomLoc.longitude should equal (location.where.longitude) } @@ -5499,7 +4907,7 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) var randomLoc = JSONFactory.createLocationPlainJSON(400,200) When("the request is sent") - val putReply = updateWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + val putReply = updateWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -5514,7 +4922,7 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) var randomLoc = randomLocation When("the request is sent") - val putReply = updateWhereForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id, randomLoc) + val putReply = updateWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, None) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -5529,7 +4937,7 @@ class API1_2Test extends ServerSetup{ val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation When("the request is sent") - val putReply = updateWhereForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id, randomLoc) + val putReply = updateWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user3) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -5543,7 +4951,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomLoc = randomLocation When("the request is sent") - val putReply = updateWhereForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomLoc) + val putReply = updateWhereForOneTransaction(bankId, bankAccount.id, view, randomString(5), randomLoc, user1) Then("we should get a 400 code") putReply.code should equal (400) And("we should get an error message") @@ -5559,9 +4967,9 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation - postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user1) When("the delete request is sent") - val deleteReply = deleteWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id) + val deleteReply = deleteWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 204 code") deleteReply.code should equal (204) And("the where should be null") @@ -5577,9 +4985,9 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation - postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user1) When("the delete request is sent") - val deleteReply = deleteWhereForOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id) + val deleteReply = deleteWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, None) Then("we should get a 400 code") deleteReply.code should equal (400) // And("the where should not be null") @@ -5592,9 +5000,9 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation - postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user1) When("the delete request is sent") - val deleteReply = deleteWhereForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id) + val deleteReply = deleteWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) // And("the where should not be null") @@ -5607,9 +5015,9 @@ class API1_2Test extends ServerSetup{ val view = "public" val transaction = randomTransaction(bankId, bankAccount.id, view) val randomLoc = randomLocation - postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc) + postWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, randomLoc, user1) When("the delete request is sent") - val deleteReply = deleteWhereForOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id) + val deleteReply = deleteWhereForOneTransaction(bankId, bankAccount.id, view, transaction.id, user3) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -5621,7 +5029,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val randomLoc = randomLocation When("the delete request is sent") - val deleteReply = deleteWhereForOneTransaction(bankId, bankAccount.id, view, randomString(5)) + val deleteReply = deleteWhereForOneTransaction(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") deleteReply.code should equal (400) } @@ -5635,7 +5043,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTheOtherBankAccountOfOneTransaction(bankId, bankAccount.id, view, transaction.id) + val reply = getTheOtherBankAccountOfOneTransaction(bankId, bankAccount.id, view, transaction.id, user1) Then("we should get a 200 code") reply.code should equal (200) val accountJson = reply.body.extract[OtherAccountJSON] @@ -5650,7 +5058,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTheOtherBankAccountOfOneTransactionWithoutToken(bankId, bankAccount.id, view, transaction.id) + val reply = getTheOtherBankAccountOfOneTransaction(bankId, bankAccount.id, view, transaction.id, None) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5664,7 +5072,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTheOtherBankAccountOfOneTransactionWithWrongUser(bankId, bankAccount.id, view, transaction.id) + val reply = getTheOtherBankAccountOfOneTransaction(bankId, bankAccount.id, view, transaction.id, user3) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5678,7 +5086,7 @@ class API1_2Test extends ServerSetup{ val view = randomViewPermalink(bankId, bankAccount) val transaction = randomTransaction(bankId, bankAccount.id, view) When("the request is sent") - val reply = getTheOtherBankAccountOfOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id) + val reply = getTheOtherBankAccountOfOneTransaction(bankId, bankAccount.id, randomString(5), transaction.id, user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message") @@ -5691,7 +5099,7 @@ class API1_2Test extends ServerSetup{ val bankAccount : AccountJSON = randomPrivateAccount(bankId) val view = randomViewPermalink(bankId, bankAccount) When("the request is sent") - val reply = getTheOtherBankAccount(bankId, bankAccount.id, view, randomString(5)) + val reply = getTheOtherBankAccount(bankId, bankAccount.id, view, randomString(5), user1) Then("we should get a 400 code") reply.code should equal (400) And("we should get an error message")