All tests fail: akka fails to serialize ViewImpl due to kryo problem

This commit is contained in:
Petar Bozin 2017-06-16 10:45:01 +02:00
parent df455c2f71
commit a704261f5f
51 changed files with 1756 additions and 1721 deletions

View File

@ -307,7 +307,7 @@
<dependency>
<groupId>com.github.romix.akka</groupId>
<artifactId>akka-kryo-serialization_${scala.version}</artifactId>
<version>0.5.2</version>
<version>0.5.1</version>
</dependency>
<dependency>
<groupId>com.github.cb372</groupId>

View File

@ -382,12 +382,12 @@ class Boot extends MdcLoggable {
TransactionStatusScheduler.start(delay)
}
APIUtil.akkaSanityCheck() match {
case Full(c) if c == true => logger.info(s"remotedata.secret matched = $c")
case Full(c) if c == false => throw new Exception(ErrorMessages.RemoteDataSecretMatchError)
case Empty => throw new Exception(ErrorMessages.RemoteDataSecretObtainError)
case _ => throw new Exception(s"Unexpected error occurs during Akka sanity check!")
}
//APIUtil.akkaSanityCheck() match {
// case Full(c) if c == true => logger.info(s"remotedata.secret matched = $c")
// case Full(c) if c == false => throw new Exception(ErrorMessages.RemoteDataSecretMatchError)
// case Empty => throw new Exception(ErrorMessages.RemoteDataSecretObtainError)
// case _ => throw new Exception(s"Unexpected error occurs during Akka sanity check!")
//}
}

View File

