From 8219cd386540f29a7707ef09bbdbcb9120639d95 Mon Sep 17 00:00:00 2001 From: Everett Sochowski Date: Tue, 11 Feb 2014 12:24:48 +0100 Subject: [PATCH] Add test that demonstrates permissions bug where get permissions json is missing values --- src/test/scala/code/api/API121Test.scala | 35 ++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/test/scala/code/api/API121Test.scala b/src/test/scala/code/api/API121Test.scala index db5eeef48..94fc7b0e1 100644 --- a/src/test/scala/code/api/API121Test.scala +++ b/src/test/scala/code/api/API121Test.scala @@ -56,6 +56,8 @@ import code.api.test.{ServerSetup, APIResponse} import code.util.APIUtil.OAuth._ import code.model.ViewCreationJSON +import scala.reflect.runtime.universe._ + class API1_2_1Test extends ServerSetup{ @@ -174,6 +176,13 @@ class API1_2_1Test extends ServerSetup{ val user3 = Some((consumer, token3)) /************************* test tags ************************/ + + /** + * Example: To run tests with tag "getPermissions": + * mvn test -D tagsToInclude + * + * This is made possible by the scalatest maven plugin + */ object CurrentTest extends Tag("currentScenario") object API1_2 extends Tag("api1.2.1") @@ -1018,9 +1027,31 @@ class API1_2_1Test extends ServerSetup{ val reply = getAccountPermissions(bankId, bankAccount.id, user1) Then("we should get a 200 ok code") reply.code should equal (200) - reply.body.extract[PermissionsJSON] - } + val permissions = reply.body.extract[PermissionsJSON] + + def stringNotEmpty(s : String) { + s should not equal null + s should not equal "" + } + + for { + permission <- permissions.permissions + } { + val user = permission.user + //TODO: Need to come up with a better way to check that information is not missing + // idea: reflection on all the json case classes, marking "required" information with annotations + stringNotEmpty(user.id) + stringNotEmpty(user.provider) + + for { + view <- permission.views + } { + stringNotEmpty(view.id) + } + } + } + scenario("we will not get one bank account permissions", API1_2, GetPermissions) { Given("We will not use an access token") val bankId = randomBank