Skip to content

Commit

Permalink
OpenBankProject#927 fixed the failed tests, no public accounts for al…
Browse files Browse the repository at this point in the history
…l getAccounts endpoints.
  • Loading branch information
hongwei1 committed Feb 18, 2018
1 parent 64aa4dd commit 11bbdc0
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 84 deletions.
104 changes: 52 additions & 52 deletions src/test/scala/code/api/v1_2_1/API1_2_1Test.scala
Expand Up @@ -1085,30 +1085,30 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
}

feature("Information about all the bank accounts for all banks"){
scenario("we get only the public bank accounts", API1_2, GetBankAccountsForAllBanks) {
accountTestsSpecificDBSetup()
Given("We will not use an access token")
When("the request is sent")
val reply = getBankAccountsForAllBanks(None)
Then("we should get a 200 ok code")
reply.code should equal (200)
val publicAccountsInfo = reply.body.extract[AccountsJSON]
And("some fields should not be empty")
publicAccountsInfo.accounts.foreach(a => {
a.id.nonEmpty should equal (true)
a.views_available.nonEmpty should equal (true)
a.views_available.foreach(
//check that all the views are public
v => v.is_public should equal (true)
)
})

And("There are accounts from more than one bank")
assertAccountsFromMoreThanOneBank(publicAccountsInfo)

And("There are no duplicate accounts")
assertNoDuplicateAccounts(publicAccountsInfo)
}
// scenario("we get only the public bank accounts", API1_2, GetBankAccountsForAllBanks) {
// accountTestsSpecificDBSetup()
// Given("We will not use an access token")
// When("the request is sent")
// val reply = getBankAccountsForAllBanks(None)
// Then("we should get a 200 ok code")
// reply.code should equal (200)
// val publicAccountsInfo = reply.body.extract[AccountsJSON]
// And("some fields should not be empty")
// publicAccountsInfo.accounts.foreach(a => {
// a.id.nonEmpty should equal (true)
// a.views_available.nonEmpty should equal (true)
// a.views_available.foreach(
// //check that all the views are public
// v => v.is_public should equal (true)
// )
// })
//
// And("There are accounts from more than one bank")
// assertAccountsFromMoreThanOneBank(publicAccountsInfo)
//
// And("There are no duplicate accounts")
// assertNoDuplicateAccounts(publicAccountsInfo)
// }
scenario("we get the bank accounts the user has access to", API1_2, GetBankAccountsForAllBanks) {
accountTestsSpecificDBSetup()
Given("We will use an access token")
Expand All @@ -1124,8 +1124,8 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
})

//test that this call is a combination of accounts with more than public access, and accounts with public access
And("Some accounts should have only public views")
assertAtLeastOneAccountHasAllViewsWithCondition(accountsInfo, _.is_public)
// And("Some accounts should have only public views")
// assertAtLeastOneAccountHasAllViewsWithCondition(accountsInfo, _.is_public)
And("Some accounts should have only private views")
assertAtLeastOneAccountHasAllViewsWithCondition(accountsInfo, !_.is_public)

Expand Down Expand Up @@ -1201,30 +1201,30 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
}

feature("Information about all the bank accounts for a single bank"){
scenario("we get only the public bank accounts", API1_2, GetBankAccounts) {
accountTestsSpecificDBSetup()
Given("We will not use an access token")
When("the request is sent")
val reply = getBankAccounts(randomBank, None)
Then("we should get a 200 ok code")
reply.code should equal (200)
val publicAccountsInfo = reply.body.extract[AccountsJSON]
And("some fields should not be empty")
publicAccountsInfo.accounts.foreach(a => {
a.id.nonEmpty should equal (true)
a.views_available.nonEmpty should equal (true)
a.views_available.foreach(
//check that all the views are public
v => v.is_public should equal (true)
)
})

And("The accounts are only from one bank")
assertAccountsFromOneBank(publicAccountsInfo)

And("There are no duplicate accounts")
assertNoDuplicateAccounts(publicAccountsInfo)
}
// scenario("we get only the public bank accounts", API1_2, GetBankAccounts) {
// accountTestsSpecificDBSetup()
// Given("We will not use an access token")
// When("the request is sent")
// val reply = getBankAccounts(randomBank, None)
// Then("we should get a 200 ok code")
// reply.code should equal (200)
// val publicAccountsInfo = reply.body.extract[AccountsJSON]
// And("some fields should not be empty")
// publicAccountsInfo.accounts.foreach(a => {
// a.id.nonEmpty should equal (true)
// a.views_available.nonEmpty should equal (true)
// a.views_available.foreach(
// //check that all the views are public
// v => v.is_public should equal (true)
// )
// })
//
// And("The accounts are only from one bank")
// assertAccountsFromOneBank(publicAccountsInfo)
//
// And("There are no duplicate accounts")
// assertNoDuplicateAccounts(publicAccountsInfo)
// }
scenario("we get the bank accounts the user have access to", API1_2, GetBankAccounts) {
accountTestsSpecificDBSetup()
Given("We will use an access token")
Expand All @@ -1242,8 +1242,8 @@ class API1_2_1Test extends User1AllPrivileges with DefaultUsers with PrivateUser
//test that this call is a combination of accounts with more than public access, and accounts with public access
And("Some accounts should have only public views")

assertAtLeastOneAccountHasAllViewsWithCondition(accountsInfo, _.is_public)
And("Some accounts should have only private views")
// assertAtLeastOneAccountHasAllViewsWithCondition(accountsInfo, _.is_public)
// And("Some accounts should have only private views")
assertAtLeastOneAccountHasAllViewsWithCondition(accountsInfo, !_.is_public)

And("The accounts are only from one bank")
Expand Down
64 changes: 32 additions & 32 deletions src/test/scala/code/api/v2_0_0/AccountTest.scala
Expand Up @@ -26,22 +26,22 @@ class AccountTest extends V200ServerSetup with DefaultUsers {
And("We should get a 200")
responsePut.code should 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)

val isPublic: List[Boolean] =
for {
JObject(o) <- responseGet.body
JField("is_public", JBool(isPublic)) <- o
} yield {
isPublic
}
And("All received accounts have to be public")
isPublic.forall(_ == true) should equal(true)
// 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)
//
// val isPublic: List[Boolean] =
// for {
// JObject(o) <- responseGet.body
// JField("is_public", JBool(isPublic)) <- o
// } yield {
// isPublic
// }
// And("All received accounts have to be public")
// isPublic.forall(_ == true) should equal(true)

When("We make the authenticated access request")
val requestGetAll = (v2_0Request / "accounts").GET <@ (user1)
Expand Down Expand Up @@ -74,22 +74,22 @@ class AccountTest extends V200ServerSetup with DefaultUsers {
And("We should get a 200")
responsePut.code should 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)

val isPublic: List[Boolean] =
for {
JObject(o) <- responseGet.body
JField("is_public", JBool(isPublic)) <- o
} yield {
isPublic
}
And("All received accounts have to be public")
isPublic.forall(_ == true) should equal(true)
// 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)
//
// val isPublic: List[Boolean] =
// for {
// JObject(o) <- responseGet.body
// JField("is_public", JBool(isPublic)) <- o
// } yield {
// isPublic
// }
// And("All received accounts have to be public")
// isPublic.forall(_ == true) should equal(true)

When("We make the authenticated access request")
val requestGetAll = (v2_0Request / "banks" / testBank.value / "accounts").GET <@ (user1)
Expand Down

0 comments on commit 11bbdc0

Please sign in to comment.