@ -24,24 +24,35 @@ object ObpActorConfig {
provider = "akka.remote.RemoteActorRefProvider"
allow-java-serialization = off
kryo {
type = "graph"
idstrategy = "default"
buffer-size = 65536
max-buffer-size = -1
use-manifests = false
use-unsafe = true
post-serialization-transformations = "off"
#post-serialization-transformations = "lz4,aes"
#encryption {
# aes {
# mode = "AES/CBC/PKCS5Padding"
# key = j68KkRjq21ykRGAQ
# IV-length = 16
# }
#}
implicit-registration-logging = false
kryo-trace = false
resolve-subclasses = true
setIgnoreSyntheticFields = true
type = "graph"
idstrategy = "default"
buffer-size = 65536
max-buffer-size = -1
use-manifests = false
use-unsafe = false
post-serialization-transformations = "off"
#post-serialization-transformations = "lz4,aes"
#encryption {
# aes {
# mode = "AES/CBC/PKCS5Padding"
# key = j68KkRjq21ykRGAQ
# IV-length = 16
# }
#}
implicit-registration-logging = false
kryo-trace = true
resolve-subclasses = true
#mappings = {
# "akka.actor.ActorSelectionMessage" = 40
# "scala.collection.immutnnnnable.Vector" = 41
# "akka.actor.SelectChildName" = 42
# "code.views.RemotedataViewsCaseClasses" = 43
# "code.views.RemotedataViewsCaseClasses$createOwnerView" = 44
# "code.model.AccountId" = 45
# "code.model.BankId" = 46
# "net.liftweb.mapper.MappedString$$Lambda" = 47
#}
}
serializers {
kryo = "com.romix.akka.serialization.kryo.KryoSerializer"
@ -51,6 +62,7 @@ object ObpActorConfig {
"net.liftweb.common.Empty" = kryo,
"net.liftweb.common.Box" = kryo,
"net.liftweb.common.ParamFailure" = kryo,
"net.liftweb.mapper.MappedString" = kryo,
"code.api.APIFailure" = kryo,
"code.model.BankAccount" = kryo,
"code.model.View" = kryo,

View File

@ -277,7 +277,7 @@ object APIUtil extends MdcLoggable {
def registeredApplication(consumerKey: String): Boolean = {
Consumers.consumers.vend.getConsumerByConsumerKey(consumerKey) match {
case Full(application) => application.isActive
case Full(application) => application.isActive.get
case _ => false
}
}
@ -523,10 +523,10 @@ object APIUtil extends MdcLoggable {
}
if(parsedDate.isDefined){
Full(parsedDate.get)
parsedDate
}
else if(fallBackParsedDate.isDefined){
Full(fallBackParsedDate.get)
fallBackParsedDate
}
else{
Failure(FilterDateFormatError)

View File

@ -1729,19 +1729,19 @@ trait APIMethods210 {
setFilterPart1 <- Full(parameters += OBPLimit(limit) +=OBPOffset(offset) += OBPFromDate(startDate)+= OBPToDate(endDate))
setFilterPart2 <- if (!consumerId.isEmpty)
Full(parameters += OBPConsumerId(consumerId.get))
Full(parameters += OBPConsumerId(consumerId.getOrElse("")))
else if (!userId.isEmpty)
Full(parameters += OBPUserId(userId.get))
Full(parameters += OBPUserId(userId.getOrElse("")))
else if (!url.isEmpty)
Full(parameters += OBPUrl(url.get))
Full(parameters += OBPUrl(url.getOrElse("")))
else if (!appName.isEmpty)
Full(parameters += OBPAppName(appName.get))
Full(parameters += OBPAppName(appName.getOrElse("")))
else if (!implementedInVersion.isEmpty)
Full(parameters += OBPImplementedInVersion(implementedInVersion.get))
Full(parameters += OBPImplementedInVersion(implementedInVersion.getOrElse("")))
else if (!implementedByPartialFunction.isEmpty)
Full(parameters += OBPImplementedByPartialFunction(implementedByPartialFunction.get))
Full(parameters += OBPImplementedByPartialFunction(implementedByPartialFunction.getOrElse("")))
else if (!verb.isEmpty)
Full(parameters += OBPVerb(verb.get))
Full(parameters += OBPVerb(verb.getOrElse("")))
else
Full(parameters)

View File

@ -56,7 +56,7 @@ class ViewImpl extends View with LongKeyedMapper[ViewImpl] with ManyToMany with
def getSingleton = ViewImpl
def primaryKeyField = id_
object users_ extends MappedManyToMany(ViewPrivileges, ViewPrivileges.view, ViewPrivileges.user, ResourceUser)
//object users_ extends MappedManyToMany(ViewPrivileges, ViewPrivileges.view, ViewPrivileges.user, ResourceUser)
object bankPermalink extends MappedString(this, 255)
object accountPermalink extends MappedString(this, 255)
@ -67,7 +67,7 @@ class ViewImpl extends View with LongKeyedMapper[ViewImpl] with ManyToMany with
object description_ extends MappedString(this, 255)
object permalink_ extends MappedString(this, 255)
def users : List[User] = users_.toList
def users : List[User] = List.empty //users_.toList
//Important! If you add a field, be sure to handle it here in this function
def setFromViewData(viewData : ViewSpecification) = {

View File

@ -103,8 +103,10 @@ class RemotedataViewsActor extends Actor with ObpActorHelper with MdcLoggable {
sender ! extractResult(mapper.getNonPublicBankAccounts(user))
case cc.createOwnerView(bankId, accountId, description) =>
logger.debug("createOwnerView(" + bankId +", "+ accountId +", "+ description +")")
sender ! extractResult(mapper.createOwnerView(bankId, accountId, description))
logger.info("createOwnerView(" + bankId +", "+ accountId +", "+ description +")")
val res = extractResult(mapper.createOwnerView(bankId, accountId, description))
println("------------------------------------> res=" + res)
sender ! res.asInstanceOf[code.model.View]
case cc.createPublicView(bankId, accountId, description) =>
logger.debug("createPublicView(" + bankId +", "+ accountId +", "+ description +")")

View File

@ -413,10 +413,12 @@ object MapperViews extends Views with MdcLoggable {
}
def createOwnerView(bankId: BankId, accountId: AccountId, description: String = "Owner View") : Box[View] = {
getExistingView(bankId, accountId, "Owner") match {
val res = getExistingView(bankId, accountId, "Owner") match {
case Empty => createDefaultOwnerView(bankId, accountId, description)
case Full(v) => Full(v)
}
println("============================================> res=" + res)
res
}
def getOwners(view: View) : Set[User] = {

View File

@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You must have received a copy of the GNU Affero General Public License
you should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Email: contact@tesobe.com

View File

@ -96,7 +96,7 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
//setupUserAndConsumer
Given("the app we are testing is registered and active")
Then("We must be able to find it")
Then("We should be able to find it")
//val consumers = OBPConsumer.findAll()
//assert(registeredApplication(KEY) == true)
@ -104,7 +104,7 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
val request = directLoginRequest
val response = makePostRequestAdditionalHeader(request, "", List(accessControlOriginHeader))
Then("We must get a 400 - Bad Request")
Then("We should get a 400 - Bad Request")
response.code must equal(400)
assertResponse(response, ErrorMessages.DirectLoginMissingParameters)
}
@ -114,14 +114,14 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
//setupUserAndConsumer
Given("the app we are testing is registered and active")
Then("We must be able to find it")
Then("We should be able to find it")
//assert(registeredApplication(KEY) == true)
When("we try to login with an invalid username/password")
val request = directLoginRequest
val response = makePostRequestAdditionalHeader(request, "", invalidUsernamePasswordHeaders)
Then("We must get a 401 - Unauthorized")
Then("We should get a 401 - Unauthorized")
response.code must equal(401)
assertResponse(response, ErrorMessages.InvalidLoginCredentials)
}
@ -131,7 +131,7 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
val request = directLoginRequest
val response = makePostRequestAdditionalHeader(request, "", invalidUsernamePasswordCharaterHeaders)
Then("We must get a 400 - Invalid Characters")
Then("We should get a 400 - Invalid Characters")
response.code must equal(400)
assertResponse(response, ErrorMessages.InvalidValueCharacters)
}
@ -148,13 +148,13 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
response = makePostRequestAdditionalHeader(request, "", validUsernameInvalidPasswordHeaders)
response = makePostRequestAdditionalHeader(request, "", validUsernameInvalidPasswordHeaders)
Then("We must get a 401 - the username has been locked")
Then("We should get a 401 - the username has been locked")
response.code must equal(401)
assertResponse(response, ErrorMessages.UsernameHasBeenLocked)
Then("We login in with the valid username and valid passpord, the username still be locked ")
response = makePostRequestAdditionalHeader(request, "", validHeaders)
Then("We must get a 401 - the username has been locked")
Then("We should get a 401 - the username has been locked")
response.code must equal(401)
assertResponse(response, ErrorMessages.UsernameHasBeenLocked)
@ -167,7 +167,7 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
When("We try to login with username/password")
val request = directLoginRequest
val response = makePostRequestAdditionalHeader(request, "", disabledConsumerKeyHeaders)
Then("We must get a 401")
Then("We should get a 401")
response.code must equal(401)
assertResponse(response, ErrorMessages.InvalidConsumerKey)
}
@ -177,14 +177,14 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
//setupUserAndConsumer
Given("the app we are testing is registered and active")
Then("We must be able to find it")
Then("We should be able to find it")
//assert(registeredApplication(KEY) == true)
When("we try to login with a missing DirectLogin header")
val request = directLoginRequest
val response = makePostRequest(request,"")
Then("We must get a 400 - Bad Request")
Then("We should get a 400 - Bad Request")
response.code must equal(400)
assertResponse(response, ErrorMessages.DirectLoginMissingParameters)
}
@ -194,14 +194,14 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
//setupUserAndConsumer
Given("the app we are testing is registered and active")
Then("We must be able to find it")
Then("We should be able to find it")
//assert(registeredApplication(KEY) == true)
When("the consumer key is invalid")
val request = directLoginRequest
val response = makePostRequestAdditionalHeader(request, "", invalidConsumerKeyHeaders)
Then("We must get a 401 - Unauthorized")
Then("We should get a 401 - Unauthorized")
response.code must equal(401)
assertResponse(response, ErrorMessages.InvalidConsumerKey)
}
@ -211,14 +211,14 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
//setupUserAndConsumer
Given("the app we are testing is registered and active")
Then("We must be able to find it")
Then("We should be able to find it")
//assert(registeredApplication(KEY) == true)
When("the header and credentials are good")
val request = directLoginRequest
val response = makePostRequestAdditionalHeader(request, "", validHeaders)
var token = "INVALID"
Then("We must get a 200 - OK and a token")
Then("We should get a 200 - OK and a token")
response.code must equal(200)
response.body match {
case JObject(List(JField(name, JString(value)))) =>
@ -235,7 +235,7 @@ class directloginTest extends ServerSetup with BeforeAndAfter {
val request2 = baseRequest / "obp" / "v2.0.0" / "my" / "accounts"
val response2 = makeGetRequest(request2, validHeadersWithToken)
Then("We must get a 200 - OK and an empty list of accounts")
Then("We should get a 200 - OK and an empty list of accounts")
response2.code must equal(200)
response2.body match {
case JArray(List()) =>

View File

@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You must have received a copy of the GNU Affero General Public License
you should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Email: contact@tesobe.com
@ -196,7 +196,7 @@ class OAuthTest extends ServerSetup {
Given("The application is registered and does not have a callback URL")
When("the request is sent")
val reply = getRequestToken(consumer, oob)
Then("we must get a 200 code")
Then("We should get a 200 code")
reply.code must equal (200)
And("we can extract the token form the body")
val requestToken = extractToken(reply.body)
@ -205,7 +205,7 @@ class OAuthTest extends ServerSetup {
Given("The application is registered and have a callback URL")
When("the request is sent")
val reply = getRequestToken(consumer, "localhost:8080/app")
Then("we must get a 200 code")
Then("We should get a 200 code")
reply.code must equal (200)
And("we can extract the token form the body")
val requestToken = extractToken(reply.body)
@ -214,23 +214,23 @@ class OAuthTest extends ServerSetup {
Given("The application not registered")
When("the request is sent")
val reply = getRequestToken(notRegisteredConsumer, oob)
Then("we must get a 401 code")
Then("We should get a 401 code")
reply.code must equal (401)
}
scenario("we don't get a request token since the application is not registered even with a callback URL", RequestToken, Oauth) {
Given("The application not registered")
When("the request is sent")
val reply = getRequestToken(notRegisteredConsumer, "localhost:8080/app")
Then("we must get a 401 code")
Then("We should get a 401 code")
reply.code must equal (401)
}
scenario("We don't get a request token since the application is not enabled", RequestToken, Oauth) {
Given("The application is not enabled")
When("The request is sent")
val reply = getRequestToken(disabledConsumer, oob)
Then("We must get a 401 code")
Then("We should get a 401 code")
reply.code must equal (401)
And("We must get message")
And("We should get message")
reply.body must equal (ErrorMessages.InvalidConsumerCredentials)
}
}
@ -245,7 +245,7 @@ class OAuthTest extends ServerSetup {
case Full(v) => v
case Empty => null
}
Then("we must get a verifier")
Then("We should get a verifier")
verifier must not equal (null)
}
scenario("the user login and is asked to enter the verifier manually", Verifier, Oauth){
@ -254,21 +254,21 @@ class OAuthTest extends ServerSetup {
val requestToken = extractToken(reply.body)
When("the browser is launched to login")
val verifier = getVerifier(requestToken.value, user1.username.get, user1Password)
Then("we must get a verifier")
Then("We should get a verifier")
verifier.isEmpty must equal (false)
}
scenario("the user cannot login because there is no token", Verifier, Oauth){
Given("there will be no token")
When("the browser is launched to login")
val verifier = getVerifier(user1.username.get, user1Password)
Then("we must not get a verifier")
Then("We should not get a verifier")
verifier.isEmpty must equal (true)
}
scenario("the user cannot login because the token does not exist", Verifier, Oauth){
Given("we will use a random request token")
When("the browser is launched to login")
val verifier = getVerifier(randomString(4), user1.username.get, user1Password)
Then("we must not get a verifier")
Then("We should not get a verifier")
verifier.isEmpty must equal (true)
}
}
@ -282,7 +282,7 @@ class OAuthTest extends ServerSetup {
}
When("when we ask for an access token")
val accessToken = getAccessToken(consumer, requestToken, verifier)
Then("we must get an access token")
Then("We should get an access token")
extractToken(accessToken.body)
}
scenario("we get an access token with a callback", AccessToken, Oauth){
@ -294,7 +294,7 @@ class OAuthTest extends ServerSetup {
}
When("when we ask for an access token")
val accessToken = getAccessToken(consumer, requestToken, verifier)
Then("we must get an access token")
Then("We should get an access token")
extractToken(accessToken.body)
}
scenario("we don't get an access token because the verifier is wrong", AccessToken, Oauth){
@ -303,7 +303,7 @@ class OAuthTest extends ServerSetup {
val requestToken = extractToken(reply.body)
When("when we ask for an access token")
val accessTokenReply = getAccessToken(consumer, requestToken, randomString(5))
Then("we must get a 401")
Then("We should get a 401")
accessTokenReply.code must equal (401)
}
scenario("we don't get an access token because the request token is wrong", AccessToken, Oauth){
@ -316,7 +316,7 @@ class OAuthTest extends ServerSetup {
When("when we ask for an access token with a request token")
val randomRequestToken = Token(randomString(5), randomString(5))
val accessTokenReply = getAccessToken(consumer, randomRequestToken, verifier)
Then("we must get a 401")
Then("We should get a 401")
accessTokenReply.code must equal (401)
}
scenario("we don't get an access token because the requestToken and the verifier are wrong", AccessToken, Oauth){
@ -325,7 +325,7 @@ class OAuthTest extends ServerSetup {
When("when we ask for an access token with a request token")
val randomRequestToken = Token(randomString(5), randomString(5))
val accessTokenReply = getAccessToken(consumer, randomRequestToken, randomString(5))
Then("we must get a 401")
Then("We should get a 401")
accessTokenReply.code must equal (401)
}
}
@ -346,14 +346,14 @@ class OAuthTest extends ServerSetup {
verifier = getVerifier(requestToken.value, user1.username.get, invalidPassword)
verifier = getVerifier(requestToken.value, user1.username.get, invalidPassword)
Then("we must get a locked account verifier")
Then("We should get a locked account verifier")
verifier.asInstanceOf[Failure].msg.contains(ErrorMessages.UsernameHasBeenLocked)
Then("We login in with valid username and password, it will still be failed")
verifier = getVerifier(requestToken.value, user1.username.get, user1Password)
Then("we must get a locked account verifier")
Then("We should get a locked account verifier")
verifier.asInstanceOf[Failure].msg.contains(ErrorMessages.UsernameHasBeenLocked)
Then("We unlock the username")
@ -371,7 +371,7 @@ class OAuthTest extends ServerSetup {
Then("we set the valid username, valid password and try to login")
val verifier = getVerifier(requestToken.value, user2.username.get, user2Password)
Then("we must get a message: " + accountValidationError)
Then("We should get a message: " + accountValidationError)
verifier.contains(accountValidationError) must equal (true)
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -266,12 +266,12 @@ class PhysicalCardsTest extends ServerSetup with DefaultUsers with DefaultConne
val request = (v1_3Request / "cards").GET <@(user1)
val response = makeGetRequest(request)
Then("We must get a 200")
Then("We should get a 200")
response.code must equal(200)
//dummy connector above tells us we must get back user1AllCards
//dummy connector above tells us We should get back user1AllCards
//we are just testing that the api calls the connector properly
And("We must get the correct cards")
And("We should get the correct cards")
val expectedCardNumbers = user1AllCards.map(_.bankCardNumber)
val json = response.body.extract[PhysicalCardsJSON]
val returnedCardNumbers = json.cards.map(_.bank_card_number)
@ -286,12 +286,12 @@ class PhysicalCardsTest extends ServerSetup with DefaultUsers with DefaultConne
val request = (v1_3Request / "banks" / bank.bankId.value / "cards").GET <@(user1)
val response = makeGetRequest(request)
Then("We must get a 200")
Then("We should get a 200")
response.code must equal(200)
//dummy connector above tells us we must get back user1CardsForOneBank
//dummy connector above tells us We should get back user1CardsForOneBank
//we are just testing that the api calls the connector properly
And("We must get the correct cards")
And("We should get the correct cards")
val expectedCardNumbers = user1CardsForOneBank.map(_.bankCardNumber)
val json = response.body.extract[PhysicalCardsJSON]

View File

@ -117,7 +117,7 @@ class AtmsTest extends V140ServerSetup with DefaultUsers {
val request = (v1_4Request / "banks" / BankWithoutLicense.value / "atms").GET <@ user1
val response = makeGetRequest(request)
Then("We must get a 200")
Then("We should get a 200")
response.code must equal(200)
}
@ -127,17 +127,17 @@ class AtmsTest extends V140ServerSetup with DefaultUsers {
val request = (v1_4Request / "banks" / BankWithLicense.value / "atms").GET <@ user1
val response = makeGetRequest(request)
Then("We must get a 200")
Then("We should get a 200")
response.code must equal(200)
And("We must get the right json format containing a list of ATMs")
And("We should get the right json format containing a list of ATMs")
val wholeResponseBody = response.body
val responseBodyOpt = wholeResponseBody.extractOpt[AtmsJson]
responseBodyOpt.isDefined must equal(true)
val responseBody = responseBodyOpt.get
And("We must get the right atms")
And("We should get the right atms")
val atms = responseBody.atms
// Order of ATMs in the list is arbitrary

View File

@ -146,7 +146,7 @@ class BranchesTest extends V140ServerSetup with DefaultUsers {
val request = (v1_4Request / "banks" / BankWithoutLicense.value / "branches").GET <@(user1)
val response = makeGetRequest(request)
Then("We must get a 200")
Then("We should get a 200")
response.code must equal(200)
}
@ -155,17 +155,17 @@ class BranchesTest extends V140ServerSetup with DefaultUsers {
val request = (v1_4Request / "banks" / BankWithLicense.value / "branches").GET <@(user1)
val response = makeGetRequest(request)
Then("We must get a 200")
Then("We should get a 200")
response.code must equal(200)
And("We must get the right json format containing a list of Branches")
And("We should get the right json format containing a list of Branches")
val wholeResponseBody = response.body
val responseBodyOpt = wholeResponseBody.extractOpt[BranchesJson]
responseBodyOpt.isDefined must equal(true)
val responseBody = responseBodyOpt.get
And("We must get the right branches")
And("We should get the right branches")
val branches = responseBody.branches
// Order of branches in the list is arbitrary

View File

@ -57,34 +57,34 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON1.user_id).size must equal(0)
val requestPost = (v1_4Request / "banks" / mockBankId1.value / "customer").POST <@ (user1)
val responsePost = makePostRequest(requestPost, write(customerPostJSON1))
Then("We must get a 400")
Then("We should get a 400")
responsePost.code must equal(400)
When("We add one required entitlement")
Entitlement.entitlement.vend.addEntitlement(mockBankId1.value, resourceUser1.userId, ApiRole.CanCreateCustomer.toString)
val responsePost1Entitlement = makePostRequest(requestPost, write(customerPostJSON1))
Then("We must get a 400")
Then("We should get a 400")
responsePost1Entitlement.code must equal(400)
When("We add all required entitlement")
Entitlement.entitlement.vend.addEntitlement(mockBankId1.value, resourceUser1.userId, ApiRole.CanCreateUserCustomerLink.toString)
val responsePost2Entitlement = makePostRequest(requestPost, write(customerPostJSON1))
Then("We must get a 200")
Then("We should get a 200")
responsePost2Entitlement.code must equal(200)
And("We must get the right information back")
And("We should get the right information back")
val infoPost = responsePost2Entitlement.body.extract[CustomerJsonV140]
When("We make the request")
val requestGet = (v1_4Request / "banks" / mockBankId1.value / "customer").GET <@ (user1)
val responseGet = makeGetRequest(requestGet)
Then("We must get a 200")
Then("We should get a 200")
responseGet.code must equal(200)
And("We must get the right information back")
And("We should get the right information back")
val infoGet = responseGet.body.extract[CustomerJsonV140]
And("POST feedback and GET feedback must be the same")
And("POST feedback and GET feedback should be the same")
infoGet must equal(infoPost)
And("User is linked to 1 customer")
@ -93,10 +93,10 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
When("We try to make the second request with same customer number at same bank")
val secondResponsePost = makePostRequest(requestPost, write(customerPostJSON1))
Then("We must get a 400")
Then("We should get a 400")
secondResponsePost.code must equal(400)
val error = for { JObject(o) <- secondResponsePost.body; JField("error", JString(error)) <- o } yield error
And("We must get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
error must contain (ErrorMessages.CustomerNumberAlreadyExists)
And("User is linked to 1 customer")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON1.user_id).size must equal(1)
@ -105,7 +105,7 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
val customerPostJSON2 = createCustomerJson(mockCustomerNumber2)
val requestPost2 = (v1_4Request / "banks" / mockBankId1.value / "customer").POST <@ (user1)
val responsePost2 = makePostRequest(requestPost2, write(customerPostJSON2))
Then("We must get a 200")
Then("We should get a 200")
responsePost2.code must equal(200)
And("User is linked to 2 customers")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON1.user_id).size must equal(2)
@ -117,17 +117,17 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
val customerPostJSON3 = createCustomerJson(mockCustomerNumber1)
val requestPost3 = (v1_4Request / "banks" / mockBankId2.value / "customer").POST <@ (user1)
val responsePost3 = makePostRequest(requestPost3, write(customerPostJSON3))
Then("We must get a 200")
Then("We should get a 200")
responsePost3.code must equal(200)
And("User is linked to 3 customers")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON1.user_id).size must equal(3)
When("We try to make the second request with same customer number at same bank")
val secondResponsePost3 = makePostRequest(requestPost3, write(customerPostJSON3))
Then("We must get a 400")
Then("We should get a 400")
secondResponsePost3.code must equal(400)
val error3 = for { JObject(o) <- secondResponsePost3.body; JField("error", JString(error)) <- o } yield error
And("We must get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
error3 must contain (ErrorMessages.CustomerNumberAlreadyExists)
And("User is linked to 3 customers")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON3.user_id).size must equal(3)

View File

@ -30,10 +30,10 @@ class MappedCustomerMessagesTest extends V140ServerSetup with DefaultUsers {
val request = (v1_4Request / "banks" / mockBankId1.value / "customer" / "messages").GET <@ user1
val response = makeGetRequest(request)
Then("We must get a 200")
Then("We should get a 200")
response.code must equal(200)
And("We must get no messages")
And("We should get no messages")
val json = response.body.extract[CustomerMessagesJson]
json.messages.size must equal(0)
}
@ -73,7 +73,7 @@ class MappedCustomerMessagesTest extends V140ServerSetup with DefaultUsers {
request = (v1_4Request / "banks" / mockBankId1.value / "customer" / customerId / "messages").POST <@ user1
val messageJson = AddCustomerMessageJson("some message", "some department", "some person")
response = makePostRequest(request, write(messageJson))
Then("We must get a 201")
Then("We should get a 201")
response.code must equal(201)
And("We should get that message when we do a get messages request ")

View File

@ -105,7 +105,7 @@ class ProductsTest extends ServerSetup with DefaultUsers with V140ServerSetup {
val request = (v1_4Request / "banks" / BankWithoutLicense.value / "products").GET <@(user1)
val response = makeGetRequest(request)
Then("We must get a 200")
Then("We should get a 200")
response.code must equal(200)
}
@ -115,17 +115,17 @@ class ProductsTest extends ServerSetup with DefaultUsers with V140ServerSetup {
val request = (v1_4Request / "banks" / BankWithLicense.value / "products").GET <@(user1)
val response = makeGetRequest(request)
Then("We must get a 200")
Then("We should get a 200")
response.code must equal(200)
And("We must get the right json format containing a list of products")
And("We should get the right json format containing a list of products")
val wholeResponseBody = response.body
val responseBodyOpt = wholeResponseBody.extractOpt[ProductsJson]
responseBodyOpt.isDefined must equal(true)
val responseBody = responseBodyOpt.get
And("We must get the right products")
And("We should get the right products")
val products = responseBody.products
// Order of Products in the list is arbitrary

View File

@ -74,7 +74,7 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
var request = (v1_4Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests").POST <@(user1)
var response = makePostRequest(request, write(transactionRequestBody))
Then("we must get a 201 created code")
Then("We should get a 201 created code")
response.code must equal(201)
//created a transaction request, check some return values. As type is SANDBOX_TAN, we expect no challenge
@ -82,7 +82,7 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
case JString(i) => i
case _ => ""
}
Then("We must have some new transaction id")
Then("We should have some new transaction id")
transId must not equal ("")
val status: String = (response.body \ "status") match {
@ -105,7 +105,7 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
"owner" / "transaction-requests").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val transactionRequests = response.body.children
transactionRequests.size must not equal(0)
@ -126,7 +126,7 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
"owner" / "transactions").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val transactions = response.body.children
@ -143,19 +143,19 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
//(do it here even though the payments test does test makePayment already)
val fromAccountBalance = getFromAccount.balance
And("the from account must have a balance smaller by the amount specified to pay")
And("the from account should have a balance smaller by the amount specified to pay")
fromAccountBalance must equal((beforeFromBalance - amt))
/*
And("the newest transaction for the account receiving the payment must have the proper amount")
And("the newest transaction for the account receiving the payment should have the proper amount")
newestToAccountTransaction.details.value.amount must equal(amt.toString)
*/
And("the account receiving the payment must have a new balance plus the amount paid")
And("the account receiving the payment should have a new balance plus the amount paid")
val toAccountBalance = getToAccount.balance
toAccountBalance must equal(beforeToBalance + amt)
And("there must now be 2 new transactions in the database (one for the sender, one for the receiver")
And("there should now be 2 new transactions in the database (one for the sender, one for the receiver")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore + 2)
}
}
@ -204,7 +204,7 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
var request = (v1_4Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests").POST <@ (user1)
var response = makePostRequest(request, write(transactionRequestBody))
Then("we must get a 201 created code")
Then("We should get a 201 created code")
response.code must equal(201)
//ok, created a transaction request, check some return values. As type is SANDBOX_TAN but over 100, we expect a challenge
@ -240,7 +240,7 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
"owner" / "transaction-requests").GET <@ (user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
var transactionRequests = response.body.children
@ -260,7 +260,7 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
request = (v1_4Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests" / transId / "challenge").POST <@ (user1)
response = makePostRequest(request, write(answerJson))
Then("we must get a 400 bad request code")
Then("We should get a 400 bad request code")
response.code must equal(400)
//TODO: check if allowed_attempts is decreased
@ -270,7 +270,7 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
request = (v1_4Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests" / transId / "challenge").POST <@ (user1)
response = makePostRequest(request, write(answerJson))
Then("we must get a 202 accepted code")
Then("We should get a 202 accepted code")
response.code must equal(202)
//check if returned data includes new transaction's id
@ -291,7 +291,7 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
"owner" / "transaction-requests").GET <@ (user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
transactionRequests = response.body.children
@ -309,19 +309,19 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
//(do it here even though the payments test does test makePayment already)
val fromAccountBalance = getFromAccount.balance
And("the from account must have a balance smaller by the amount specified to pay")
And("the from account should have a balance smaller by the amount specified to pay")
fromAccountBalance must equal((beforeFromBalance - amt))
/*
And("the newest transaction for the account receiving the payment must have the proper amount")
And("the newest transaction for the account receiving the payment should have the proper amount")
newestToAccountTransaction.details.value.amount must equal(amt.toString)
*/
And("the account receiving the payment must have a new balance plus the amount paid")
And("the account receiving the payment should have a new balance plus the amount paid")
val toAccountBalance = getToAccount.balance
toAccountBalance must equal(beforeToBalance + amt)
And("there must now be 2 new transactions in the database (one for the sender, one for the receiver")
And("there should now be 2 new transactions in the database (one for the sender, one for the receiver")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore + 2)
}
}
@ -357,13 +357,13 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user2)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
}
@ -397,13 +397,13 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, None)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
}
@ -439,13 +439,13 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
}
@ -482,13 +482,13 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
}
@ -517,13 +517,13 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(bankId.value, "ACCOUNTTHATDOESNOTEXIST232321321", amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for the sender's account must remain unchanged")
And("the number of transactions for the sender's account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount))
And("the balance of the sender's account must remain unchanged")
And("the balance of the sender's account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
}
@ -557,13 +557,13 @@ class TransactionRequestsTest extends V140ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
} */

View File

@ -23,14 +23,14 @@ class AccountTest extends V200ServerSetup with DefaultUsers {
val requestPut = (v2_0Request / "banks" / testBank.value / "accounts" / mockAccountId1).PUT <@ (user1)
val responsePut = makePutRequest(requestPut, write(accountPutJSON))
And("We must get a 200")
And("We should get a 200")
responsePut.code must equal(200)
When("We make the anonymous access request")
val requestGet = (v2_0Request / "accounts").GET
val responseGet = makeGetRequest(requestGet)
Then("We must get a 200")
Then("We should get a 200")
responseGet.code must equal(200)
val isPublic: List[Boolean] =
@ -47,7 +47,7 @@ class AccountTest extends V200ServerSetup with DefaultUsers {
val requestGetAll = (v2_0Request / "accounts").GET <@ (user1)
val responseGetAll = makeGetRequest(requestGetAll)
Then("We must get a 200")
Then("We should get a 200")
responseGetAll.code must equal(200)
val isPublicAll =
@ -71,14 +71,14 @@ class AccountTest extends V200ServerSetup with DefaultUsers {
val requestPut = (v2_0Request / "banks" / testBank.value / "accounts" / mockAccountId1).PUT <@ (user1)
val responsePut = makePutRequest(requestPut, write(accountPutJSON))
And("We must get a 200")
And("We should get a 200")
responsePut.code must equal(200)
When("We make the anonymous access request")
val requestGet = (v2_0Request / "banks" / testBank.value / "accounts").GET
val responseGet = makeGetRequest(requestGet)
Then("We must get a 200")
Then("We should get a 200")
responseGet.code must equal(200)
val isPublic: List[Boolean] =
@ -95,7 +95,7 @@ class AccountTest extends V200ServerSetup with DefaultUsers {
val requestGetAll = (v2_0Request / "banks" / testBank.value / "accounts").GET <@ (user1)
val responseGetAll = makeGetRequest(requestGetAll)
Then("We must get a 200")
Then("We should get a 200")
responseGetAll.code must equal(200)
val isPublicAll =
@ -120,14 +120,14 @@ class AccountTest extends V200ServerSetup with DefaultUsers {
val requestPut = (v2_0Request / "banks" / testBank.value / "accounts" / newAccountIdWithSpaces).PUT <@ (user1)
val responsePut = makePutRequest(requestPut, write(accountPutJSON))
And("We must get a 400")
And("We should get a 400")
responsePut.code must equal(400)
And("We must have the error massage")
And("We should have the error massage")
val error: String = (responsePut.body \ "error") match {
case JString(i) => i
case _ => ""
}
Then("We must have the error: " + ErrorMessages.InvalidAccountIdFormat)
Then("We should have the error: " + ErrorMessages.InvalidAccountIdFormat)
error must equal(ErrorMessages.InvalidAccountIdFormat)
}
}

View File

@ -79,7 +79,7 @@ class CreateUserTest extends V200ServerSetup with BeforeAndAfter {
var request = (v2_0Request / "users").POST
var response = makePostRequest(request, write(params))
Then("we must get a 201 created code")
Then("We should get a 201 created code")
response.code must equal(201)
}
@ -88,7 +88,7 @@ class CreateUserTest extends V200ServerSetup with BeforeAndAfter {
var request = directLoginRequest
var response = makePostRequestAdditionalHeader(request, "", validHeaders)
var token = "INVALID"
Then("we must get a 200 - OK and a token")
Then("We should get a 200 - OK and a token")
response.code must equal(200)
response.body match {
case JObject(List(JField(name, JString(value)))) =>
@ -103,7 +103,7 @@ class CreateUserTest extends V200ServerSetup with BeforeAndAfter {
scenario("we login using OAuth as newly created user", CreateUser) {
When("the request an OAuth token")
val reply = getRequestToken(consumer, oob)
Then("we must get a 200 - OK and a token")
Then("We should get a 200 - OK and a token")
reply.code must equal (200)
val requestToken = extractToken(reply.body)
requestToken.value.size must not equal (0)
@ -119,7 +119,7 @@ class CreateUserTest extends V200ServerSetup with BeforeAndAfter {
val request = (v2_0Request / "users").POST
val response = makePostRequest(request, write(params))
Then("we must get a 409 created code")
Then("We should get a 409 created code")
response.code must equal(409)
}

View File

@ -44,34 +44,34 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON.user_id).size must equal(0)
val requestPost = (v2_0Request / "banks" / mockBankId1.value / "customers").POST <@ (user1)
val responsePost = makePostRequest(requestPost, write(customerPostJSON))
Then("We must get a 400")
Then("We should get a 400")
responsePost.code must equal(400)
When("We add one required entitlement")
Entitlement.entitlement.vend.addEntitlement(mockBankId1.value, resourceUser1.userId, ApiRole.CanCreateCustomer.toString)
val responsePost1 = makePostRequest(requestPost, write(customerPostJSON))
Then("We must get a 400")
Then("We should get a 400")
responsePost1.code must equal(400)
When("We add all required entitlement")
Entitlement.entitlement.vend.addEntitlement(mockBankId1.value, resourceUser1.userId, ApiRole.CanCreateUserCustomerLink.toString)
val responsePost2 = makePostRequest(requestPost, write(customerPostJSON))
Then("We must get a 201")
Then("We should get a 201")
responsePost2.code must equal(201)
And("We must get the right information back")
And("We should get the right information back")
val infoPost = responsePost2.body.extract[CustomerJsonV140]
When("We make the request")
val requestGet = (v2_0Request / "banks" / mockBankId1.value / "customer").GET <@ (user1)
val responseGet = makeGetRequest(requestGet)
Then("We must get a 200")
Then("We should get a 200")
responseGet.code must equal(200)
And("We must get the right information back")
And("We should get the right information back")
val infoGet = responseGet.body.extract[CustomerJsonV140]
And("POST feedback and GET feedback must be the same")
And("POST feedback and GET feedback should be the same")
infoGet must equal(infoPost)
And("User is linked to 1 customer")
@ -80,10 +80,10 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
When("We try to make the second request with same customer number at same bank")
val secondResponsePost = makePostRequest(requestPost, write(customerPostJSON))
Then("We must get a 400")
Then("We should get a 400")
secondResponsePost.code must equal(400)
val error = for { JObject(o) <- secondResponsePost.body; JField("error", JString(error)) <- o } yield error
And("We must get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
error must contain (ErrorMessages.CustomerNumberAlreadyExists)
And("User is linked to 1 customer")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON.user_id).size must equal(1)
@ -92,7 +92,7 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
val customerPostJSON3 = createCustomerJson(mockCustomerNumber2)
val requestPost3 = (v2_0Request / "banks" / mockBankId1.value / "customers").POST <@ (user1)
val responsePost3 = makePostRequest(requestPost3, write(customerPostJSON3))
Then("We must get a 201")
Then("We should get a 201")
responsePost3.code must equal(201)
And("User is linked to 2 customers")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON3.user_id).size must equal(2)
@ -104,17 +104,17 @@ class CustomerTest extends V200ServerSetup with DefaultUsers {
val customerPostJSON4 = createCustomerJson(mockCustomerNumber1)
val requestPost4 = (v2_0Request / "banks" / mockBankId2.value / "customers").POST <@ (user1)
val responsePost4 = makePostRequest(requestPost4, write(customerPostJSON4))
Then("We must get a 201")
Then("We should get a 201")
responsePost4.code must equal(201)
And("User is linked to 3 customers")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON4.user_id).size must equal(3)
When("We try to make the second request with same customer number at same bank")
val secondResponsePost4 = makePostRequest(requestPost4, write(customerPostJSON4))
Then("We must get a 400")
Then("We should get a 400")
secondResponsePost4.code must equal(400)
val error4 = for { JObject(o) <- secondResponsePost4.body; JField("error", JString(error)) <- o } yield error
And("We must get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
error4 must contain (ErrorMessages.CustomerNumberAlreadyExists)
And("User is linked to 3 customers")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON.user_id).size must equal(3)

View File

@ -28,10 +28,10 @@ class EntitlementTests extends V200ServerSetup with DefaultUsers {
When("We make the request")
val requestGet = (v2_0Request / "users" / resourceUser1.userId / "entitlements").GET
val responseGet = makeGetRequest(requestGet)
Then("We must get a 400")
Then("We should get a 400")
responseGet.code must equal(400)
val error = for { JObject(o) <- responseGet.body; JField("error", JString(error)) <- o } yield error
And("We must get a message: " + ErrorMessages.UserNotLoggedIn)
And("We should get a message: " + ErrorMessages.UserNotLoggedIn)
error must contain (ErrorMessages.UserNotLoggedIn)
}
@ -40,10 +40,10 @@ class EntitlementTests extends V200ServerSetup with DefaultUsers {
When("We make the request")
val requestGet = (v2_0Request / "users" / resourceUser1.userId / "entitlements").GET <@ (user1)
val responseGet = makeGetRequest(requestGet)
Then("We must get a 400")
Then("We should get a 400")
responseGet.code must equal(400)
val error = for { JObject(o) <- responseGet.body; JField("error", JString(error)) <- o } yield error
And("We must get a message: " + s"$CanGetEntitlementsForAnyUserAtAnyBank entitlement required")
And("We should get a message: " + s"$CanGetEntitlementsForAnyUserAtAnyBank entitlement required")
error must contain (UserDoesNotHaveRole + CanGetEntitlementsForAnyUserAtAnyBank)
}
@ -53,7 +53,7 @@ class EntitlementTests extends V200ServerSetup with DefaultUsers {
And("We make the request")
val requestGet = (v2_0Request / "users" / resourceUser1.userId / "entitlements").GET <@ (user1)
val responseGet = makeGetRequest(requestGet)
Then("We must get a 200")
Then("We should get a 200")
responseGet.code must equal(200)
}
}

View File

@ -1,7 +1,8 @@
package code.api.v2_0_0
import code.api.ErrorMessage
import code.api.util.ErrorMessages
import code.api.{DefaultUsers, ErrorMessage, ServerSetupWithTestData}
import code.setup.{DefaultUsers, ServerSetupWithTestData}
import code.api.util.APIUtil.OAuth._
import code.api.v1_2_1.AmountOfMoneyJsonV121
import code.api.v1_4_0.JSONFactory1_4_0.{ChallengeAnswerJSON, TransactionRequestAccountJsonV140}
@ -42,10 +43,10 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val bankId = testBank.bankId
val accountId1 = AccountId("__acc1")
val accountId2 = AccountId("__acc2")
createAccountAndOwnerView(Some(authuser1), bankId, accountId1, "EUR")
createAccountAndOwnerView(Some(authuser1), bankId, accountId2, "EUR")
createAccountAndOwnerView(Some(resourceUser1), bankId, accountId1, "EUR")
createAccountAndOwnerView(Some(resourceUser1), bankId, accountId2, "EUR")
addEntitlement(bankId.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
addEntitlement(bankId.value, resourceUser3.userId, CanCreateAnyTransactionRequest.toString)
Then("We add entitlement to user3")
val hasEntitlement = code.api.util.APIUtil.hasEntitlement(bankId.value, resourceUser3.userId, CanCreateAnyTransactionRequest)
hasEntitlement must equal(true)
@ -83,7 +84,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
var request = (v2_0Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests").POST <@(user3)
var response = makePostRequest(request, write(transactionRequestBody))
Then("we must get a 201 created code")
Then("We should get a 201 created code")
response.code must equal(201)
println(response.body)
@ -93,7 +94,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
case JString(i) => i
case _ => ""
}
Then("We must have some new transaction id")
Then("We should have some new transaction id")
transRequestId must not equal ("")
val responseBody = response.body
@ -105,7 +106,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
}
status must equal (code.transactionrequests.TransactionRequests.STATUS_COMPLETED)
// Challenge must be null (none required)
// Challenge should be null (none required)
var challenge = (response.body \ "challenge").children
challenge.size must equal(0)
@ -121,7 +122,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transaction-requests").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val transactionRequests = response.body.children
transactionRequests.size must not equal(0)
@ -145,7 +146,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transactions").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val transactions = response.body.children
@ -164,19 +165,19 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val rate = fx.exchangeRate (fromAccount.currency, toAccount.currency)
val convertedAmount = fx.convert(amt, rate)
val fromAccountBalance = getFromAccount.balance
And("the from account must have a balance smaller by the amount specified to pay")
And("the from account should have a balance smaller by the amount specified to pay")
fromAccountBalance must equal((beforeFromBalance - convertedAmount))
/*
And("the newest transaction for the account receiving the payment must have the proper amount")
And("the newest transaction for the account receiving the payment should have the proper amount")
newestToAccountTransaction.details.value.amount must equal(amt.toString)
*/
And("the account receiving the payment must have a new balance plus the amount paid")
And("the account receiving the payment should have a new balance plus the amount paid")
val toAccountBalance = getToAccount.balance
toAccountBalance must equal(beforeToBalance + convertedAmount)
And("there must now be 2 new transactions in the database (one for the sender, one for the receiver")
And("there should now be 2 new transactions in the database (one for the sender, one for the receiver")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore + 2)
}
}
@ -227,7 +228,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
var request = (v2_0Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests").POST <@(user1)
var response = makePostRequest(request, write(transactionRequestBody))
Then("we must get a 201 created code")
Then("We should get a 201 created code")
response.code must equal(201)
//created a transaction request, check some return values. As type is SANDBOX_TAN and value is < 1000, we expect no challenge
@ -235,7 +236,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
case JString(i) => i
case _ => ""
}
Then("We must have some new transaction id")
Then("We should have some new transaction id")
transRequestId must not equal ("")
val responseBody = response.body
@ -247,7 +248,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
}
status must equal (code.transactionrequests.TransactionRequests.STATUS_COMPLETED)
// Challenge must be null (none required)
// Challenge should be null (none required)
var challenge = (response.body \ "challenge").children
challenge.size must equal(0)
@ -262,7 +263,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transaction-requests").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val transactionRequests = response.body.children
transactionRequests.size must not equal(0)
@ -286,7 +287,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transactions").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val transactions = response.body.children
@ -304,19 +305,19 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val rate = fx.exchangeRate (fromAccount.currency, toAccount.currency)
val convertedAmount = fx.convert(amt, rate)
val fromAccountBalance = getFromAccount.balance
And("the from account must have a balance smaller by the amount specified to pay")
And("the from account should have a balance smaller by the amount specified to pay")
fromAccountBalance must equal((beforeFromBalance - convertedAmount))
/*
And("the newest transaction for the account receiving the payment must have the proper amount")
And("the newest transaction for the account receiving the payment should have the proper amount")
newestToAccountTransaction.details.value.amount must equal(amt.toString)
*/
And("the account receiving the payment must have a new balance plus the amount paid")
And("the account receiving the payment should have a new balance plus the amount paid")
val toAccountBalance = getToAccount.balance
toAccountBalance must equal(beforeToBalance + convertedAmount)
And("there must now be 2 new transactions in the database (one for the sender, one for the receiver")
And("there should now be 2 new transactions in the database (one for the sender, one for the receiver")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore + 2)
}
}
@ -353,7 +354,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val request = (v2_0Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests").POST <@(user2)
val response = makePostRequest(request, write(transactionRequestBody))
Then("we must get a 400 created code")
Then("We should get a 400 created code")
response.code must equal(400)
//created a transaction request, check some return values. As type is SANDBOX_TAN and value is < 1000, we expect no challenge
@ -361,7 +362,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
case JString(i) => i
case _ => ""
}
Then("We must have the error: " + ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
Then("We should have the error: " + ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
error must equal (ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
}
@ -413,7 +414,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val request = (v2_0Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests").POST <@ (user3)
val response = makePostRequest(request, write(transactionRequestBody))
Then("we must get a 400 created code")
Then("We should get a 400 created code")
response.code must equal(400)
//created a transaction request, check some return values. As type is SANDBOX_TAN and value is < 1000, we expect no challenge
@ -421,7 +422,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
case JString(i) => i
case _ => ""
}
Then("We must have the error: " + ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
Then("We should have the error: " + ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
error must equal (ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
@ -493,7 +494,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
var request = (v2_0Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests").POST <@(user1)
var response = makePostRequest(request, write(transactionRequestBody))
Then("we must get a 201 created code")
Then("We should get a 201 created code")
response.code must equal(201)
@ -504,7 +505,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
case JString(i) => i
case _ => ""
}
Then("We must have some new transaction request id")
Then("We should have some new transaction request id")
transRequestId must not equal ("")
val status: String = (response.body \ "status") match {
@ -514,7 +515,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
status must equal (code.transactionrequests.TransactionRequests.STATUS_COMPLETED)
Then("we must not have a challenge object")
Then("We should not have a challenge object")
var challenge = (response.body \ "challenge").children
challenge.size must equal(0)
@ -529,7 +530,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transaction-requests").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val transactionRequests = response.body.children
transactionRequests.size must not equal(0)
@ -550,7 +551,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transactions").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val fromTransactions = response.body.children
@ -585,7 +586,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transactions").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val toTransactions = response.body.children
@ -617,24 +618,24 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val rate = fx.exchangeRate (fromAccount.currency, toAccount.currency)
val convertedAmount = fx.convert(amt, rate)
val fromAccountBalance = getFromAccount.balance
And("the from account must have a balance smaller by the original amount specified to pay")
And("the from account should have a balance smaller by the original amount specified to pay")
fromAccountBalance must equal(beforeFromBalance - amt)
//val fromAccountBalance = getFromAccount.balance
//And("the from account must have a balance smaller by the amount specified to pay")
//And("the from account should have a balance smaller by the amount specified to pay")
//fromAccountBalance must equal((beforeFromBalance - amt))
/*
And("the newest transaction for the account receiving the payment must have the proper amount")
And("the newest transaction for the account receiving the payment should have the proper amount")
newestToAccountTransaction.details.value.amount must equal(amt.toString)
*/
And("the account receiving the payment must have a new balance plus the amount paid")
And("the account receiving the payment should have a new balance plus the amount paid")
val toAccountBalance = getToAccount.balance
toAccountBalance must equal(beforeToBalance + convertedAmount)
And("there must now be 2 new transactions in the database (one for the sender, one for the receiver)")
And("there should now be 2 new transactions in the database (one for the sender, one for the receiver)")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore + 2)
}
}
@ -688,7 +689,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
var request = (v2_0Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests").POST <@ (user1)
var response = makePostRequest(request, write(transactionRequestBody))
Then("we must get a 201 created code")
Then("We should get a 201 created code")
response.code must equal(201)
//ok, created a transaction request, check some return values. As type is SANDBOX_TAN but over 100, we expect a challenge
@ -724,7 +725,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transaction-requests").GET <@ (user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
var transactionRequests = response.body.children
@ -744,7 +745,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
request = (v1_4Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests" / transRequestId / "challenge").POST <@ (user1)
response = makePostRequest(request, write(answerJson))
Then("we must get a 400 bad request code")
Then("We should get a 400 bad request code")
response.code must equal(400)
//TODO: check if allowed_attempts is decreased
@ -754,7 +755,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
request = (v1_4Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests" / transRequestId / "challenge").POST <@ (user1)
response = makePostRequest(request, write(answerJson))
Then("we must get a 202 accepted code")
Then("We should get a 202 accepted code")
response.code must equal(202)
//check if returned data includes new transaction's id
@ -775,7 +776,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transaction-requests").GET <@ (user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
transactionRequests = response.body.children
@ -793,19 +794,19 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
//(do it here even though the payments test does test makePayment already)
val fromAccountBalance = getFromAccount.balance
And("the from account must have a balance smaller by the amount specified to pay")
And("the from account should have a balance smaller by the amount specified to pay")
fromAccountBalance must equal((beforeFromBalance - amt))
/*
And("the newest transaction for the account receiving the payment must have the proper amount")
And("the newest transaction for the account receiving the payment should have the proper amount")
newestToAccountTransaction.details.value.amount must equal(amt.toString)
*/
And("the account receiving the payment must have a new balance plus the amount paid")
And("the account receiving the payment should have a new balance plus the amount paid")
val toAccountBalance = getToAccount.balance
toAccountBalance must equal(beforeToBalance + amt)
And("there must now be 2 new transactions in the database (one for the sender, one for the receiver")
And("there should now be 2 new transactions in the database (one for the sender, one for the receiver")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore + 2)
}
}
@ -877,7 +878,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
var request = (v2_0Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests").POST <@(user1)
var response = makePostRequest(request, write(transactionRequestBody))
Then("we must get a 201 created code")
Then("We should get a 201 created code")
response.code must equal(201)
//created a transaction request, check some return values. As type is SANDBOX_TAN, we expect no challenge
@ -885,7 +886,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
case JString(i) => i
case _ => ""
}
Then("We must have some new transaction id")
Then("We should have some new transaction id")
transRequestId must not equal ("")
var status: String = (response.body \ "status") match {
@ -914,7 +915,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transaction-requests").GET <@ (user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
var transactionRequests = response.body.children
@ -925,7 +926,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
}
transaction_ids must equal ("")
//Then("we must have a challenge object")
//Then("We should have a challenge object")
//challenge = (response.body \ "challenge").children
// TODO fix this path challenge.size must not equal(0)
@ -935,7 +936,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
request = (v2_0Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests" / transRequestId / "challenge").POST <@ (user1)
response = makePostRequest(request, write(answerJson))
Then("we must get a 400 bad request code")
Then("We should get a 400 bad request code")
response.code must equal(400)
//TODO: check if allowed_attempts is decreased
@ -945,7 +946,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
request = (v2_0Request / "banks" / testBank.bankId.value / "accounts" / fromAccount.accountId.value /
"owner" / "transaction-request-types" / "SANDBOX_TAN" / "transaction-requests" / transRequestId / "challenge").POST <@ (user1)
response = makePostRequest(request, write(answerJson))
Then("we must get a 202 accepted code")
Then("We should get a 202 accepted code")
response.code must equal(202)
//check if returned data includes new transaction's id
@ -966,7 +967,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transaction-requests").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
transactionRequests = response.body.children
@ -988,7 +989,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transactions").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val fromTransactions = response.body.children
@ -1023,7 +1024,7 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
"owner" / "transactions").GET <@(user1)
response = makeGetRequest(request)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
response.code must equal(200)
val toTransactions = response.body.children
@ -1055,24 +1056,24 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val rate = fx.exchangeRate (fromAccount.currency, toAccount.currency)
val convertedAmount = fx.convert(amt, rate)
val fromAccountBalance = getFromAccount.balance
And("the from account must have a balance smaller by the original amount specified to pay")
And("the from account should have a balance smaller by the original amount specified to pay")
fromAccountBalance must equal(beforeFromBalance - amt)
//val fromAccountBalance = getFromAccount.balance
//And("the from account must have a balance smaller by the amount specified to pay")
//And("the from account should have a balance smaller by the amount specified to pay")
//fromAccountBalance must equal((beforeFromBalance - amt))
/*
And("the newest transaction for the account receiving the payment must have the proper amount")
And("the newest transaction for the account receiving the payment should have the proper amount")
newestToAccountTransaction.details.value.amount must equal(amt.toString)
*/
And("the account receiving the payment must have a new balance plus the amount paid")
And("the account receiving the payment should have a new balance plus the amount paid")
val toAccountBalance = getToAccount.balance
toAccountBalance must equal(beforeToBalance + convertedAmount)
And("there must now be 2 new transactions in the database (one for the sender, one for the receiver)")
And("there should now be 2 new transactions in the database (one for the sender, one for the receiver)")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore + 2)
}
}
@ -1108,13 +1109,13 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user2)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
}
@ -1148,13 +1149,13 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, None)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
}
@ -1190,13 +1191,13 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
}
@ -1233,13 +1234,13 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
}
@ -1268,13 +1269,13 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(bankId.value, "ACCOUNTTHATDOESNOTEXIST232321321", amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for the sender's account must remain unchanged")
And("the number of transactions for the sender's account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount))
And("the balance of the sender's account must remain unchanged")
And("the balance of the sender's account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
}
@ -1308,13 +1309,13 @@ class TransactionRequestsTest extends V200ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
} */

View File

@ -45,7 +45,7 @@ class CreateBranchTest extends V210ServerSetup with DefaultUsers {
var requestPut = (v2_1Request / "banks" / bankId.value / "branches" / branchId.value ).PUT <@ (user1)
var responsePut = makePutRequest(requestPut, write(customerPutJSON))
Then("We must get a 201 and check all the fields")
Then("We should get a 201 and check all the fields")
responsePut.code must equal(201)
var nameResponse = (responsePut.body \ "name" ) match {
@ -76,7 +76,7 @@ class CreateBranchTest extends V210ServerSetup with DefaultUsers {
requestPut = (v2_1Request / "banks" / bankId.value / "branches" / branchId.value ).PUT <@ (user1)
responsePut = makePutRequest(requestPut, write(customerPutJSON2))
Then("We must get a 201 and check all the fields")
Then("We should get a 201 and check all the fields")
responsePut.code must equal(201)
var nameResponse = (responsePut.body \ "name" ) match {
@ -117,7 +117,7 @@ class CreateBranchTest extends V210ServerSetup with DefaultUsers {
val requestPut = (v2_1Request / "banks" / bankId.value / "branches").POST <@ (user1)
val responsePost = makePostRequest(requestPut, write(customerPostJSON))
Then("We must get a 201 and check all the fields")
Then("We should get a 201 and check all the fields")
responsePost.code must equal(201)
var nameResponse = (responsePost.body \ "name" ) match {
@ -147,7 +147,7 @@ class CreateBranchTest extends V210ServerSetup with DefaultUsers {
var requestPost = (v2_1Request / "banks" / bankId.value / "branches").POST <@ (user1)
var responsePost = makePostRequest(requestPost, write(customerPostJSON))
Then("We must get a 201 and check all the fields")
Then("We should get a 201 and check all the fields")
responsePost.code must equal(201)
val customerPostJSON2 = customerPostJSON.copy(name="OBP1")
@ -155,7 +155,7 @@ class CreateBranchTest extends V210ServerSetup with DefaultUsers {
requestPost = (v2_1Request / "banks" / bankId.value / "branches" / branchId.value ).PUT <@ (user1)
responsePost = makePutRequest(requestPost, write(customerPostJSON2))
Then("We must get a 201 and check all the fields")
Then("We should get a 201 and check all the fields")
responsePost.code must equal(201)
var nameResponse = (responsePost.body \ "name" ) match {

View File

@ -47,7 +47,7 @@ class CreateCounterpartyTest extends V210ServerSetup with DefaultUsers {
val requestPost = (v2_1Request / "banks" / bankId.value / "accounts" / accountId.value / viewId.value / "counterparties" ).POST <@ (user1)
val responsePost = makePostRequest(requestPost, write(counterpartyPostJSON))
Then("We must get a 200 and check all the fields")
Then("We should get a 200 and check all the fields")
responsePost.code must equal(200)
var accountRoutingAddress = (responsePost.body \ "other_account_routing_address" ) match {
@ -70,7 +70,7 @@ class CreateCounterpartyTest extends V210ServerSetup with DefaultUsers {
val requestPost = (v2_1Request / "banks" / bankId.value / "accounts" / accountId.value / viewId.value / "counterparties" ).POST <@ (user1)
val responsePost = makePostRequest(requestPost, write(counterpartyPostJSON))
Then("We must get a 400")
Then("We should get a 400")
responsePost.code must equal(400)
val error = for { JObject(o) <- responsePost.body; JField("error", JString(error)) <- o } yield error
@ -92,7 +92,7 @@ class CreateCounterpartyTest extends V210ServerSetup with DefaultUsers {
Then("We make the request again, the same name/bank_id/account_id/view_id")
responsePost = makePostRequest(requestPost, write(counterpartyPostJSON))
Then("We must get a 400 and check the error massage")
Then("We should get a 400 and check the error massage")
responsePost.code must equal(400)
val error = for { JObject(o) <- responsePost.body; JField("error", JString(error)) <- o } yield error

View File

@ -43,10 +43,10 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers {
When("We make the request")
val requestPut = (v2_1Request / "banks" / mockBankId1.value / "transaction-types").PUT <@ (user1)
val responsePut = makePutRequest(requestPut, write(transactionTypeJSON))
Then("We must get a 400")
Then("We should get a 400")
responsePut.code must equal(400)
val error = for {JObject(o) <- responsePut.body; JField("error", JString(error)) <- o} yield error
And("We must get a message: " + ErrorMessages.InsufficientAuthorisationToCreateTransactionType)
And("We should get a message: " + ErrorMessages.InsufficientAuthorisationToCreateTransactionType)
error must contain(ErrorMessages.InsufficientAuthorisationToCreateTransactionType)
}
@ -58,7 +58,7 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers {
val requestPut = (v2_1Request / "banks" / mockBankId1.value / "transaction-types").PUT <@ (user1)
val responsePut = makePutRequest(requestPut, write(transactionTypeJSON))
And("We must get a 200")
And("We should get a 200")
responsePut.code must equal(200)
}
}
@ -73,7 +73,7 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers {
val requestPut1 = (v2_1Request / "banks" / mockBankId1.value / "transaction-types").PUT <@ (user1)
val responsePut1 = makePutRequest(requestPut1, write(transactionTypeJSON))
And("We must get a 200")
And("We should get a 200")
responsePut1.code must equal(200)
Then("update input value and We make the request")
@ -88,7 +88,7 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers {
val requestPut = (v2_1Request / "banks" / mockBankId1.value / "transaction-types").PUT <@ (user1)
val responsePut = makePutRequest(requestPut, write(transactionTypeJSON2))
And("We must get a 200")
And("We should get a 200")
responsePut.code must equal(200)
}
@ -100,7 +100,7 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers {
val requestPut1 = (v2_1Request / "banks" / mockBankId1.value / "transaction-types").PUT <@ (user1)
val responsePut1 = makePutRequest(requestPut1, write(transactionTypeJSON))
And("We must get a 200")
And("We should get a 200")
responsePut1.code must equal(200)
Then("insert new data and We make the request")
@ -115,10 +115,10 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers {
val requestPut2 = (v2_1Request / "banks" / mockBankId1.value / "transaction-types").PUT <@ (user1)
val responsePut2 = makePutRequest(requestPut2, write(transactionTypeJSON1))
And("We must get a 400")
And("We should get a 400")
responsePut2.code must equal(400)
val errorInsert = for {JObject(o) <- responsePut2.body; JField("error", JString(error)) <- o} yield error
And("We must get a message: " + ErrorMessages.CreateTransactionTypeInsertError)
And("We should get a message: " + ErrorMessages.CreateTransactionTypeInsertError)
errorInsert must contain(ErrorMessages.CreateTransactionTypeInsertError)
@ -134,10 +134,10 @@ class CreateTransactionTypeTest extends V210ServerSetup with DefaultUsers {
val requestPut3 = (v2_1Request / "banks" / mockBankId1.value / "transaction-types").PUT <@ (user1)
val responsePut3 = makePutRequest(requestPut3, write(transactionTypeJSON2))
And("We must get a 400")
And("We should get a 400")
responsePut3.code must equal(400)
val errorUpdate = for {JObject(o) <- responsePut3.body; JField("error", JString(error)) <- o} yield error
And("We must get a message: " + ErrorMessages.CreateTransactionTypeUpdateError)
And("We should get a message: " + ErrorMessages.CreateTransactionTypeUpdateError)
errorUpdate must contain(ErrorMessages.CreateTransactionTypeUpdateError)
}
}

View File

@ -46,35 +46,35 @@ class CustomerTest extends V210ServerSetup with DefaultUsers {
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON.user_id).size must equal(0)
val requestPost = (v2_1Request / "banks" / mockBankId1.value / "customers").POST <@ (user1)
val responsePost = makePostRequest(requestPost, write(customerPostJSON))
Then("We must get a 400")
Then("We should get a 400")
responsePost.code must equal(400)
When("We add one required entitlement")
Entitlement.entitlement.vend.addEntitlement(mockBankId1.value, resourceUser1.userId, ApiRole.CanCreateCustomer.toString)
val responsePost1 = makePostRequest(requestPost, write(customerPostJSON))
Then("We must get a 400")
Then("We should get a 400")
responsePost1.code must equal(400)
When("We add all required entitlement")
Entitlement.entitlement.vend.addEntitlement(mockBankId1.value, resourceUser1.userId, ApiRole.CanCreateUserCustomerLink.toString)
val responsePost2 = makePostRequest(requestPost, write(customerPostJSON))
println("responsePost2 " + responsePost2)
Then("We must get a 201")
Then("We should get a 201")
responsePost2.code must equal(201)
And("We must get the right information back")
And("We should get the right information back")
val infoPost = responsePost2.body.extract[CustomerJsonV210]
When("We make the request")
val requestGet = (v2_1Request / "banks" / mockBankId1.value / "customer").GET <@ (user1)
val responseGet = makeGetRequest(requestGet)
Then("We must get a 200")
Then("We should get a 200")
responseGet.code must equal(200)
And("We must get the right information back")
And("We should get the right information back")
val infoGet = responseGet.body.extract[CustomerJsonV210]
And("POST feedback and GET feedback must be the same")
And("POST feedback and GET feedback should be the same")
infoGet must equal(infoPost)
And("User is linked to 1 customer")
@ -83,10 +83,10 @@ class CustomerTest extends V210ServerSetup with DefaultUsers {
When("We try to make the second request with same customer number at same bank")
val secondResponsePost = makePostRequest(requestPost, write(customerPostJSON))
Then("We must get a 400")
Then("We should get a 400")
secondResponsePost.code must equal(400)
val error = for { JObject(o) <- secondResponsePost.body; JField("error", JString(error)) <- o } yield error
And("We must get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
error must contain (ErrorMessages.CustomerNumberAlreadyExists)
And("User is linked to 1 customer")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON.user_id).size must equal(1)
@ -95,7 +95,7 @@ class CustomerTest extends V210ServerSetup with DefaultUsers {
val customerPostJSON3 = createCustomerJson(mockCustomerNumber2)
val requestPost3 = (v2_1Request / "banks" / mockBankId1.value / "customers").POST <@ (user1)
val responsePost3 = makePostRequest(requestPost3, write(customerPostJSON3))
Then("We must get a 201")
Then("We should get a 201")
responsePost3.code must equal(201)
And("User is linked to 2 customers")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON3.user_id).size must equal(2)
@ -107,17 +107,17 @@ class CustomerTest extends V210ServerSetup with DefaultUsers {
val customerPostJSON4 = createCustomerJson(mockCustomerNumber1)
val requestPost4 = (v2_1Request / "banks" / mockBankId2.value / "customers").POST <@ (user1)
val responsePost4 = makePostRequest(requestPost4, write(customerPostJSON4))
Then("We must get a 201")
Then("We should get a 201")
responsePost4.code must equal(201)
And("User is linked to 3 customers")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON4.user_id).size must equal(3)
When("We try to make the second request with same customer number at same bank")
val secondResponsePost4 = makePostRequest(requestPost4, write(customerPostJSON4))
Then("We must get a 400")
Then("We should get a 400")
secondResponsePost4.code must equal(400)
val error4 = for { JObject(o) <- secondResponsePost4.body; JField("error", JString(error)) <- o } yield error
And("We must get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
And("We should get a message: " + ErrorMessages.CustomerNumberAlreadyExists)
error4 must contain (ErrorMessages.CustomerNumberAlreadyExists)
And("User is linked to 3 customers")
UserCustomerLink.userCustomerLink.vend.getUserCustomerLinkByUserId(customerPostJSON.user_id).size must equal(3)

View File

@ -22,10 +22,10 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers {
When("We make the request")
val requestGet = (v2_1Request / "roles").GET
val responseGet = makeGetRequest(requestGet)
Then("We must get a 400")
Then("We should get a 400")
responseGet.code must equal(400)
val error = for { JObject(o) <- responseGet.body; JField("error", JString(error)) <- o } yield error
And("We must get a message: " + ErrorMessages.UserNotLoggedIn)
And("We should get a message: " + ErrorMessages.UserNotLoggedIn)
error must contain (ErrorMessages.UserNotLoggedIn)
}
@ -34,7 +34,7 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers {
When("We make the request")
val requestGet = (v2_1Request / "roles").GET <@ (user1)
val responseGet = makeGetRequest(requestGet)
Then("We must get a 200")
Then("We should get a 200")
responseGet.code must equal(200)
}
}
@ -45,10 +45,10 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers {
When("We make the request")
val requestGet = (v2_1Request / "banks" / mockBankId1.value / "users" / resourceUser1.userId / "entitlements").GET
val responseGet = makeGetRequest(requestGet)
Then("We must get a 400")
Then("We should get a 400")
responseGet.code must equal(400)
val error = for { JObject(o) <- responseGet.body; JField("error", JString(error)) <- o } yield error
And("We must get a message: " + ErrorMessages.UserNotLoggedIn)
And("We should get a message: " + ErrorMessages.UserNotLoggedIn)
error must contain (ErrorMessages.UserNotLoggedIn)
}
@ -57,14 +57,14 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers {
When("We make the request")
val requestGet = (v2_1Request / "banks" / mockBankId1.value / "users" / resourceUser1.userId / "entitlements").GET <@ (user1)
val responseGet = makeGetRequest(requestGet)
Then("We must get a 400")
Then("We should get a 400")
responseGet.code must equal(400)
val error = for { JObject(o) <- responseGet.body; JField("error", JString(error)) <- o } yield error
val requiredEntitlements = CanGetEntitlementsForAnyUserAtOneBank ::
CanGetEntitlementsForAnyUserAtAnyBank::
Nil
val requiredEntitlementsTxt = requiredEntitlements.mkString(" or ")
And("We must get a message: " + s"$requiredEntitlementsTxt entitlements required")
And("We should get a message: " + s"$requiredEntitlementsTxt entitlements required")
error must contain (UserDoesNotHaveRole + requiredEntitlementsTxt)
}
@ -74,7 +74,7 @@ class EntitlementTests extends V210ServerSetup with DefaultUsers {
And("We make the request")
val requestGet = (v2_1Request / "banks" / mockBankId1.value / "users" / resourceUser1.userId / "entitlements").GET <@ (user1)
val responseGet = makeGetRequest(requestGet)
Then("We must get a 200")
Then("We should get a 200")
responseGet.code must equal(200)
}
}

View File

@ -92,7 +92,7 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
var answerJson = ChallengeAnswerJSON(id = challengeId, answer = "123456")
//prepare for counterparty and SEPA stuff
//For SEPA, otherAccountRoutingScheme must be 'IBAN'
//For SEPA, otherAccountRoutingScheme should be 'IBAN'
val counterPartySEPA = createCounterparty(bankId.value, accountId2.value, "IBAN", "IBAN", true, UUID.randomUUID.toString);
//For Counterpart local mapper, the mOtherAccountRoutingScheme='OBP' and mOtherBankRoutingScheme = 'OBP'
val counterPartyCounterparty = createCounterparty(bankId.value, accountId2.value, "IBAN", "OBP", true, UUID.randomUUID.toString);
@ -128,32 +128,32 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
def makeCreateTransReqRequestCounterparty: APIResponse = makePostRequest(createTransReqRequest, write(transactionRequestBodyCounterparty))
def checkAllCreateTransReqResBodyField(createTransactionRequestResponse: APIResponse, withChallenge: Boolean): Unit = {
Then("we must get a 201 created code")
Then("We should get a 201 created code")
(createTransactionRequestResponse.code) must equal(201)
Then("We must have a new transaction id in response body")
Then("We should have a new transaction id in response body")
transRequestId = (createTransactionRequestResponse.body \ "id").values.toString
transRequestId must not equal ("")
if (withChallenge) {
Then("We must have the INITIATED status in response body")
Then("We should have the INITIATED status in response body")
(createTransactionRequestResponse.body \ "status").values.toString must equal(code.transactionrequests.TransactionRequests.STATUS_INITIATED)
Then("The transaction_ids filed must be empty")
Then("The transaction_ids filed should be empty")
(createTransactionRequestResponse.body \ "transaction_ids").values.toString must equal("List()")
Then("Challenge must have body, this is the with challenge scenario")
Then("Challenge should have body, this is the with challenge scenario")
(createTransactionRequestResponse.body \ "challenge").children.size must not equal (0)
challengeId = (createTransactionRequestResponse.body \ "challenge" \ "id").values.toString
challengeId must not equal ("")
} else {
Then("We must have the COMPLETED status in response body")
Then("We should have the COMPLETED status in response body")
(createTransactionRequestResponse.body \ "status").values.toString must equal(code.transactionrequests.TransactionRequests.STATUS_COMPLETED)
Then("The transaction_ids filed must be not empty")
Then("The transaction_ids filed should be not empty")
(createTransactionRequestResponse.body \ "transaction_ids").values.toString must not equal ("List()")
Then("Challenge must be null, this is the no challenge scenario")
Then("Challenge should be null, this is the no challenge scenario")
(createTransactionRequestResponse.body \ "challenge").children.size must equal(0)
}
Then("We must have a new TransactionIds value")
Then("We should have a new TransactionIds value")
(createTransactionRequestResponse.body \ "transaction_ids").values.toString must not equal ("")
}
@ -167,29 +167,29 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
def makeGetTransReqRequest = makeGetRequest(getTransReqRequest)
def checkAllGetTransReqResBodyField(getTransactionRequestResponse: APIResponse, withChellenge: Boolean): Unit = {
Then("we must get a 200 created code")
Then("We should get a 200 created code")
(getTransactionRequestResponse.code) must equal(200)
And("We must have a new transaction id in response body")
And("We should have a new transaction id in response body")
(getTransactionRequestResponse.body \ "transaction_requests_with_charges" \ "id").values.toString must not equal ("")
if (withChellenge) {
And("We must have the INITIATED status in response body")
And("We should have the INITIATED status in response body")
(getTransactionRequestResponse.body \ "transaction_requests_with_charges" \ "status").values.toString must equal(code.transactionrequests.TransactionRequests.STATUS_INITIATED)
And("Challenge must be not null, this is the no challenge scenario")
And("Challenge should be not null, this is the no challenge scenario")
(getTransactionRequestResponse.body \ "transaction_requests_with_charges" \ "challenge").children.size must not equal (0)
And("We must have be null value for TransactionIds")
And("We should have be null value for TransactionIds")
(getTransactionRequestResponse.body \ "transaction_requests_with_charges" \ "transaction_ids").values.toString must equal("List()")
} else {
And("We must have the COMPLETED status in response body")
And("We should have the COMPLETED status in response body")
(getTransactionRequestResponse.body \ "transaction_requests_with_charges" \ "status").values.toString must equal(code.transactionrequests.TransactionRequests.STATUS_COMPLETED)
And("Challenge must be null, this is the no challenge scenario")
And("Challenge should be null, this is the no challenge scenario")
(getTransactionRequestResponse.body \ "transaction_requests_with_charges" \ "challenge").children.size must equal(0)
And("We must have a new TransactionIds value")
And("We should have a new TransactionIds value")
(getTransactionRequestResponse.body \ "transaction_requests_with_charges" \ "transaction_ids").values.toString must not equal ("")
}
@ -203,15 +203,15 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
def makeGetTransRequest = makeGetRequest(getTransactionRequest)
def checkAllGetTransResBodyField(getTransactionResponse: APIResponse, withChellenge: Boolean): Unit = {
Then("we must get a 200 created code")
Then("We should get a 200 created code")
(getTransactionResponse.code) must equal(200)
And("we must get the body size is one")
And("We should get the body size is one")
(getTransactionResponse.body.children.size) must equal(1)
if (withChellenge) {
And("we must get None, there is no transaction yet")
And("We should get None, there is no transaction yet")
((getTransactionResponse.body \ "transactions"\"details").toString contains (discription)) must not equal(true)
} else {
And("we must get the body discription value is as we set before")
And("We should get the body discription value is as we set before")
((getTransactionResponse.body \ "transactions"\"details").toString contains (discription)) must equal(true)
}
}
@ -232,33 +232,33 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
if (finishedTranscation ) {
if(transactionRequestTypeInput.equals("FREE_FORM")){
Then("FREE_FORM just transfer money to itself, the money must be the same as before ")
Then("FREE_FORM just transfer money to itself, the money should be the same as before ")
fromAccountBalance must equal((beforeFromBalance))
And("there must now be 2 new transactions in the database")
And("there should now be 2 new transactions in the database")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore+2)
} else if(transactionRequestTypeInput.equals("SANDBOX_TAN")){
Then("check that the balances have been properly decreased/increased (since we handle that logic for sandbox accounts at least) ")
fromAccountBalance must equal((beforeFromBalance - amt))
And("the account receiving the payment must have a new balance plus the amount paid")
And("the account receiving the payment should have a new balance plus the amount paid")
toAccountBalance must equal(beforeToBalance + convertedAmount)
And("there must now be 2 new transactions in the database (one for the sender, one for the receiver")
And("there should now be 2 new transactions in the database (one for the sender, one for the receiver")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore + 2)
} else{
Then("check that the balances have been properly decreased/increased (since we handle that logic for sandbox accounts at least) ")
fromAccountBalance must equal((beforeFromBalance - amt))
And("the account receiving the payment must have a new balance plus the amount paid")
And("the account receiving the payment should have a new balance plus the amount paid")
//TODO for now, sepa, counterparty can not clear the toAccount and toAccount Currency so just test the fromAccount
//toAccountBalance must equal(beforeToBalance + convertedAmount)
And("there must now be 2 new transactions in the database (one for the sender, one for the receiver")
And("there should now be 2 new transactions in the database (one for the sender, one for the receiver")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore + 2)
}
} else {
Then("No transaction, it must be the same as before ")
Then("No transaction, it should be the same as before ")
fromAccountBalance must equal((beforeFromBalance))
And("No transaction, it must be the same as before ")
And("No transaction, it should be the same as before ")
toAccountBalance must equal(beforeToBalance)
And("No transaction, it must be the same as before ")
And("No transaction, it should be the same as before ")
transactionCount(fromAccount, toAccount) must equal(totalTransactionsBefore)
}
}
@ -273,16 +273,16 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
def makeAnswerRequest = makePostRequest(answerRequest, write(answerJson))
def checkAllAnsTransReqBodyFields(ansTransReqResponse: APIResponse, withChellenge: Boolean): Unit = {
Then("we must get a 202 created code")
Then("We should get a 202 created code")
(ansTransReqResponse.code) must equal(202)
And("we must get the body sie is 10, the response Json body have 10 Attributes")
And("We should get the body sie is 10, the response Json body have 10 Attributes")
(ansTransReqResponse.body.children.size) must equal(10)
Then("We must have a new TransactionIds value")
Then("We should have a new TransactionIds value")
(ansTransReqResponse.body \ "transaction_ids").values.toString must not equal ("")
Then("We must have the COMPLETED status in response body")
Then("We should have the COMPLETED status in response body")
(ansTransReqResponse.body \ "status").values.toString must equal(code.transactionrequests.TransactionRequests.STATUS_COMPLETED)
}
}
@ -303,10 +303,10 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
var response = makePostRequest(request, write(helper.transactionRequestBody))
Then("we must get a 400 created code")
Then("We should get a 400 created code")
response.code must equal(400)
Then("We must have the error message")
Then("We should have the error message")
val error = for {JObject(o) <- response.body; JField("error", JString(error)) <- o} yield error
error must contain(ErrorMessages.UserNotLoggedIn)
@ -325,10 +325,10 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
"owner" / "transaction-request-types" / helper.transactionRequestType / "transaction-requests").POST <@ (user2)
val response = makePostRequest(request, write(helper.transactionRequestBody))
Then("we must get a 400 created code")
Then("We should get a 400 created code")
response.code must equal(400)
Then("We must have the error: " + ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
Then("We should have the error: " + ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
val error: String = (response.body \ "error").values.toString
error must equal(ErrorMessages.InsufficientAuthorisationToCreateTransactionRequest)
}
@ -349,7 +349,7 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
"owner" / "transaction-request-types" / helper.transactionRequestType / "transaction-requests").POST <@ (user3)
var response = makePostRequest(request, write(helper.transactionRequestBody))
Then("we must get a 201 created code")
Then("We should get a 201 created code")
response.code must equal(201)
}
@ -363,7 +363,7 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
val helper = defaultSetup()
Then("We grant the CanCreateAnyTransactionRequest role to user3")
addEntitlement(helper.bankId.value, authuser3.userId, CanCreateAnyTransactionRequest.toString)
addEntitlement(helper.bankId.value, resourceUser3.userId, CanCreateAnyTransactionRequest.toString)
Then("We call createTransactionRequest with invalid transactionRequestType - V210")
val invalidTransactionRequestType = "invalidTransactionRequestType"
@ -371,10 +371,10 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
"owner" / "transaction-request-types" / invalidTransactionRequestType / "transaction-requests").POST <@ (user3)
var response = makePostRequest(request, write(helper.transactionRequestBody))
Then("we must get a 400 created code")
Then("We should get a 400 created code")
response.code must equal(400)
Then("We must have the error message")
Then("We should have the error message")
val error: List[String] = for {JObject(o) <- response.body; JField("error", JString(error)) <- o} yield error
error(0) must include(ErrorMessages.InvalidTransactionRequestType)
}
@ -1046,13 +1046,13 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
}
@ -1089,13 +1089,13 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(toAccount.bankId.value, toAccount.accountId.value, amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for each account must remain unchanged")
And("the number of transactions for each account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount, toAccount))
And("the balances of each account must remain unchanged")
And("the balances of each account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
beforeToBalance must equal(getToAccount.balance)
}
@ -1124,13 +1124,13 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
val payJson = MakePaymentJson(bankId.value, "ACCOUNTTHATDOESNOTEXIST232321321", amt.toString)
val postResult = postTransaction(fromAccount.bankId.value, fromAccount.accountId.value, view, payJson, user1)
Then("we must get a 400")
Then("We should get a 400")
postResult.code must equal(400)
And("the number of transactions for the sender's account must remain unchanged")
And("the number of transactions for the sender's account should remain unchanged")
totalTransactionsBefore must equal(transactionCount(fromAccount))
And("the balance of the sender's account must remain unchanged")
And("the balance of the sender's account should remain unchanged")
beforeFromBalance must equal(getFromAccount.balance)
}
*/

View File

@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You must have received a copy of the GNU Affero General Public License
you should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Email: contact@tesobe.com
@ -134,7 +134,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
Given("We will not use an access token")
When("the request is sent")
val reply = getAPIInfo
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
reply.code must equal (200)
val apiInfo = reply.body.extract[APIInfoJSON]
apiInfo.version must equal ("2.2.0")
@ -147,7 +147,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
Given("We will not use an access token")
When("the request is sent")
val reply = getBanksInfo
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
reply.code must equal (200)
val banksInfo = reply.body.extract[BanksJSON]
banksInfo.banks.foreach(b => {
@ -161,7 +161,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
Given("We will not use an access token")
When("the request is sent")
val reply = getBankInfo(randomBank)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
reply.code must equal (200)
val bankInfo = reply.body.extract[code.api.v1_2_1.BankJSON]
bankInfo.id.nonEmpty must equal (true)
@ -171,9 +171,9 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
Given("We will not use an access token and request a random bankId")
When("the request is sent")
val reply = getBankInfo(randomString(5))
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
}
@ -215,7 +215,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
val bankAccount : code.api.v1_2.AccountJSON = randomPrivateAccount(bankId)
When("the request is sent")
val reply = getAccountViews(bankId, bankAccount.id, user1)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
reply.code must equal (200)
reply.body.extract[ViewsJSONV220]
}
@ -226,9 +226,9 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
val bankAccount : code.api.v1_2.AccountJSON = randomPrivateAccount(bankId)
When("the request is sent")
val reply = getAccountViews(bankId, bankAccount.id, None)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
@ -238,9 +238,9 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
val bankAccount : code.api.v1_2.AccountJSON = randomPrivateAccount(bankId)
When("the request is sent")
val reply = getAccountViews(bankId, bankAccount.id, user3)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
}
@ -253,10 +253,10 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
val view = randomView(true, "")
When("the request is sent")
val reply = postView(bankId, bankAccount.id, view, user1)
Then("we must get a 201 code")
Then("We should get a 201 code")
reply.code must equal (201)
reply.body.extract[ViewJSONV220]
And("we must get a new view")
And("We should get a new view")
val viewsAfter = getAccountViews(bankId, bankAccount.id, user1).body.extract[ViewsJSONV220].views
viewsBefore.size must equal (viewsAfter.size -1)
}
@ -268,9 +268,9 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
val view = randomView(true, "")
When("the request is sent")
val reply = postView(bankId, bankAccount.id, view, None)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
@ -281,9 +281,9 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
val view = randomView(true, "")
When("the request is sent")
val reply = postView(bankId, bankAccount.id, view, user3)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
@ -293,9 +293,9 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
val view = randomView(true, "")
When("the request is sent")
val reply = postView(bankId, randomString(3), view, user1)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
@ -307,9 +307,9 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
postView(bankId, bankAccount.id, view, user1)
When("the request is sent")
val reply = postView(bankId, bankAccount.id, view, user1)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
}
@ -359,7 +359,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
When("We use a valid access token and valid put json")
val reply = putView(bankId, bankAccount.id, createdView.id, viewUpdateJson(createdView), user1)
Then("We must get back the updated view")
Then("We should get back the updated view")
reply.code must equal (200)
val updatedView = reply.body.extract[ViewJSONV220]
updatedView.can_see_images must equal(true)
@ -384,7 +384,7 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
When("we try to update that view")
val reply = putView(bankId, bankAccount.id, nonExistantViewId, someViewUpdateJson(), user1)
Then("We must get a 404")
Then("We should get a 404")
reply.code must equal(404)
}
@ -399,10 +399,10 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
When("we don't use an access token")
val reply = putView(bankId, bankAccount.id, createdView.id, viewUpdateJson(createdView), None)
Then("we must get a 400")
Then("We should get a 400")
reply.code must equal(400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
@ -417,10 +417,10 @@ class API2_2_0Test extends User1AllPrivileges with V220ServerSetup with DefaultU
When("we try to update a view without having sufficient privileges to do so")
val reply = putView(bankId, bankAccount.id, createdView.id, viewUpdateJson(createdView), user3)
Then("we must get a 400")
Then("We should get a 400")
reply.code must equal(400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
}

View File

@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You must have received a copy of the GNU Affero General Public License
you should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Email: contact@tesobe.com
@ -99,7 +99,7 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
Given("We will not use an access token")
When("the request is sent")
val reply = getAPIInfo
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
reply.code must equal (200)
val apiInfo = reply.body.extract[APIInfoJSON]
apiInfo.version must equal ("3.0.0")
@ -111,7 +111,7 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
Given("We will not use an access token")
When("the request is sent")
val reply = getBanksInfo
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
reply.code must equal (200)
val banksInfo = reply.body.extract[BanksJSON]
banksInfo.banks.foreach(b => {
@ -125,7 +125,7 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
Given("We will not use an access token")
When("the request is sent")
val reply = getBankInfo(randomBankId)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
reply.code must equal (200)
val bankInfo = reply.body.extract[code.api.v1_2_1.BankJSON]
bankInfo.id.nonEmpty must equal (true)
@ -135,9 +135,9 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
Given("We will not use an access token and request a random bankId")
When("the request is sent")
val reply = getBankInfo(randomString(5))
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
}
@ -149,7 +149,7 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
val bankAccount : code.api.v1_2.AccountJSON = randomPrivateAccount(bankId)
When("the request is sent")
val reply = getAccountViews(bankId, bankAccount.id, user1)
Then("we must get a 200 ok code")
Then("We should get a 200 ok code")
reply.code must equal (200)
reply.body.extract[ViewsJsonV300]
}
@ -160,9 +160,9 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
val bankAccount : code.api.v1_2.AccountJSON = randomPrivateAccount(bankId)
When("the request is sent")
val reply = getAccountViews(bankId, bankAccount.id, None)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
@ -172,9 +172,9 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
val bankAccount : code.api.v1_2.AccountJSON = randomPrivateAccount(bankId)
When("the request is sent")
val reply = getAccountViews(bankId, bankAccount.id, user3)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
}
@ -187,10 +187,10 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
When("the request is sent")
val reply = postView(bankId, bankAccount.id, view, user1)
Then("we must get a 201 code")
Then("We should get a 201 code")
reply.code must equal (201)
reply.body.extract[ViewJSONV220]
And("we must get a new view")
And("We should get a new view")
val viewsAfter = getAccountViews(bankId, bankAccount.id, user1).body.extract[ViewsJsonV300].views
viewsBefore.size must equal (viewsAfter.size -1)
}
@ -201,9 +201,9 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
val bankAccount : code.api.v1_2.AccountJSON = randomPrivateAccount(bankId)
When("the request is sent")
val reply = postView(bankId, bankAccount.id, view, None)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
@ -213,9 +213,9 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
val bankAccount : code.api.v1_2.AccountJSON = randomPrivateAccount(bankId)
When("the request is sent")
val reply = postView(bankId, bankAccount.id, view, user3)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
@ -224,9 +224,9 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
val bankId = randomBankId
When("the request is sent")
val reply = postView(bankId, randomString(3), view, user1)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
@ -237,9 +237,9 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
postView(bankId, bankAccount.id, view, user1)
When("the request is sent")
val reply = postView(bankId, bankAccount.id, view, user1)
Then("we must get a 400 code")
Then("We should get a 400 code")
reply.code must equal (400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
}
@ -288,7 +288,7 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
When("We use a valid access token and valid put json")
val reply = putView(bankId, bankAccount.id, createdView.id, viewUpdateJson(createdView), user1)
Then("We must get back the updated view")
Then("We should get back the updated view")
reply.code must equal (200)
val updatedView = reply.body.extract[ViewJsonV300]
updatedView.can_see_images must equal(true)
@ -313,7 +313,7 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
When("we try to update that view")
val reply = putView(bankId, bankAccount.id, nonExistantViewId, someViewUpdateJson(), user1)
Then("We must get a 404")
Then("We should get a 404")
reply.code must equal(404)
}
@ -327,10 +327,10 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
When("we don't use an access token")
val reply = putView(bankId, bankAccount.id, createdView.id, viewUpdateJson(createdView), None)
Then("we must get a 400")
Then("We should get a 400")
reply.code must equal(400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
@ -344,10 +344,10 @@ class API3_0_0Test extends User1AllPrivileges with V300ServerSetup with DefaultU
When("we try to update a view without having sufficient privileges to do so")
val reply = putView(bankId, bankAccount.id, createdView.id, viewUpdateJson(createdView), user3)
Then("we must get a 400")
Then("We should get a 400")
reply.code must equal(400)
And("we must get an error message")
And("We should get an error message")
reply.body.extract[ErrorMessage].error.nonEmpty must equal (true)
}
}

