Skip to content

Commit

Permalink
Added Permissions SQL db
Browse files Browse the repository at this point in the history
Ripped out all GCS code (except Token Handler) and replaced it with a
sql database permissions client.
  • Loading branch information
Vivek Dasari committed Aug 13, 2015
1 parent e3c43d8 commit 6a9462c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,65 +26,65 @@ object AgoraIntegrationTestData {
payload = payload1,
entityType = Option(AgoraEntityType.Workflow))

val testAgoraEntityWithValidOfficialDockerImageInWdl = new AgoraEntity(namespace = Option("___docker_test" + System.currentTimeMillis()),
val testAgoraEntityWithValidOfficialDockerImageInWdl = new AgoraEntity(namespace = Option("___docker_test"),
name = name1,
synopsis = synopsis1,
documentation = documentation1,
owner = Option(owner1),
owner = Option(mockAutheticatedOwner),
payload = payloadWithValidOfficialDockerImageInWdl,
entityType = Option(AgoraEntityType.Task)
)

val testAgoraEntityWithInvalidOfficialDockerRepoNameInWdl = new AgoraEntity(namespace = Option("___docker_test" + System.currentTimeMillis()),
val testAgoraEntityWithInvalidOfficialDockerRepoNameInWdl = new AgoraEntity(namespace = Option("___docker_test"),
name = name1,
synopsis = synopsis1,
documentation = documentation1,
owner = Option(owner1),
owner = Option(mockAutheticatedOwner),
payload = payloadWithInvalidOfficialDockerRepoNameInWdl,
entityType = Option(AgoraEntityType.Task)
)

val testAgoraEntityWithInvalidOfficialDockerTagNameInWdl = new AgoraEntity(namespace = Option("___docker_test" + System.currentTimeMillis()),
val testAgoraEntityWithInvalidOfficialDockerTagNameInWdl = new AgoraEntity(namespace = Option("___docker_test"),
name = name1,
synopsis = synopsis1,
documentation = documentation1,
owner = Option(owner1),
owner = Option(mockAutheticatedOwner),
payload = payloadWithInvalidOfficialDockerTagNameInWdl,
entityType = Option(AgoraEntityType.Task)
)

val testAgoraEntityWithValidPersonalDockerInWdl = new AgoraEntity(namespace = Option("___docker_test" + System.currentTimeMillis()),
val testAgoraEntityWithValidPersonalDockerInWdl = new AgoraEntity(namespace = Option("___docker_test"),
name = name1,
synopsis = synopsis1,
documentation = documentation1,
owner = Option(owner1),
owner = Option(mockAutheticatedOwner),
payload = payloadWithValidPersonalDockerImageInWdl,
entityType = Option(AgoraEntityType.Task)
)

val testAgoraEntityWithInvalidPersonalDockerUserNameInWdl = new AgoraEntity(namespace = Option("___docker_test" + System.currentTimeMillis()),
val testAgoraEntityWithInvalidPersonalDockerUserNameInWdl = new AgoraEntity(namespace = Option("___docker_test"),
name = name1,
synopsis = synopsis1,
documentation = documentation1,
owner = Option(owner1),
owner = Option(mockAutheticatedOwner),
payload = payloadWithInvalidPersonalDockerUserNameInWdl,
entityType = Option(AgoraEntityType.Task)
)

val testAgoraEntityWithInvalidPersonalDockerRepoNameInWdl = new AgoraEntity(namespace = Option("___docker_test" + System.currentTimeMillis()),
val testAgoraEntityWithInvalidPersonalDockerRepoNameInWdl = new AgoraEntity(namespace = Option("___docker_test"),
name = name1,
synopsis = synopsis1,
documentation = documentation1,
owner = Option(owner1),
owner = Option(mockAutheticatedOwner),
payload = payloadWithInvalidPersonalDockerRepoNameInWdl,
entityType = Option(AgoraEntityType.Task)
)

val testAgoraEntityWithInvalidPersonalDockerTagNameInWdl = new AgoraEntity(namespace = Option("___docker_test" + System.currentTimeMillis()),
val testAgoraEntityWithInvalidPersonalDockerTagNameInWdl = new AgoraEntity(namespace = Option("___docker_test"),
name = name1,
synopsis = synopsis1,
documentation = documentation1,
owner = Option(owner1),
owner = Option(mockAutheticatedOwner),
payload = payloadWithInvalidPersonalDockerTagNameInWdl,
entityType = Option(AgoraEntityType.Task)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,15 @@ class AgoraIntegrationTestSuite extends Suites(
agora.start()
EmbeddedMongo.startMongo()

val setupAction = DBIO.seq(
db = AgoraConfig.sqlDatabase

val setupFuture = db.run(
(entitys.schema ++
users.schema ++
permissions.schema).create,

users ++= Seq(
UserDao(owner1),
UserDao(owner2),
UserDao(mockAutheticatedOwner)
)
permissions.schema).create
)

db = AgoraConfig.sqlDatabase
println("Connecting to sql database.")
val setupFuture = db.run(setupAction)
Await.result(setupFuture, timeout)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,15 @@ class AgoraUnitTestSuite extends Suites(
println(s"Starting Agora web services ($suiteName)")
agora.start()

val setupAction = DBIO.seq(
db = AgoraConfig.sqlDatabase

val setupFuture = db.run(
(entitys.schema ++
users.schema ++
permissions.schema).create,

users ++= Seq(
UserDao(owner1.get),
UserDao(owner2.get),
UserDao(mockAutheticatedOwner.get)
)
permissions.schema).create
)

db = AgoraConfig.sqlDatabase
println("Connecting to test sql database.")
val setupFuture = db.run(setupAction)
Await.result(setupFuture, timeout)

agoraBusiness.insert(testEntity1, mockAutheticatedOwner.get)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.broadinstitute.dsde.agora.server.business

import org.broadinstitute.dsde.agora.server.AgoraConfig
import org.broadinstitute.dsde.agora.server.AgoraIntegrationTestData._
import org.broadinstitute.dsde.agora.server.dataaccess.acls.gcs.GcsAuthorizationProvider
import org.broadinstitute.dsde.agora.server.webservice.util.DockerHubClient.DockerImageNotFoundException
import org.scalatest.{DoNotDiscover, FlatSpec}

Expand All @@ -11,46 +9,46 @@ class AgoraBusinessIntegrationSpec extends FlatSpec {
val agoraBusiness = new AgoraBusiness()

"Agora" should "be able to store a task configuration with a valid (extant) official docker image" in {
val entity = agoraBusiness.insert(testAgoraEntityWithValidOfficialDockerImageInWdl, owner1)
assert(agoraBusiness.findSingle(entity, Seq(entity.entityType.get), owner1) === entity)
val entity = agoraBusiness.insert(testAgoraEntityWithValidOfficialDockerImageInWdl, mockAutheticatedOwner)
assert(agoraBusiness.findSingle(entity, Seq(entity.entityType.get), mockAutheticatedOwner) === entity)
}

"Agora" should "be unable to store a task configuration with an invalid docker image (invalid/non-existent repo name)" in {
val thrown = intercept[DockerImageNotFoundException] {
agoraBusiness.insert(testAgoraEntityWithInvalidOfficialDockerRepoNameInWdl, owner1)
agoraBusiness.insert(testAgoraEntityWithInvalidOfficialDockerRepoNameInWdl, mockAutheticatedOwner)
}
assert(thrown != null)
}

"Agora" should "be unable to store a task configuration with an invalid docker image (invalid/non-existent tag name)" in {
val thrown = intercept[DockerImageNotFoundException] {
agoraBusiness.insert(testAgoraEntityWithInvalidOfficialDockerTagNameInWdl, owner1)
agoraBusiness.insert(testAgoraEntityWithInvalidOfficialDockerTagNameInWdl, mockAutheticatedOwner)
}
assert(thrown != null)
}

"Agora" should "be able to store a task configuration with a valid (extant) personal docker image" in {
val entity = agoraBusiness.insert(testAgoraEntityWithValidPersonalDockerInWdl, owner1)
assert(agoraBusiness.findSingle(entity, Seq(entity.entityType.get), owner1) === entity)
val entity = agoraBusiness.insert(testAgoraEntityWithValidPersonalDockerInWdl, mockAutheticatedOwner)
assert(agoraBusiness.findSingle(entity, Seq(entity.entityType.get), mockAutheticatedOwner) === entity)
}

"Agora" should "be unable to store a task configuration with an invalid personal docker image (invalid/non-existent user name)" in {
val thrown = intercept[DockerImageNotFoundException] {
agoraBusiness.insert(testAgoraEntityWithInvalidPersonalDockerUserNameInWdl, owner1)
agoraBusiness.insert(testAgoraEntityWithInvalidPersonalDockerUserNameInWdl, mockAutheticatedOwner)
}
assert(thrown != null)
}

"Agora" should "be unable to store a task configuration with an invalid personal docker image (invalid/non-existent repo name)" in {
val thrown = intercept[DockerImageNotFoundException] {
agoraBusiness.insert(testAgoraEntityWithInvalidPersonalDockerRepoNameInWdl, owner1)
agoraBusiness.insert(testAgoraEntityWithInvalidPersonalDockerRepoNameInWdl, mockAutheticatedOwner)
}
assert(thrown != null)
}

"Agora" should "be unable to store a task configuration with an invalid personal docker image (invalid/non-existent tag name)" in {
val thrown = intercept[DockerImageNotFoundException] {
agoraBusiness.insert(testAgoraEntityWithInvalidPersonalDockerTagNameInWdl, owner1)
agoraBusiness.insert(testAgoraEntityWithInvalidPersonalDockerTagNameInWdl, mockAutheticatedOwner)
}
assert(thrown != null)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.broadinstitute.dsde.agora.server.webservice

import org.broadinstitute.dsde.agora.server.AgoraIntegrationTestData._
import org.broadinstitute.dsde.agora.server.business.AgoraBusiness
import org.broadinstitute.dsde.agora.server.dataaccess.acls.MockAuthorizationProvider
import org.broadinstitute.dsde.agora.server.model.AgoraEntity
import org.broadinstitute.dsde.agora.server.webservice.methods.MethodsService
import org.broadinstitute.dsde.agora.server.webservice.util.ApiUtil
Expand All @@ -23,8 +22,8 @@ class AgoraImportIntegrationSpec extends FlatSpec with RouteTest with ScalatestR
def actorRefFactory = system
}

val agoraBusiness = new AgoraBusiness(MockAuthorizationProvider)
val methodsService = new MethodsService(MockAuthorizationProvider) with ActorRefFactoryContext with AgoraOpenAMMockDirectives
val agoraBusiness = new AgoraBusiness()
val methodsService = new MethodsService() with ActorRefFactoryContext


def handleError[T](deserialized: Deserialized[T], assertions: (T) => Unit) = {
Expand Down

0 comments on commit 6a9462c

Please sign in to comment.