Skip to content

Commit

Permalink
Added negative test case to GCS auth tests when a bucket exists but u…
Browse files Browse the repository at this point in the history
…ser doesn't have write permissions.

Fixed potential None.get exception on AgoraAuthorizationException.
  • Loading branch information
jcarey committed Jul 29, 2015
1 parent 429556b commit ecdc06f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -7,6 +7,8 @@ import org.broadinstitute.dsde.agora.server.model.AgoraEntity
case class AgoraAuthorizationException(agoraPermissions: AgoraPermissions, agoraEntity: AgoraEntity) extends Exception {
override def getMessage: String = {
s"Authorization exception attempting to exercise permission ${agoraPermissions.permissions} " +
s"on entity ${agoraEntity.namespace.get}.${agoraEntity.name.get}.${agoraEntity.snapshotId.get}."
s"on entity ${agoraEntity.namespace.getOrElse("No Namespace")}" +
s".${agoraEntity.name.getOrElse("No Name")}" +
s".${agoraEntity.snapshotId.getOrElse(-1)}."
}
}
Expand Up @@ -3,7 +3,7 @@ package org.broadinstitute.dsde.agora.server.dataaccess.acls

import org.broadinstitute.dsde.agora.server.AgoraConfig
import org.broadinstitute.dsde.agora.server.AgoraIntegrationTestData._
import org.broadinstitute.dsde.agora.server.business.AgoraBusiness
import org.broadinstitute.dsde.agora.server.business.{AgoraAuthorizationException, AgoraBusiness}
import org.broadinstitute.dsde.agora.server.dataaccess.acls.gcs.GcsAuthorizationProvider
import org.scalatest.{DoNotDiscover, FlatSpec}

Expand All @@ -16,4 +16,13 @@ class GcsAuthorizationSpec extends FlatSpec {
val entity = agoraBusiness.insert(testIntegrationEntity, "jcarey@broadinstitute.org")
assert(agoraBusiness.findSingle(entity, Seq(entity.entityType.get), username) === entity)
}

"Agora" should "check bucket write ACL when creating a new method in an existing workspace and fail if the user " +
"doesn't have access" in {
val thrown = intercept[AgoraAuthorizationException] {
agoraBusiness.insert(testIntegrationEntity, "jcarey@broadinstitute.org")
agoraBusiness.insert(testIntegrationEntity, "ggrant@broadinstitute.org")
}
assert(thrown != null)
}
}

0 comments on commit ecdc06f

Please sign in to comment.