View File

@ -21,14 +21,14 @@ class AccountTest extends V300ServerSetup with DefaultUsers {
val responsePut = makePutRequest(requestPut, write(accountPutJSON))
And("We should get a 200")
responsePut.code should equal(200)
responsePut.code must equal(200)
When("We make the anonymous access request")
val requestGet = (v2_0Request / "accounts").GET
val responseGet = makeGetRequest(requestGet)
Then("We should get a 200")
responseGet.code should equal(200)
responseGet.code must equal(200)
val isPublic: List[Boolean] =
for {
@ -38,14 +38,14 @@ class AccountTest extends V300ServerSetup with DefaultUsers {
isPublic
}
And("All received accounts have to be public")
isPublic.forall(_ == true) should equal(true)
isPublic.forall(_ == true) must equal(true)
When("We make the authenticated access request")
val requestGetAll = (v2_0Request / "accounts").GET <@ (user1)
val responseGetAll = makeGetRequest(requestGetAll)
Then("We should get a 200")
responseGetAll.code should equal(200)
responseGetAll.code must equal(200)
val isPublicAll =
for {
@ -56,7 +56,7 @@ class AccountTest extends V300ServerSetup with DefaultUsers {
isPublic
}
And("The new created account has to be private")
isPublicAll.forall(_ == false) should equal(true)
isPublicAll.forall(_ == false) must equal(true)
}
scenario("We create an account and get accounts as anonymous and then as authenticated user - allAccountsAtOneBank") {
@ -69,14 +69,14 @@ class AccountTest extends V300ServerSetup with DefaultUsers {
val responsePut = makePutRequest(requestPut, write(accountPutJSON))
And("We should get a 200")
responsePut.code should equal(200)
responsePut.code must equal(200)
When("We make the anonymous access request")
val requestGet = (v2_0Request / "banks" / testBank.value / "accounts").GET
val responseGet = makeGetRequest(requestGet)
Then("We should get a 200")
responseGet.code should equal(200)
responseGet.code must equal(200)
val isPublic: List[Boolean] =
for {
@ -86,14 +86,14 @@ class AccountTest extends V300ServerSetup with DefaultUsers {
isPublic
}
And("All received accounts have to be public")
isPublic.forall(_ == true) should equal(true)
isPublic.forall(_ == true) must equal(true)
When("We make the authenticated access request")
val requestGetAll = (v2_0Request / "banks" / testBank.value / "accounts").GET <@ (user1)
val responseGetAll = makeGetRequest(requestGetAll)
Then("We should get a 200")
responseGetAll.code should equal(200)
responseGetAll.code must equal(200)
val isPublicAll =
for {
@ -104,7 +104,7 @@ class AccountTest extends V300ServerSetup with DefaultUsers {
isPublic
}
And("The new created account has to be private")
isPublicAll.forall(_ == false) should equal(true)
isPublicAll.forall(_ == false) must equal(true)
}
scenario("We create an account, but with wrong format of account_id ") {
@ -118,14 +118,14 @@ class AccountTest extends V300ServerSetup with DefaultUsers {
val responsePut = makePutRequest(requestPut, write(accountPutJSON))
And("We should get a 400")
responsePut.code should equal(400)
responsePut.code must equal(400)
And("We should have the error massage")
val error: String = (responsePut.body \ "error") match {
case JString(i) => i
case _ => ""
}
Then("We should have the error: " + ErrorMessages.InvalidAccountIdFormat)
error should equal(ErrorMessages.InvalidAccountIdFormat)
error must equal(ErrorMessages.InvalidAccountIdFormat)
}
}

View File

@ -96,14 +96,14 @@ class MappedAtmsProviderTest extends ServerSetup {
When("we try to get the atms for that bank")
val atmsOpt: Option[List[Atm]] = MappedAtmsProvider.getAtms(BankId(fixture.bankIdX))
Then("We must get a atms list")
Then("We should get a atms list")
atmsOpt.isDefined must equal (true)
val atms = atmsOpt.get
And("it must contain two atms")
atms.size must equal(2)
And("they must be the licensed ones")
And("they should be the licensed ones")
atms must equal (expectedAtms)
}
@ -118,7 +118,7 @@ class MappedAtmsProviderTest extends ServerSetup {
When("we try to get the atms for that bank")
val atmDataOpt = MappedAtmsProvider.getAtms(BankId(fixture.bankIdY))
Then("we must get back an empty list")
Then("We should get back an empty list")
atmDataOpt.isDefined must equal(true)
val atms = atmDataOpt.get

View File

@ -44,7 +44,7 @@ class BankAccountCreationListenerTest extends ServerSetup with DefaultConnectorT
val accountNumber = "123456"
def thenCheckAccountCreated(user: User) = {
Then("An account with the proper parameters must be created")
Then("An account with the proper parameters should be created")
val userAccounts = Views.views.vend.getAllAccountsUserCanSee(Full(user))
userAccounts.size must equal(1)
val createdAccount = userAccounts(0)
@ -76,7 +76,7 @@ class BankAccountCreationListenerTest extends ServerSetup with DefaultConnectorT
When("We create a bank account")
//using expectedBankId as the bank name must be okay as the behaviour must be to slugify the bank name to get the id
//using expectedBankId as the bank name should be okay as the behaviour should be to slugify the bank name to get the id
//what to do if this slugification results in an id collision has not been determined yet
val msgContent = CreateBankAccount(userId, userProvider, accountNumber, bankIdentifier, expectedBankId)
@ -87,7 +87,7 @@ class BankAccountCreationListenerTest extends ServerSetup with DefaultConnectorT
thenCheckAccountCreated(user)
And("A bank must be created")
And("A bank should be created")
val createdBankBox = Connector.connector.vend.getBank(BankId(expectedBankId))
createdBankBox.isDefined must equal(true)
val createdBank = createdBankBox match {

View File

@ -39,7 +39,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
//
// val newBank1 = createBank(id)
//
// Then("A bank must now exist, with the correct parameters")
// Then("A bank should now exist, with the correct parameters")
//
// val allBanks = Connector.connector.vend.getBanks
// allBanks.size must equal(1)
@ -67,14 +67,14 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
"","", "" //added field in V220
)
Then("A bank must now exist, with the correct parameters")
Then("A bank should now exist, with the correct parameters")
val allBanks = Connector.connector.vend.getBanks
allBanks.size must equal(1)
val newBank = allBanks(0)
newBank.fullName must equal(bankName)
newBank.nationalIdentifier must equal(bankNationalIdentifier)
And("An account must now exist, with the correct parameters")
And("An account should now exist, with the correct parameters")
val foundAccountBox = Connector.connector.vend.getBankAccount(newBank.bankId, returnedAccount.accountId)
foundAccountBox.isDefined must equal(true)
val foundAccount = foundAccountBox match {
@ -104,13 +104,13 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
"","", "" //added field in V220
)
Then("No new bank must be created")
Then("No new bank should be created")
val allBanksAfter = Connector.connector.vend.getBanks
allBanksAfter.size must equal(1)
allBanksAfter(0).fullName must equal(existingBank.fullName)
allBanksAfter(0).nationalIdentifier must equal(existingBank.nationalIdentifier)
And("An account must now exist, with the correct parameters")
And("An account should now exist, with the correct parameters")
val foundAccountBox = Connector.connector.vend.getBankAccount(existingBank.bankId, returnedAccount.accountId)
foundAccountBox.isDefined must equal(true)
val foundAccount = foundAccountBox match {
@ -160,7 +160,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
Connector.connector.vend.createSandboxBankAccount(bankId, accountId, defaultAccountNumber, accountType, accountLabel, currency, initialBalance, accountHolderName,
"","","" ) //added field in V220
Then("An account with the proper parameters must be created")
Then("An account with the proper parameters should be created")
val createdAccBox = Connector.connector.vend.getBankAccount(bankId, accountId)
createdAccBox.isDefined must be(true)
val createdAcc = createdAccBox match {
@ -184,7 +184,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
Connector.connector.vend.createSandboxBankAccount(bankId, accountId, accountType, accountLabel, currency, initialBalance, accountHolderName,
"","", "")//added field in V220
Then("An account with the proper parameters must be created")
Then("An account with the proper parameters should be created")
val createdAccBox = Connector.connector.vend.getBankAccount(bankId, accountId)
createdAccBox.isDefined must be(true)
val createdAcc = createdAccBox match {
@ -197,7 +197,7 @@ class BankAccountCreationTest extends ServerSetup with DefaultUsers with Default
createdAcc.currency must equal(currency)
createdAcc.accountHolder must equal(accountHolderName)
//Account number must be autogenerated
//Account number should be autogenerated
createdAcc.number.nonEmpty must equal(true)
}

View File

@ -96,14 +96,14 @@ class MappedBranchesProviderTest extends ServerSetup {
When("we try to get the branches for that bank")
val branchesOpt: Option[List[Branch]] = MappedBranchesProvider.getBranches(BankId(fixture.bankIdX))
Then("We must get a branches list")
Then("We should get a branches list")
branchesOpt.isDefined must equal (true)
val branches = branchesOpt.get
And("it must contain two branches")
branches.size must equal(2)
And("they must be the licensed ones")
And("they should be the licensed ones")
branches must equal (expectedBranches)
}
@ -118,7 +118,7 @@ class MappedBranchesProviderTest extends ServerSetup {
When("we try to get the branches for that bank")
val branchDataOpt = MappedBranchesProvider.getBranches(BankId(fixture.bankIdY))
Then("we must get back an empty list")
Then("We should get back an empty list")
branchDataOpt.isDefined must equal(true)
val branches = branchDataOpt.get

View File

@ -120,7 +120,7 @@ class MappedCrmEventProviderTest extends ServerSetup with DefaultUsers {
Then("We do")
foundOpt.isDefined must equal(true)
And("There must be two")
And("There should be two")
val foundThings = foundOpt.get
foundThings.size must equal(2)

View File

@ -45,7 +45,7 @@ class MappedCustomerProviderTest extends V140ServerSetup with DefaultUsers {
And("Try to create a customer")
val requestPost = (v1_4Request / "banks" / bankId.value / "customer").POST <@ (user)
val responsePost = makePostRequest(requestPost, write(customerPostJSON1))
Then("We must get a 200")
Then("We should get a 200")
responsePost.code must equal(200)
val customer: Box[Customer] = Customer.customerProvider.vend.getCustomerByCustomerNumber(nmb, bankId)
@ -92,7 +92,7 @@ class MappedCustomerProviderTest extends V140ServerSetup with DefaultUsers {
When("We try to get the user for a bank with that customer number")
val found = Customer.customerProvider.vend.getUser(BankId("some-bank"), customerNumber)
Then("We must not find a user")
Then("We should not find a user")
found.isDefined must equal(false)
}
@ -104,13 +104,13 @@ class MappedCustomerProviderTest extends V140ServerSetup with DefaultUsers {
When("We try to get the user for the same bank")
val user = Customer.customerProvider.vend.getUser(BankId(mockBankId2.value), customerNumber)
Then("We must find a user")
Then("We should find a user")
user.isDefined must equal(true)
When("We try to get the user for a different bank")
val found = Customer.customerProvider.vend.getUser(BankId(mockBankId2.value + "asdsad"), customerNumber)
Then("We must not find a user")
Then("We should not find a user")
found.isDefined must equal(false)
}
@ -130,7 +130,7 @@ class MappedCustomerProviderTest extends V140ServerSetup with DefaultUsers {
When("We try to get the user for that bank")
val found = Customer.customerProvider.vend.getUser(mockBankId2, customerNumber)
Then("We must not find a user")
Then("We should not find a user")
found.isDefined must equal(true)
}

View File

@ -157,10 +157,10 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
When("We try to import transactions without using a secret key")
val response = addTransactions(f.testJson, None)
Then("We must get a 400")
Then("We should get a 400")
response.code must equal(400)
And("No transactions must be added")
And("No transactions should be added")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId) match {
case Full(ts) => ts
}
@ -179,10 +179,10 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
When("We try to import transactions with the incorrect secret key")
val response = addTransactions(f.testJson, Some(secretKeyValue + "asdsadsad"))
Then("We must get a 401")
Then("We should get a 401")
response.code must equal(401)
And("No transactions must be added")
And("No transactions should be added")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId) match {
case Full(ts) => ts
}
@ -201,16 +201,16 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
When("We try to import transactions with the correct secret key")
val response = addTransactions(f.testJson, Some(secretKeyValue))
Then("We must get a 200") //implementation returns 200 and not 201, so we'll leave it like that
Then("We should get a 200") //implementation returns 200 and not 201, so we'll leave it like that
response.code must equal(200)
And("Transactions must be added")
And("Transactions should be added")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId) match {
case Full(ts) => ts
}
tsAfter.size must equal(2)
And("The transactions must have the correct parameters")
And("The transactions should have the correct parameters")
val t1 = tsAfter(0)
checkOkay(t1, f.t1Value, f.t1NewBalance, f.t1StartDate, f.t1EndDate, f.dummyLabel)
@ -218,13 +218,13 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
checkOkay(t2, f.t2Value, f.t2NewBalance, f.t2StartDate, f.t2EndDate, f.dummyLabel)
And("The account must have its balance set to the 'new_balance' value of the most recently completed transaction")
And("The account should have its balance set to the 'new_balance' value of the most recently completed transaction")
val account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId) match {
case Full(a) => a
}
account.balance.toString must equal(f.t2NewBalance) //t2 has a later completed date than t1
And("The account must have accountLastUpdate set to the current time")
And("The account should have accountLastUpdate set to the current time")
val dt = (now.getTime - account.lastUpdate.getTime)
dt < 1000 must equal(true)
@ -247,25 +247,25 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
//it must NOT complain about identical "new balances" as sometimes this value is unknown, or computed on a daily basis
//and hence all transactions for the day will have the same end balance
Then("We must get a 200") //implementation returns 200 and not 201, so we'll leave it like that
Then("We should get a 200") //implementation returns 200 and not 201, so we'll leave it like that
response.code must equal(200)
And("Transactions must be added")
And("Transactions should be added")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId) match {
case Full(ts) => ts
}
tsAfter.size must equal(2)
And("The transactions must have the correct parameters")
And("The transactions should have the correct parameters")
tsAfter.foreach(checkTransactionOkay)
And("The account must have its balance set to the 'new_balance' value of the most recently completed transaction")
And("The account should have its balance set to the 'new_balance' value of the most recently completed transaction")
val account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId) match {
case Full(a) => a
}
account.balance.toString must equal(f.t1NewBalance)
And("The account must have accountLastUpdate set to the current time")
And("The account should have accountLastUpdate set to the current time")
val dt = (now.getTime - account.lastUpdate.getTime)
dt < 1000 must equal(true)
}
@ -295,7 +295,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
When("We try to add those transactions again")
val response = addTransactions(importJson, Some(secretKeyValue))
Then("We must get a 200") //implementation returns 200 and not 201, so we'll leave it like that
Then("We should get a 200") //implementation returns 200 and not 201, so we'll leave it like that
response.code must equal(200)
And("There must still only be two transactions")
@ -306,7 +306,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
tsAfter.foreach(checkTransactionOkay)
And("The account must have accountLastUpdate set to the current time (different from first insertion)")
And("The account should have accountLastUpdate set to the current time (different from first insertion)")
account = Connector.connector.vend.getBankAccount(f.account.bankId, f.account.accountId) match {
case Full(a) => a
}
@ -335,10 +335,10 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
When("We try to add 5 copies of the transaction")
val response = addTransactions(secondImportJson, Some(secretKeyValue))
Then("We must get a 200") //implementation returns 200 and not 201, so we'll leave it like that
Then("We should get a 200") //implementation returns 200 and not 201, so we'll leave it like that
response.code must equal(200)
And("There must now be 5 transactions")
And("There should now be 5 transactions")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId) match {
case Full(ts) => ts
}
@ -372,7 +372,7 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
When("We add these same 'identical' transactions to a different account")
addTransactions(t1F2ImportJson, Some(secretKeyValue))
Then("There must be two transactions for each account")
Then("There should be two transactions for each account")
val f1TsAfter = Connector.connector.vend.getTransactions(f1.account.bankId, f1.account.accountId) match {
case Full(ts) => ts
}
@ -398,10 +398,10 @@ class ImporterTest extends ServerSetup with MdcLoggable with DefaultConnectorTes
When("We try to import transactions with the correct secret key")
val response = addTransactions("""{"some_gibberish" : "json"}""", Some(secretKeyValue))
Then("We must get a 500") //implementation returns 500, so we'll leave it like that
Then("We should get a 500") //implementation returns 500, so we'll leave it like that
response.code must equal(200)
And("No transactions must be added")
And("No transactions should be added")
val tsAfter = Connector.connector.vend.getTransactions(f.account.bankId, f.account.accountId) match {
case Full(ts) => ts
}

View File

@ -85,14 +85,14 @@ class MappedProductsProviderTest extends ServerSetup {
When("we try to get the Products for that bank")
val productsOpt: Option[List[Product]] = MappedProductsProvider.getProducts(BankId(fixture.bankIdX))
Then("We must get a Products list")
Then("We should get a Products list")
productsOpt.isDefined must equal (true)
val products = productsOpt.get
And("it must contain two Products")
products.size must equal(2)
And("they must be the licensed ones")
And("they should be the licensed ones")
products must equal (expectedProducts)
}
@ -107,7 +107,7 @@ class MappedProductsProviderTest extends ServerSetup {
When("we try to get the Products for that bank")
val productsOpt = MappedProductsProvider.getProducts(BankId(fixture.bankIdY))
Then("we must get back an empty list")
Then("We should get back an empty list")
productsOpt.isDefined must equal(true)
val products = productsOpt.get

View File

@ -14,7 +14,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You must have received a copy of the GNU Affero General Public License
you should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Email: contact@tesobe.com

View File

@ -14,7 +14,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You must have received a copy of the GNU Affero General Public License
you should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Email: contact@tesobe.com

View File

@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You must have received a copy of the GNU Affero General Public License
you should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Email: contact@tesobe.com
@ -310,12 +310,12 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
val owner = Users.users.vend.getUserByProviderId(defaultProvider, foundAccount.owners.toList.head.name) match {
case Full(o) => o
}
//there must be an owner view
//there should be an owner view
val views = Views.views.vend.permittedViews(owner, BankAccountUID(foundAccount.bankId, foundAccount.accountId))
val ownerView = views.find(v => v.viewId.value == "owner")
ownerView.isDefined must equal(true)
//and the owners must have access to it
//and the owners should have access to it
Views.views.vend.getOwners(ownerView.get).map(_.idGivenByProvider) must equal(account.owners.toSet)
}
@ -623,7 +623,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
response.code must equal(403)
//nothing must be created
//nothing should be created
Connector.connector.vend.getBanks must equal(Nil)
}
@ -635,7 +635,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
response.code must equal(403)
//nothing must be created
//nothing should be created
Connector.connector.vend.getBanks must equal(Nil)
}
@ -655,13 +655,13 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
getResponse(bankWithoutId).code must equal(FAILED)
//no banks must have been created
//no banks should have been created
Connector.connector.vend.getBanks.size must equal(0)
val bankWithEmptyId = addIdField(bankWithoutId, "")
getResponse(bankWithEmptyId).code must equal(FAILED)
//no banks must have been created
//no banks should have been created
Connector.connector.vend.getBanks.size must equal(0)
//Check that the same json becomes valid when a non-empty id is added
@ -727,10 +727,10 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
val otherBank = bank2
//when we try to add bank1 and another valid bank it must now fail
//when we try to add bank1 and another valid bank it should now fail
getResponse(List(bank1Json, Extraction.decompose(bank2))).code must equal(FAILED)
//and the other bank must not have been created
//and the other bank should not have been created
Connector.connector.vend.getBank(BankId(otherBank.id)).isDefined must equal(false)
}
@ -749,7 +749,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
val userWithEmptyEmail = addEmailField(userWithoutEmail, "")
//there must be no user with a blank id before we try to add one
//there should be no user with a blank id before we try to add one
Users.users.vend.getUserByProviderId(defaultProvider, "") match {
case ParamFailure(_,x,y,_) => x must equal(Empty) // Returned result in case when akka is used
case Empty => Empty must equal(Empty)
@ -783,7 +783,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
getResponse(userWithValidEmail).code must equal(SUCCESS)
//a user must now have been created
//a user should now have been created
val createdUser = Users.users.vend.getUserByProviderId(defaultProvider, user1.user_name) match {
case Full(c) => c
case Empty => null
@ -825,7 +825,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
getResponse(List(user1Json, userWithSameUsernameAsUser1)).code must equal(FAILED)
//no user with firstUserId must be created
//no user with firstUserId should be created
Users.users.vend.getUserByProviderId(defaultProvider, user1.user_name) match {
case ParamFailure(_,x,y,_) => x must equal(Empty) // Returned result in case when akka is used
case Empty => Empty must equal(Empty)
@ -837,7 +837,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
getResponse(List(user1Json, userWithUsername2)).code must equal(SUCCESS)
//and both users must be created
//and both users should be created
val firstUser = Users.users.vend.getUserByProviderId(defaultProvider, user1.user_name) match {
case Full(fu) => fu
case Empty => null
@ -871,10 +871,10 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
val otherUser = user2
//when we try to add user1 and another valid new user it must now fail
//when we try to add user1 and another valid new user it should now fail
getResponse(List(user1Json, Extraction.decompose(otherUser))).code must equal(FAILED)
//and the other user must not have been created
//and the other user should not have been created
Users.users.vend.getUserByProviderId(defaultProvider, otherUser.user_name)
}
@ -888,12 +888,12 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
val userWithoutPassword = removeField(goodUser, "password")
getResponse(List(userWithoutPassword)).code must equal(FAILED)
//no user must be created
//no user should be created
Users.users.vend.getUserByProviderId(defaultProvider, user1.user_name).isDefined must equal(false)
val userWithBlankPassword = replaceField(goodUser, "password", "")
getResponse(List(userWithBlankPassword)).code must equal(FAILED)
//no user must be created
//no user should be created
Users.users.vend.getUserByProviderId(defaultProvider, user1.user_name).isDefined must equal(false)
//check that a normal password is okay
@ -943,7 +943,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
getResponse(List(acc1AtBank1Json)).code must equal(SUCCESS)
//an account must now exist
//an account should now exist
verifyAccountCreated(account1AtBank1)
}
@ -961,7 +961,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
//might be nice to test a case where the only similar attribute between the accounts is the id
getResponse(List(account1AtBank1Json, accountWithSameId)).code must equal(FAILED)
//no accounts must have been created
//no accounts should have been created
Connector.connector.vend.getBankAccount(BankId(account1AtBank1.bank), AccountId(account1AtBank1.id)).isDefined must equal(false)
val accountIdTwo = "2"
@ -971,7 +971,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
getResponse(List(account1AtBank1Json, accountWithDifferentId)).code must equal(SUCCESS)
//two accounts must have been created
//two accounts should have been created
Connector.connector.vend.getBankAccount(BankId(account1AtBank1.bank), AccountId(account1AtBank1.id)).isDefined must equal(true)
Connector.connector.vend.getBankAccount(BankId(account1AtBank1.bank), AccountId(accountIdTwo)).isDefined must equal(true)
@ -990,10 +990,10 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
getResponse(List(account1AtBank1Json)).code must equal(SUCCESS)
val otherAccount = account1AtBank2
//when we try to add account1AtBank1 and another valid account it must now fail
//when we try to add account1AtBank1 and another valid account it should now fail
getResponse(List(account1AtBank1Json, Extraction.decompose(otherAccount))).code must equal(FAILED)
//and the other account must not have been created
//and the other account should not have been created
Connector.connector.vend.getBankAccount(BankId(otherAccount.bank), AccountId(otherAccount.id)).isDefined must equal(false)
}
@ -1014,7 +1014,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
getResponse(List(badBankAccount)).code must equal(FAILED)
//no account must have been created
//no account should have been created
Connector.connector.vend.getBankAccount(BankId(badBankId), AccountId(account1AtBank1.id)).isDefined must equal(false)
}
@ -1055,14 +1055,14 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
getResponse(List(Extraction.decompose(accountWithInvalidOwner))).code must equal(FAILED)
//it must not have been created
//it should not have been created
Connector.connector.vend.getBankAccount(BankId(accountWithInvalidOwner.bank), AccountId(accountWithInvalidOwner.id)).isDefined must equal(false)
//a mix of valid an invalid owners must also not work
val accountWithSomeValidSomeInvalidOwners = accountWithInvalidOwner.copy(owners = List(accountWithInvalidOwner.owners + user1.user_name))
getResponse(List(Extraction.decompose(accountWithSomeValidSomeInvalidOwners))).code must equal(FAILED)
//it must not have been created
//it should not have been created
Connector.connector.vend.getBankAccount(BankId(accountWithSomeValidSomeInvalidOwners.bank), AccountId(accountWithSomeValidSomeInvalidOwners.id)).isDefined must equal(false)
}
@ -1085,14 +1085,14 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
getResponse(List(acc1Json, sameNumberJson)).code must equal(FAILED)
//no accounts must have been created
//no accounts should have been created
Connector.connector.vend.getBankAccount(BankId(acc1.bank), AccountId(acc1.id)).isDefined must equal(false)
Connector.connector.vend.getBankAccount(BankId(acc1.bank), AccountId(acc2.id)).isDefined must equal(false)
//check it works with the normal different number
getResponse(List(acc1Json, acc2Json)).code must equal(SUCCESS)
//and the accounts must be created
//and the accounts should be created
Connector.connector.vend.getBankAccount(BankId(acc1.bank), AccountId(acc1.id)).isDefined must equal(true)
Connector.connector.vend.getBankAccount(BankId(acc1.bank), AccountId(acc2.id)).isDefined must equal(true)
}
@ -1184,7 +1184,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
val otherTransaction = transactionWithCounterparty
//when we try to add t1Json and another valid transaction it must now fail
//when we try to add t1Json and another valid transaction it should now fail
getResponse(List(t1Json, Extraction.decompose(otherTransaction))).code must equal(FAILED)
//and no new transaction must exist
@ -1561,7 +1561,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
val counter1 = foundTransaction1Box.otherAccount
val counter2 = foundTransaction2Box.otherAccount
//transactions must have the same counterparty
//transactions should have the same counterparty
counter1.counterPartyId must not equal(counter2.counterPartyId)
counter1.counterPartyId.isEmpty must equal(false)
counter2.counterPartyId.isEmpty must equal(false)
@ -1662,7 +1662,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with MustM
TransactionId(newTransId)).isDefined must equal(exist)
}
//no transactions must be created
//no transactions should be created
checkNoTransactionsExist()
//check transaction with bad value

