Skip to content

Commit

Permalink
Merge branch 'develop' into unboundid
Browse files Browse the repository at this point in the history
  • Loading branch information
dvoet committed Jun 13, 2018
2 parents 552ae74 + f1145e2 commit eafee5f
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 35 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sbt._
object Dependencies {
val akkaV = "2.5.1"
val akkaHttpV = "10.0.6"
val jacksonV = "2.8.10"
val jacksonV = "2.9.5"
val scalaLoggingV = "3.5.0"
val scalaTestV = "3.0.1"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ object Boot extends App with LazyLogging {
val resourceTypes = config.as[Map[String, ResourceType]]("resourceTypes").values.toSet
val resourceTypeMap = resourceTypes.map(rt => rt.name -> rt).toMap

val environment = config.getString("environment")

val cloudExt = googleServicesConfigOption match {
case Some(googleServicesConfig) =>
val petServiceAccountConfig = config.as[PetServiceAccountConfig]("petServiceAccount")
Expand All @@ -74,7 +72,7 @@ object Boot extends App with LazyLogging {
val googleKeyCache = new GoogleKeyCache(googleIamDAO, googleStorageDAO, googlePubSubDAO, googleServicesConfig, petServiceAccountConfig)
val notificationDAO = new PubSubNotificationDAO(googlePubSubDAO, googleServicesConfig.notificationTopic)

new GoogleExtensions(directoryDAO, accessPolicyDAO, googleDirectoryDAO, googlePubSubDAO, googleIamDAO, googleStorageDAO, googleProjectDAO, googleKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, environment, resourceTypeMap(CloudExtensions.resourceTypeName))
new GoogleExtensions(directoryDAO, accessPolicyDAO, googleDirectoryDAO, googlePubSubDAO, googleIamDAO, googleStorageDAO, googleProjectDAO, googleKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, resourceTypeMap(CloudExtensions.resourceTypeName))
case None => NoExtensions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import scala.concurrent.duration.FiniteDuration
*/
case class GoogleServicesConfig(appName: String,
appsDomain: String,
environment: String,
pemFile: String,
serviceAccountClientId: String,
serviceAccountClientEmail: WorkbenchEmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ package object config {
GoogleServicesConfig(
config.getString("appName"),
config.getString("appsDomain"),
config.getString("environment"),
config.getString("pathToPem"),
config.getString("serviceAccountClientId"),
WorkbenchEmail(config.getString("serviceAccountClientEmail")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object GoogleExtensions {
val getPetPrivateKeyAction = ResourceAction("get_pet_private_key")
}

class GoogleExtensions(val directoryDAO: DirectoryDAO, val accessPolicyDAO: AccessPolicyDAO, val googleDirectoryDAO: GoogleDirectoryDAO, val googlePubSubDAO: GooglePubSubDAO, val googleIamDAO: GoogleIamDAO, val googleStorageDAO: GoogleStorageDAO, val googleProjectDAO: GoogleProjectDAO, val googleKeyCache: GoogleKeyCache, val notificationDAO: NotificationDAO, val googleServicesConfig: GoogleServicesConfig, val petServiceAccountConfig: PetServiceAccountConfig, environment: String, extensionResourceType: ResourceType)(implicit val system: ActorSystem, executionContext: ExecutionContext) extends LazyLogging with FutureSupport with CloudExtensions with Retry {
class GoogleExtensions(val directoryDAO: DirectoryDAO, val accessPolicyDAO: AccessPolicyDAO, val googleDirectoryDAO: GoogleDirectoryDAO, val googlePubSubDAO: GooglePubSubDAO, val googleIamDAO: GoogleIamDAO, val googleStorageDAO: GoogleStorageDAO, val googleProjectDAO: GoogleProjectDAO, val googleKeyCache: GoogleKeyCache, val notificationDAO: NotificationDAO, val googleServicesConfig: GoogleServicesConfig, val petServiceAccountConfig: PetServiceAccountConfig, extensionResourceType: ResourceType)(implicit val system: ActorSystem, executionContext: ExecutionContext) extends LazyLogging with FutureSupport with CloudExtensions with Retry {

private val maxGroupEmailLength = 64

Expand Down Expand Up @@ -275,7 +275,7 @@ class GoogleExtensions(val directoryDAO: DirectoryDAO, val accessPolicyDAO: Acce
}

private def getDefaultServiceAccountForShellProject(user: WorkbenchUser): Future[String] = {
val projectName = s"fc-${environment.substring(0, Math.min(environment.length(), 5))}-${user.id.value}" //max 30 characters. subject ID is 21
val projectName = s"fc-${googleServicesConfig.environment.substring(0, Math.min(googleServicesConfig.environment.length(), 5))}-${user.id.value}" //max 30 characters. subject ID is 21
for {
creationOperationId <- googleProjectDAO.createProject(projectName).map(opId => Option(opId)) recover {
case gjre: GoogleJsonResponseException if gjre.getDetails.getCode == StatusCodes.Conflict.intValue => None
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ directory {
googleServices {
appName = "firecloud:sam"
appsDomain = "dev.test.firecloud.org"
environment = "local"
pathToPem = "/etc/sam-account.pem"
serviceAccountClientId = "109949113883754608360"
serviceAccountClientEmail = "sam-dev-service-account@broad-dsde-dev.iam.gserviceaccount.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class GoogleExtensionRoutesSpec extends FlatSpec with Matchers with ScalatestRou
val googleStorageDAO = new MockGoogleStorageDAO()
val notificationDAO = new PubSubNotificationDAO(pubSubDAO, "foo")
val cloudKeyCache = new GoogleKeyCache(googleIamDAO, googleStorageDAO, pubSubDAO, googleServicesConfig, petServiceAccountConfig)
val googleExt = new GoogleExtensions(directoryDAO, null, googleDirectoryDAO, null, googleIamDAO, null, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, "local", configResourceTypes(CloudExtensions.resourceTypeName))
val googleExt = new GoogleExtensions(directoryDAO, null, googleDirectoryDAO, null, googleIamDAO, null, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, configResourceTypes(CloudExtensions.resourceTypeName))

val samRoutes = new TestSamRoutes(null, new UserService(directoryDAO, googleExt), new StatusService(directoryDAO, NoExtensions), null, UserInfo(OAuth2BearerToken(""), defaultUserId, defaultUserEmail, 0), directoryDAO) with GoogleExtensionRoutes {
val googleExtensions = googleExt
Expand Down Expand Up @@ -98,7 +98,7 @@ class GoogleExtensionRoutesSpec extends FlatSpec with Matchers with ScalatestRou
val googleStorageDAO = new MockGoogleStorageDAO()
val notificationDAO = new PubSubNotificationDAO(pubSubDAO, "foo")
val cloudKeyCache = new GoogleKeyCache(googleIamDAO, googleStorageDAO, pubSubDAO, googleServicesConfig, petServiceAccountConfig)
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, null, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, "local", configResourceTypes(CloudExtensions.resourceTypeName))
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, null, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, configResourceTypes(CloudExtensions.resourceTypeName))

// create a user
Post("/register/user") ~> samRoutes.route ~> check {
Expand All @@ -122,7 +122,7 @@ class GoogleExtensionRoutesSpec extends FlatSpec with Matchers with ScalatestRou
val googleStorageDAO = new MockGoogleStorageDAO()
val notificationDAO = new PubSubNotificationDAO(pubSubDAO, "foo")
val cloudKeyCache = new GoogleKeyCache(googleIamDAO, googleStorageDAO, pubSubDAO, googleServicesConfig, petServiceAccountConfig)
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, null, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, "local", configResourceTypes(CloudExtensions.resourceTypeName))
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, null, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, configResourceTypes(CloudExtensions.resourceTypeName))

// create a user
Post("/register/user") ~> samRoutes.route ~> check {
Expand Down Expand Up @@ -172,7 +172,7 @@ class GoogleExtensionRoutesSpec extends FlatSpec with Matchers with ScalatestRou
val pubSubDAO = new MockGooglePubSubDAO()
val notificationDAO = new PubSubNotificationDAO(pubSubDAO, "foo")
val cloudKeyCache = new GoogleKeyCache(googleIamDAO, googleStorageDAO, pubSubDAO, googleServicesConfig, petServiceAccountConfig)
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, googleStorageDAO, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, "local", configResourceTypes(CloudExtensions.resourceTypeName))
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, googleStorageDAO, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, configResourceTypes(CloudExtensions.resourceTypeName))

val emailDomain = "example.com"
val mockResourceService = new ResourceService(resourceTypes, policyDAO, directoryDAO, googleExt, emailDomain)
Expand Down Expand Up @@ -219,7 +219,7 @@ class GoogleExtensionRoutesSpec extends FlatSpec with Matchers with ScalatestRou
val pubSubDAO = new MockGooglePubSubDAO()
val notificationDAO = new PubSubNotificationDAO(pubSubDAO, "foo")
val cloudKeyCache = new GoogleKeyCache(googleIamDAO, googleStorageDAO, pubSubDAO, googleServicesConfig, petServiceAccountConfig)
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, googleStorageDAO, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, "local", configResourceTypes(CloudExtensions.resourceTypeName))
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, googleStorageDAO, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, configResourceTypes(CloudExtensions.resourceTypeName))

val emailDomain = "example.com"
val mockResourceService = new ResourceService(resourceTypes, policyDAO, directoryDAO, googleExt, emailDomain)
Expand Down Expand Up @@ -278,7 +278,7 @@ class GoogleExtensionRoutesSpec extends FlatSpec with Matchers with ScalatestRou
val pubSubDAO = new MockGooglePubSubDAO()
val notificationDAO = new PubSubNotificationDAO(pubSubDAO, "foo")
val cloudKeyCache = new GoogleKeyCache(googleIamDAO, googleStorageDAO, pubSubDAO, googleServicesConfig, petServiceAccountConfig)
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, googleStorageDAO, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, "local", configResourceTypes(CloudExtensions.resourceTypeName))
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, googleStorageDAO, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, configResourceTypes(CloudExtensions.resourceTypeName))

val emailDomain = "example.com"
val mockResourceService = new ResourceService(resourceTypes, policyDAO, directoryDAO, googleExt, emailDomain)
Expand Down Expand Up @@ -321,7 +321,7 @@ class GoogleExtensionRoutesSpec extends FlatSpec with Matchers with ScalatestRou
val pubSubDAO = new MockGooglePubSubDAO()
val notificationDAO = new PubSubNotificationDAO(pubSubDAO, "foo")
val cloudKeyCache = new GoogleKeyCache(googleIamDAO, googleStorageDAO, pubSubDAO, googleServicesConfig, petServiceAccountConfig)
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, googleStorageDAO, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, "local", configResourceTypes(CloudExtensions.resourceTypeName))
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, googleStorageDAO, null, cloudKeyCache, notificationDAO, googleServicesConfig, petServiceAccountConfig, configResourceTypes(CloudExtensions.resourceTypeName))

val emailDomain = "example.com"
val mockResourceService = new ResourceService(resourceTypes, policyDAO, directoryDAO, googleExt, emailDomain)
Expand Down Expand Up @@ -379,7 +379,7 @@ class GoogleExtensionRoutesSpec extends FlatSpec with Matchers with ScalatestRou
val pubSubDAO = new MockGooglePubSubDAO()
val notificationDAO = new PubSubNotificationDAO(pubSubDAO, "foo")
val cloudKeyCache = new GoogleKeyCache(googleIamDAO, googleStorageDAO, pubSubDAO, googleServicesConfig, petServiceAccountConfig)
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, googleStorageDAO, null, cloudKeyCache, notificationDAO, googleServicesConfig.copy(serviceAccountClientEmail = defaultUserInfo.userEmail, serviceAccountClientId = defaultUserInfo.userId.value), petServiceAccountConfig, "local", configResourceTypes(CloudExtensions.resourceTypeName))
val googleExt = new GoogleExtensions(directoryDAO, policyDAO, googleDirectoryDAO, pubSubDAO, googleIamDAO, googleStorageDAO, null, cloudKeyCache, notificationDAO, googleServicesConfig.copy(serviceAccountClientEmail = defaultUserInfo.userEmail, serviceAccountClientId = defaultUserInfo.userId.value), petServiceAccountConfig, configResourceTypes(CloudExtensions.resourceTypeName))

val emailDomain = "example.com"
val mockResourceService = new ResourceService(configResourceTypes, policyDAO, directoryDAO, googleExt, emailDomain)
Expand Down
Loading

0 comments on commit eafee5f

Please sign in to comment.