Skip to content

Commit

Permalink
Merge branch 'master' into 4130-reduce-log-level
Browse files Browse the repository at this point in the history
  • Loading branch information
imsdu authored Aug 4, 2023
2 parents 5ed1096 + 69fe882 commit e7ba0d0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ object Identity extends TestHelpers {
val Alice = UserCredentials(genString(), genString(), testRealm)
}

object aggregations {
val Charlie = UserCredentials(genString(), genString(), testRealm)
val Rose = UserCredentials(genString(), genString(), testRealm)
}

object orgs {
val Fry = UserCredentials(genString(), genString(), testRealm)
val Leela = UserCredentials(genString(), genString(), testRealm)
Expand Down Expand Up @@ -89,6 +94,6 @@ object Identity extends TestHelpers {
}

lazy val allUsers =
acls.Marge :: archives.Tweety :: compositeviews.Jerry :: events.BugsBunny :: listings.Bob :: listings.Alice :: orgs.Fry :: orgs.Leela :: projects.Bojack :: projects.PrincessCarolyn :: resources.Rick :: resources.Morty :: storages.Coyote :: views.ScoobyDoo :: mash.Radar :: supervision.Mickey :: Nil
acls.Marge :: archives.Tweety :: compositeviews.Jerry :: events.BugsBunny :: listings.Bob :: listings.Alice :: aggregations.Charlie :: aggregations.Rose :: orgs.Fry :: orgs.Leela :: projects.Bojack :: projects.PrincessCarolyn :: resources.Rick :: resources.Morty :: storages.Coyote :: views.ScoobyDoo :: mash.Radar :: supervision.Mickey :: Nil

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import akka.http.scaladsl.model.StatusCodes
import ch.epfl.bluebrain.nexus.testkit.{CirceEq, EitherValuable}
import ch.epfl.bluebrain.nexus.tests.{BaseSpec, SchemaPayload}
import ch.epfl.bluebrain.nexus.tests.Identity.Anonymous
import ch.epfl.bluebrain.nexus.tests.Identity.listings.{Alice, Bob}
import ch.epfl.bluebrain.nexus.tests.Identity.aggregations.{Charlie, Rose}
import ch.epfl.bluebrain.nexus.tests.iam.types.Permission.{Organizations, Resources, Views}
import io.circe.Json
import org.scalatest.Inspectors
Expand All @@ -25,16 +25,16 @@ final class AggregationsSpec extends BaseSpec with Inspectors with EitherValuabl
super.beforeAll()

val setup = for {
_ <- aclDsl.addPermission("/", Bob, Organizations.Create)
_ <- aclDsl.addPermission("/", Charlie, Organizations.Create)
// First org and projects
_ <- adminDsl.createOrganization(org1, org1, Bob)
_ <- adminDsl.createProject(org1, proj11, kgDsl.projectJson(name = proj11), Bob)
_ <- adminDsl.createProject(org1, proj12, kgDsl.projectJson(name = proj12), Bob)
_ <- adminDsl.createOrganization(org1, org1, Charlie)
_ <- adminDsl.createProject(org1, proj11, kgDsl.projectJson(name = proj11), Charlie)
_ <- adminDsl.createProject(org1, proj12, kgDsl.projectJson(name = proj12), Charlie)
// Second org and projects
_ <- adminDsl.createOrganization(org2, org2, Bob)
_ <- adminDsl.createProject(org2, proj21, kgDsl.projectJson(name = proj21), Bob)
_ <- aclDsl.addPermission(s"/$ref12", Alice, Resources.Read)
_ <- aclDsl.addPermission(s"/$ref12", Alice, Views.Query)
_ <- adminDsl.createOrganization(org2, org2, Charlie)
_ <- adminDsl.createProject(org2, proj21, kgDsl.projectJson(name = proj21), Charlie)
_ <- aclDsl.addPermission(s"/$ref12", Rose, Resources.Read)
_ <- aclDsl.addPermission(s"/$ref12", Rose, Views.Query)
} yield ()

val resourcePayload =
Expand All @@ -45,13 +45,13 @@ final class AggregationsSpec extends BaseSpec with Inspectors with EitherValuabl
val schemaPayload = SchemaPayload.loadSimple()
val postResources = for {
// Creation
_ <- deltaClient.put[Json](s"/resources/$ref11/_/resource11", resourcePayload, Bob)(expectCreated)
_ <- deltaClient.put[Json](s"/schemas/$ref11/test-schema", schemaPayload, Bob)(expectCreated)
_ <- deltaClient.put[Json](s"/resources/$ref11/test-schema/resource11_with_schema", resourcePayload, Bob)(
_ <- deltaClient.put[Json](s"/resources/$ref11/_/resource11", resourcePayload, Charlie)(expectCreated)
_ <- deltaClient.put[Json](s"/schemas/$ref11/test-schema", schemaPayload, Charlie)(expectCreated)
_ <- deltaClient.put[Json](s"/resources/$ref11/test-schema/resource11_with_schema", resourcePayload, Charlie)(
expectCreated
)
_ <- deltaClient.put[Json](s"/resources/$ref12/_/resource12", resourcePayload, Bob)(expectCreated)
_ <- deltaClient.put[Json](s"/resources/$ref21/_/resource21", resourcePayload, Bob)(expectCreated)
_ <- deltaClient.put[Json](s"/resources/$ref12/_/resource12", resourcePayload, Charlie)(expectCreated)
_ <- deltaClient.put[Json](s"/resources/$ref21/_/resource21", resourcePayload, Charlie)(expectCreated)
} yield ()

(setup >> postResources).accepted
Expand All @@ -61,7 +61,7 @@ final class AggregationsSpec extends BaseSpec with Inspectors with EitherValuabl

"get an error if the user has no access" in {

deltaClient.get[Json](s"/resources/$ref11?aggregations=true", Alice) { (_, response) =>
deltaClient.get[Json](s"/resources/$ref11?aggregations=true", Rose) { (_, response) =>
response.status shouldEqual StatusCodes.Forbidden
}
}
Expand All @@ -72,7 +72,7 @@ final class AggregationsSpec extends BaseSpec with Inspectors with EitherValuabl
"org" -> org1,
"project" -> proj11
)
deltaClient.get[Json](s"/resources/$ref11?aggregations=true", Bob) { (json, response) =>
deltaClient.get[Json](s"/resources/$ref11?aggregations=true", Charlie) { (json, response) =>
response.status shouldEqual StatusCodes.OK
json should equalIgnoreArrayOrder(expected)
}
Expand All @@ -83,7 +83,7 @@ final class AggregationsSpec extends BaseSpec with Inspectors with EitherValuabl
"Aggregating resources within an org" should {

"get an error if the user has no access on the org" in {
deltaClient.get[Json](s"/resources/$org2?aggregations=true", Alice) { (_, response) =>
deltaClient.get[Json](s"/resources/$org2?aggregations=true", Rose) { (_, response) =>
response.status shouldEqual StatusCodes.Forbidden
}
}
Expand All @@ -95,7 +95,7 @@ final class AggregationsSpec extends BaseSpec with Inspectors with EitherValuabl
"proj11" -> proj11,
"proj12" -> proj12
)
deltaClient.get[Json](s"/resources/$org1?aggregations=true", Bob) { (json, response) =>
deltaClient.get[Json](s"/resources/$org1?aggregations=true", Charlie) { (json, response) =>
response.status shouldEqual StatusCodes.OK
json should equalIgnoreArrayOrder(expected)
}
Expand All @@ -120,7 +120,7 @@ final class AggregationsSpec extends BaseSpec with Inspectors with EitherValuabl
"proj12" -> proj12,
"proj21" -> proj21
)
deltaClient.get[Json](s"/resources?aggregations=true", Bob) { (json, response) =>
deltaClient.get[Json](s"/resources?aggregations=true", Charlie) { (json, response) =>
response.status shouldEqual StatusCodes.OK
json should equalIgnoreArrayOrder(expected)
}
Expand Down

0 comments on commit e7ba0d0

Please sign in to comment.