View File

@ -1,10 +1,12 @@
package code.setup
import code.api.util.APIUtil
import code.api.util.APIUtil.OAuth.{Consumer, Token}
import code.consumer.Consumers
import code.model.TokenType._
import code.model.{User, Consumer => OBPConsumer, Token => OBPToken}
import code.token.Tokens
import net.liftweb.common.Full
import net.liftweb.util.Helpers._
import net.liftweb.util.Props
import net.liftweb.util.TimeHelpers.TimeSpan
@ -15,7 +17,7 @@ import net.liftweb.util.TimeHelpers.TimeSpan
* The login users are tuples (consumer, token), contains the consumer and token, used for direct login.
*/
trait DefaultUsers {
//create the application(consumer, used it in the Login credential, mainly used the consume_key and consumer_secret)
lazy val testConsumer = Consumers.consumers.vend.createConsumer(
key = Some(randomString(40).toLowerCase),
@ -27,8 +29,11 @@ trait DefaultUsers {
developerEmail = None,
redirectURL = None,
createdByUserId = None //Internally, the consumer is not relevant to UserId.
).get
lazy val consumer = Consumer(testConsumer.key, testConsumer.secret)
) match {
case Full(t) => t
}
lazy val consumer = Consumer(testConsumer.key.get, testConsumer.secret.get)
// create the access token
val expiration = Props.getInt("token_expiration_weeks", 4)
@ -38,50 +43,62 @@ trait DefaultUsers {
val defaultProvider = Props.get("hostname", "")
// create some resource user for test purposes
lazy val resourceUser1 = User.createResourceUser(defaultProvider, None, None, None, None).get
lazy val resourceUser2 = User.createResourceUser(defaultProvider, None, None, None, None).get
lazy val resourceUser3 = User.createResourceUser(defaultProvider, None, None, None, None).get
lazy val resourceUser1 = User.createResourceUser(defaultProvider, None, None, None, None) match {
case Full(u1) => u1
}
lazy val resourceUser2 = User.createResourceUser(defaultProvider, None, None, None, None) match {
case Full(u2) => u2
}
lazy val resourceUser3 = User.createResourceUser(defaultProvider, None, None, None, None) match {
case Full(u3) => u3
}
// create the tokens in database, we only need token-key and token-secret
lazy val testToken1 = Tokens.tokens.vend.createToken(
Access,
Some(testConsumer.id),
Some(resourceUser1.id.toLong),
Some(testConsumer.id.get),
Some(resourceUser1.id.get),
Some(randomString(40).toLowerCase),
Some(randomString(40).toLowerCase),
Some(tokenDuration),
Some({ (now: TimeSpan) + tokenDuration }),
Some(now),
None
).get
) match {
case Full(t) => t
}
lazy val testToken2 = Tokens.tokens.vend.createToken(
Access,
Some(testConsumer.id),
Some(resourceUser2.id.toLong),
Some(testConsumer.id.get),
Some(resourceUser2.id.get),
Some(randomString(40).toLowerCase),
Some(randomString(40).toLowerCase),
Some(tokenDuration),
Some({ (now: TimeSpan) + tokenDuration }),
Some(now),
None
).get
) match {
case Full(t) => t
}
lazy val testToken3 = Tokens.tokens.vend.createToken(Access,
Some(testConsumer.id),
Some(resourceUser3.id.toLong),
Some(testConsumer.id.get),
Some(resourceUser3.id.get),
Some(randomString(40).toLowerCase),
Some(randomString(40).toLowerCase),
Some(tokenDuration),
Some({ (now: TimeSpan) + tokenDuration }),
Some(now),
None
).get
) match {
case Full(t) => t
}
// prepare the tokens
lazy val token1 = Token(testToken1.key, testToken1.secret)
lazy val token2 = Token(testToken2.key, testToken2.secret)
lazy val token3 = Token(testToken3.key, testToken3.secret)
lazy val token1 = Token(testToken1.key.get, testToken1.secret.get)
lazy val token2 = Token(testToken2.key.get, testToken2.secret.get)
lazy val token3 = Token(testToken3.key.get, testToken3.secret.get)
// prepare the OAuth users to login
lazy val user1 = Some(consumer, token1)

View File

@ -127,7 +127,7 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
}
override protected def wipeTestData() = {
//returns true if the model must not be wiped after each test
//returns true if the model should not be wiped after each test
def exclusion(m : MetaMapper[_]) = {
m == Nonce || m == Token || m == Consumer || m == AuthUser || m == ResourceUser
}

View File

@ -12,7 +12,7 @@
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*GNU Affero General Public License for more details.
**
*You must have received a copy of the GNU Affero General Public License
*you should have received a copy of the GNU Affero General Public License
*along with this program. If not, see <http://www.gnu.org/licenses/>.
**
*Email: contact@tesobe.com

View File

@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You must have received a copy of the GNU Affero General Public License
you should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Email: contact@tesobe.com

View File

@ -54,7 +54,7 @@ trait TestConnectorSetupWithStandardPermissions extends TestConnectorSetup {
//drop the mongo Database after each test
MongoDB.getDb(DefaultConnectionIdentifier).foreach(_.dropDatabase())
//returns true if the model must not be wiped after each test
//returns true if the model should not be wiped after each test
def exclusion(m : MetaMapper[_]) = {
m == Nonce || m == Token || m == Consumer || m == AuthUser || m == ResourceUser
}

View File

@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You must have received a copy of the GNU Affero General Public License
you should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Email: contact@tesobe.com