From e97a85f461eeb9a0f79ddc9919f811f6617c1b82 Mon Sep 17 00:00:00 2001 From: David An Date: Mon, 4 Dec 2023 10:43:33 -0500 Subject: [PATCH] AJ-1496: remove /api/duos/consent/orsp/{orspId} API (#1249) --- .../firecloud-orchestration.conf.ctmpl | 1 - src/main/resources/swagger/api-docs.yaml | 36 -- .../dsde/firecloud/Application.scala | 1 - .../broadinstitute/dsde/firecloud/Boot.scala | 3 +- .../dsde/firecloud/FireCloudConfig.scala | 1 - .../dsde/firecloud/HealthChecks.scala | 1 - .../firecloud/dataaccess/ConsentDAO.scala | 21 -- .../firecloud/dataaccess/HttpConsentDAO.scala | 31 -- .../dataaccess/ReportsSubsystemStatus.scala | 39 +-- .../dsde/firecloud/model/DUOS.scala | 119 ------- .../firecloud/model/ModelJsonProtocol.scala | 30 +- .../dsde/firecloud/model/SystemStatus.scala | 1 - .../service/DataUseRestrictionSupport.scala | 72 ---- .../firecloud/service/LibraryService.scala | 11 +- .../service/LibraryServiceSupport.scala | 57 +--- .../service/WorkspacePublishingSupport.scala | 14 +- .../firecloud/service/WorkspaceService.scala | 12 +- .../webservice/LibraryApiService.scala | 11 +- src/test/resources/reference.conf | 1 - .../dsde/firecloud/EntityServiceSpec.scala | 4 +- .../firecloud/dataaccess/MockConsentDAO.scala | 35 -- .../DataUseRestrictionSearchSpec.scala | 4 +- .../dsde/firecloud/model/DuosModelSpec.scala | 237 ------------- .../firecloud/service/BaseServiceSpec.scala | 3 +- .../DataUseRestrictionSupportSpec.scala | 312 ------------------ .../service/LibraryServiceSpec.scala | 129 +------- .../firecloud/service/UserServiceSpec.scala | 2 +- .../service/WorkspaceServiceSpec.scala | 2 +- .../firecloud/utils/ConsentStatusSpec.scala | 89 ----- .../firecloud/webservice/ApiServiceSpec.scala | 3 +- .../webservice/LibraryApiServiceSpec.scala | 57 +--- .../webservice/NihApiServiceSpec.scala | 4 +- .../webservice/PermissionReportApiSpec.scala | 2 +- .../webservice/StatusApiServiceSpec.scala | 2 +- 34 files changed, 65 insertions(+), 1282 deletions(-) delete mode 100644 src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/ConsentDAO.scala delete mode 100644 src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/HttpConsentDAO.scala delete mode 100644 src/main/scala/org/broadinstitute/dsde/firecloud/model/DUOS.scala delete mode 100644 src/test/scala/org/broadinstitute/dsde/firecloud/dataaccess/MockConsentDAO.scala delete mode 100644 src/test/scala/org/broadinstitute/dsde/firecloud/model/DuosModelSpec.scala delete mode 100644 src/test/scala/org/broadinstitute/dsde/firecloud/utils/ConsentStatusSpec.scala diff --git a/local-dev/templates/firecloud-orchestration.conf.ctmpl b/local-dev/templates/firecloud-orchestration.conf.ctmpl index cfe029bb6..80da392cd 100644 --- a/local-dev/templates/firecloud-orchestration.conf.ctmpl +++ b/local-dev/templates/firecloud-orchestration.conf.ctmpl @@ -122,7 +122,6 @@ elasticsearch { } duos { - baseConsentUrl = "https://consent.dsde-dev.broadinstitute.org" baseOntologyUrl = "https://consent-ontology.dsde-dev.broadinstitute.org" dulvn = 4 } diff --git a/src/main/resources/swagger/api-docs.yaml b/src/main/resources/swagger/api-docs.yaml index f2c0fbced..85bd3ea78 100755 --- a/src/main/resources/swagger/api-docs.yaml +++ b/src/main/resources/swagger/api-docs.yaml @@ -5540,42 +5540,6 @@ paths: content: {} x-passthrough: false x-codegen-request-body-name: body - /api/duos/consent/orsp/{orspId}: - get: - tags: - - Library - summary: Find Consent by ORSP ID - operationId: duosConsentOrspId - parameters: - - name: orspId - in: path - description: Finds the consent for the provided ORSP ID. - required: true - schema: - type: string - responses: - 200: - description: Consent - content: - application/json: - schema: - $ref: '#/components/schemas/Consent' - 400: - description: The consent associated with the provided name has not been - approved. - content: {} - 401: - description: Invalid authorization, must be a Terra user. - content: {} - 404: - description: The consent associated with the provided name could not be - found. - content: {} - 500: - description: Internal Server Error - content: {} - x-passthrough: true - x-passthrough-target: consent /error: get: tags: diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/Application.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/Application.scala index aacc1b065..1496999db 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/Application.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/Application.scala @@ -9,7 +9,6 @@ import org.broadinstitute.dsde.firecloud.dataaccess._ case class Application(agoraDAO: AgoraDAO, googleServicesDAO: GoogleServicesDAO, ontologyDAO: OntologyDAO, - consentDAO: ConsentDAO, rawlsDAO: RawlsDAO, samDAO: SamDAO, searchDAO: SearchDAO, diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/Boot.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/Boot.scala index b9877907e..b0e18a285 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/Boot.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/Boot.scala @@ -31,14 +31,13 @@ object Boot extends App with LazyLogging { val thurloeDAO:ThurloeDAO = new HttpThurloeDAO val googleServicesDAO:GoogleServicesDAO = new HttpGoogleServicesDAO(FireCloudConfig.GoogleCloud.priceListUrl, GooglePriceList(GooglePrices(FireCloudConfig.GoogleCloud.defaultStoragePriceList, UsTieredPriceItem(FireCloudConfig.GoogleCloud.defaultEgressPriceList)), "v1", "1")) val ontologyDAO:OntologyDAO = new ElasticSearchOntologyDAO(elasticSearchClient, FireCloudConfig.ElasticSearch.ontologyIndexName) - val consentDAO:ConsentDAO = new HttpConsentDAO val researchPurposeSupport:ResearchPurposeSupport = new ESResearchPurposeSupport(ontologyDAO) val searchDAO:SearchDAO = new ElasticSearchDAO(elasticSearchClient, FireCloudConfig.ElasticSearch.indexName, researchPurposeSupport) val shareLogDAO:ShareLogDAO = new ElasticSearchShareLogDAO(elasticSearchClient, FireCloudConfig.ElasticSearch.shareLogIndexName) val importServiceDAO:ImportServiceDAO = new HttpImportServiceDAO val shibbolethDAO:ShibbolethDAO = new HttpShibbolethDAO - val app:Application = Application(agoraDAO, googleServicesDAO, ontologyDAO, consentDAO, rawlsDAO, samDAO, searchDAO, researchPurposeSupport, thurloeDAO, shareLogDAO, importServiceDAO, shibbolethDAO); + val app:Application = Application(agoraDAO, googleServicesDAO, ontologyDAO, rawlsDAO, samDAO, searchDAO, researchPurposeSupport, thurloeDAO, shareLogDAO, importServiceDAO, shibbolethDAO); val agoraPermissionServiceConstructor: (UserInfo) => AgoraPermissionService = AgoraPermissionService.constructor(app) val exportEntitiesByTypeActorConstructor: (ExportEntitiesByTypeArguments) => ExportEntitiesByTypeActor = ExportEntitiesByTypeActor.constructor(app, system) diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/FireCloudConfig.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/FireCloudConfig.scala index fac014ce9..c505ce4c8 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/FireCloudConfig.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/FireCloudConfig.scala @@ -183,7 +183,6 @@ object FireCloudConfig { object Duos { private val duos = config.getConfig("duos") - val baseConsentUrl = duos.getString("baseConsentUrl") val baseOntologyUrl = duos.getString("baseOntologyUrl") val dulvn = duos.getInt("dulvn") } diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/HealthChecks.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/HealthChecks.scala index 375fdbd11..953a6a7ca 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/HealthChecks.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/HealthChecks.scala @@ -22,7 +22,6 @@ class HealthChecks(app: Application, registerSAs: Boolean = true) def healthMonitorChecks: () => Map[Subsystem, Future[SubsystemStatus]] = () => { Map( Agora -> app.agoraDAO.status, - Consent -> app.consentDAO.status, GoogleBuckets -> app.googleServicesDAO.status, LibraryIndex -> app.searchDAO.status, OntologyIndex -> app.ontologyDAO.status, diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/ConsentDAO.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/ConsentDAO.scala deleted file mode 100644 index aa4de5d44..000000000 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/ConsentDAO.scala +++ /dev/null @@ -1,21 +0,0 @@ -package org.broadinstitute.dsde.firecloud.dataaccess - -import org.broadinstitute.dsde.firecloud.model.DUOS.DuosDataUse -import org.broadinstitute.dsde.firecloud.model.WithAccessToken -import org.broadinstitute.dsde.rawls.model.ErrorReportSource - -import scala.concurrent.Future - -object ConsentDAO { - lazy val serviceName = "Consent" -} - -trait ConsentDAO extends ReportsSubsystemStatus { - - implicit val errorReportSource: ErrorReportSource = ErrorReportSource(ConsentDAO.serviceName) - - override def serviceName:String = ConsentDAO.serviceName - - def getRestriction(orspId: String)(implicit userInfo: WithAccessToken): Future[Option[DuosDataUse]] - -} \ No newline at end of file diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/HttpConsentDAO.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/HttpConsentDAO.scala deleted file mode 100644 index aa24dad03..000000000 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/HttpConsentDAO.scala +++ /dev/null @@ -1,31 +0,0 @@ -package org.broadinstitute.dsde.firecloud.dataaccess - -import akka.actor.ActorSystem -import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport -import akka.http.scaladsl.model.Uri -import akka.http.scaladsl.model.Uri.Query -import akka.stream.Materializer -import org.broadinstitute.dsde.firecloud.FireCloudConfig -import org.broadinstitute.dsde.firecloud.model.DUOS.{Consent, DuosDataUse} -import org.broadinstitute.dsde.firecloud.model.ModelJsonProtocol.impDuosConsent -import org.broadinstitute.dsde.firecloud.model.WithAccessToken -import org.broadinstitute.dsde.firecloud.utils.RestJsonClient -import org.broadinstitute.dsde.workbench.util.health.SubsystemStatus - -import scala.concurrent.{ExecutionContext, Future} - -class HttpConsentDAO(implicit val system: ActorSystem, implicit val executionContext: ExecutionContext, implicit val materializer: Materializer) - extends ConsentDAO with SprayJsonSupport with RestJsonClient { - - private val consentUri = Uri(FireCloudConfig.Duos.baseConsentUrl) - - override def getRestriction(orspId: String)(implicit userInfo: WithAccessToken): Future[Option[DuosDataUse]] = { - val consentUrl = FireCloudConfig.Duos.baseConsentUrl + "/api/consent" - val req = Get(Uri(consentUrl).withQuery(Query(("name", orspId)))) - authedRequestToObject[Consent](req) map (_.dataUse) - } - - override def status: Future[SubsystemStatus] = { - getStatusFromDropwizardChecks(unAuthedRequest(Get(consentUri.withPath(Uri.Path("/status"))))) - } -} diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/ReportsSubsystemStatus.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/ReportsSubsystemStatus.scala index 69d744a77..99527f05a 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/ReportsSubsystemStatus.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/dataaccess/ReportsSubsystemStatus.scala @@ -1,18 +1,9 @@ package org.broadinstitute.dsde.firecloud.dataaccess import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport -import akka.http.scaladsl.model.HttpResponse -import akka.http.scaladsl.unmarshalling.Unmarshal -import akka.http.scaladsl.unmarshalling._ -import akka.stream.Materializer -import org.broadinstitute.dsde.firecloud.model.DUOS.ConsentStatus -import org.broadinstitute.dsde.firecloud.model.DropwizardHealth -import org.broadinstitute.dsde.firecloud.model.ModelJsonProtocol.{impDuosConsentStatus, impDropwizardHealth} import org.broadinstitute.dsde.workbench.util.health.SubsystemStatus -import spray.json.DefaultJsonProtocol._ -import spray.json._ -import scala.concurrent.{ExecutionContext, Future} +import scala.concurrent.Future /** * Created by anichols on 4/21/17. @@ -22,32 +13,4 @@ trait ReportsSubsystemStatus extends SprayJsonSupport { def status: Future[SubsystemStatus] def serviceName: String - - def getStatusFromDropwizardChecks(response: Future[HttpResponse])(implicit ec: ExecutionContext, materializer: Materializer): Future[SubsystemStatus] = { - response flatMap { resp => - Unmarshal(resp).to[ConsentStatus].map { status => - val ok = status.ok.get - val errors = status.systems.get. - filter(dw => !dw._2.healthy). - map(dw => s"Error in ${dw._1}: ${dw._2.message.getOrElse("unspecified error")}").toList - if (ok) - SubsystemStatus(ok, None) - else - SubsystemStatus(ok, Some(errors)) - }.recoverWith { - case _: Throwable => - Unmarshal(resp).to[Map[String, DropwizardHealth]].map { dwStatus => - val ok = dwStatus.values.forall(_.healthy) - val errors = dwStatus. - filter(dw => !dw._2.healthy). - map(dw => s"Error in ${dw._1}: ${dw._2.message.getOrElse("unspecified error")}").toList - if (ok) - SubsystemStatus(ok, None) - else - SubsystemStatus(ok, Some(errors)) - } - } - } - } - } diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/model/DUOS.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/model/DUOS.scala deleted file mode 100644 index 773a4476a..000000000 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/model/DUOS.scala +++ /dev/null @@ -1,119 +0,0 @@ -package org.broadinstitute.dsde.firecloud.model - -import spray.json._ -import spray.json.{JsObject, JsValue} - -object DUOS { - - case class DuosDataUse( - generalUse: Option[Boolean] = None, - hmbResearch: Option[Boolean] = None, - diseaseRestrictions: Option[Seq[String]] = None, - populationOriginsAncestry: Option[Boolean] = None, - populationStructure: Option[Boolean] = None, - commercialUse: Option[Boolean] = None, - methodsResearch: Option[Boolean] = None, - aggregateResearch: Option[String] = None, - controlSetOption: Option[String] = None, - gender: Option[String] = None, - pediatric: Option[Boolean] = None, - populationRestrictions: Option[Seq[String]] = None, - dateRestriction: Option[String] = None, - recontactingDataSubjects: Option[Boolean] = None, - recontactMay: Option[String] = None, - recontactMust: Option[String] = None, - genomicPhenotypicData: Option[String] = None, - otherRestrictions: Option[Boolean] = None, - cloudStorage: Option[String] = None, - ethicsApprovalRequired: Option[Boolean] = None, - geographicalRestrictions: Option[String] = None, - other: Option[String] = None, - illegalBehavior: Option[Boolean] = None, - addiction: Option[Boolean] = None, - sexualDiseases: Option[Boolean] = None, - stigmatizeDiseases: Option[Boolean] = None, - vulnerablePopulations: Option[Boolean] = None, - psychologicalTraits: Option[Boolean] = None, - nonBiomedical: Option[Boolean] = None - ) - - object DuosDataUse { - def apply(jsValues: Map[String, JsValue]): DuosDataUse = { - def getBoolean(f: String): Option[Boolean] = { - jsValues.get(f) match { - case Some(b: JsBoolean) => Some(b.value) - case _ => None - } - } - def getSeqString(f: String): Option[Seq[String]] = { - jsValues.get(f) match { - case Some(l: JsArray) => Some(l.elements.collect { case s: JsString => s.value }) - case _ => None - } - } - def getString(f: String): Option[String] = { - jsValues.get(f) match { - case Some(s: JsString) => Some(s.value) - case _ => None - } - } - new DuosDataUse( - generalUse = getBoolean("generalUse"), - hmbResearch = getBoolean("hmbResearch"), - diseaseRestrictions = getSeqString("diseaseRestrictions"), - populationOriginsAncestry = getBoolean("populationOriginsAncestry"), - populationStructure = getBoolean("populationStructure"), - commercialUse = getBoolean("commercialUse"), - methodsResearch = getBoolean("methodsResearch"), - aggregateResearch = getString("aggregateResearch"), - controlSetOption = getString("controlSetOption"), - gender = getString("gender"), - pediatric = getBoolean("pediatric"), - populationRestrictions = getSeqString("populationRestrictions"), - dateRestriction = getString("dateRestriction"), - recontactingDataSubjects = getBoolean("recontactingDataSubjects"), - recontactMay = getString("recontactMay"), - recontactMust = getString("recontactMust"), - genomicPhenotypicData = getString("genomicPhenotypicData"), - otherRestrictions = getBoolean("otherRestrictions"), - cloudStorage = getString("cloudStorage"), - ethicsApprovalRequired = getBoolean("ethicsApprovalRequired"), - geographicalRestrictions = getString("geographicalRestrictions"), - other = getString("other"), - illegalBehavior = getBoolean("illegalBehavior"), - addiction = getBoolean("addiction"), - sexualDiseases = getBoolean("sexualDiseases"), - stigmatizeDiseases = getBoolean("stigmatizeDiseases"), - vulnerablePopulations = getBoolean("vulnerablePopulations"), - psychologicalTraits = getBoolean("psychologicalTraits"), - nonBiomedical = getBoolean("nonBiomedical") - ) - } - } - - case class Consent( - consentId: String, - name: String, - createDate: Option[Long] = None, - lastUpdate: Option[Long] = None, - sortDate: Option[Long] = None, - requiresManualReview: Option[Boolean] = None, - dataUseLetter: Option[String] = None, - useRestriction: Option[JsObject] = None, - dulName: Option[String] = None, - translatedUseRestriction: Option[String] = None, - dataUse: Option[DuosDataUse] = None - ) - - case class ConsentError( - message: String, - code: Int - ) - - case class ConsentStatus( - ok: Option[Boolean], - degraded: Option[Boolean], - systems: Option[Map[String, DropwizardHealth]] - ) - -} diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/model/ModelJsonProtocol.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/model/ModelJsonProtocol.scala index 804d106d0..65d47cd41 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/model/ModelJsonProtocol.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/model/ModelJsonProtocol.scala @@ -5,7 +5,6 @@ import akka.http.scaladsl.model.StatusCode import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.{MalformedRequestContentRejection, RejectionHandler} -import org.broadinstitute.dsde.firecloud.model.DUOS._ import org.broadinstitute.dsde.firecloud.model.DataUse._ import org.broadinstitute.dsde.firecloud.model.ManagedGroupRoles.ManagedGroupRole import org.broadinstitute.dsde.firecloud.model.OrchMethodRepository._ @@ -20,7 +19,7 @@ import org.broadinstitute.dsde.rawls.model._ import org.broadinstitute.dsde.workbench.model.ValueObjectFormat import org.broadinstitute.dsde.workbench.model.WorkbenchIdentityJsonSupport._ import org.broadinstitute.dsde.workbench.model.google.GoogleModelJsonSupport.InstantFormat -import spray.json.{JsString, _} +import spray.json._ import scala.util.{Failure, Success, Try} @@ -279,38 +278,11 @@ object ModelJsonProtocol extends WorkspaceJsonSupport with SprayJsonSupport { implicit val impStructuredDataRequest: RootJsonFormat[StructuredDataRequest] = jsonFormat12(StructuredDataRequest) implicit val impStructuredDataResponse: RootJsonFormat[StructuredDataResponse] = jsonFormat4(StructuredDataResponse) - implicit object impDuosDataUse extends RootJsonFormat[DuosDataUse] { - override def write(ddu: DuosDataUse): JsValue = { - val existingProps: Seq[(String, JsValue)] = Try(ddu.getClass.getDeclaredFields.map { f => - f.setAccessible(true) - f.get(ddu) match { - case Some(x: Boolean) => f.getName -> x.toJson - case Some(y: String) => f.getName -> y.toJson - case Some((h: String) :: tail) => f.getName -> (h +: tail.collect { case z: String => z }).toJson - case _ => f.getName -> JsNull - } - }) match { - case Success(props) => props.toIndexedSeq.filterNot(_._2 == JsNull) - case Failure(ex) => serializationError(ex.getMessage) - } - JsObject(existingProps.toMap) - } - override def read(json: JsValue): DuosDataUse = { - Try(DuosDataUse.apply(json.asJsObject.fields)) match { - case Success(ddu) => ddu - case Failure(ex) => deserializationError(s"Could not read DuosDataUse value: $json", ex) - } - } - } - implicit val impDuosConsent: RootJsonFormat[Consent] = jsonFormat11(Consent) - implicit val impDuosConsentError: RootJsonFormat[ConsentError] = jsonFormat2(ConsentError) implicit val impOntologyTermParent: RootJsonFormat[TermParent] = jsonFormat5(TermParent) implicit val impOntologyTermResource: RootJsonFormat[TermResource] = jsonFormat7(TermResource) implicit val impOntologyESTermParent: RootJsonFormat[ESTermParent] = jsonFormat2(ESTermParent) implicit val impThurloeStatus: RootJsonFormat[ThurloeStatus] = jsonFormat2(ThurloeStatus) - implicit val impDropwizardHealth: RootJsonFormat[DropwizardHealth] = jsonFormat2(DropwizardHealth) - implicit val impDuosConsentStatus: RootJsonFormat[ConsentStatus] = jsonFormat3(ConsentStatus) // don't make this implicit! It would be pulled in by anything including ModelJsonProtocol._ val entityExtractionRejectionHandler = RejectionHandler.newBuilder().handle { diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/model/SystemStatus.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/model/SystemStatus.scala index 204a5da8b..cdf214b75 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/model/SystemStatus.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/model/SystemStatus.scala @@ -4,4 +4,3 @@ package org.broadinstitute.dsde.firecloud.model * Created by anichols on 4/7/17. */ case class ThurloeStatus(status: String, error: Option[String]) -case class DropwizardHealth(healthy: Boolean, message: Option[String]) diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/service/DataUseRestrictionSupport.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/service/DataUseRestrictionSupport.scala index c4c5d3242..8822cd86d 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/service/DataUseRestrictionSupport.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/service/DataUseRestrictionSupport.scala @@ -4,7 +4,6 @@ import com.typesafe.scalalogging.LazyLogging import org.broadinstitute.dsde.firecloud.{FireCloudConfig, FireCloudException} import org.broadinstitute.dsde.firecloud.dataaccess.OntologyDAO import org.broadinstitute.dsde.firecloud.model.{ConsentCodes} -import org.broadinstitute.dsde.firecloud.model.DUOS.DuosDataUse import org.broadinstitute.dsde.firecloud.model.DataUse._ import org.broadinstitute.dsde.rawls.model.Attributable.AttributeMap import org.broadinstitute.dsde.rawls.model.WorkspaceJsonSupport.AttributeNameFormat @@ -114,77 +113,6 @@ trait DataUseRestrictionSupport extends LazyLogging { Map(AttributeName.withDefaultNS(ConsentCodes.DSURL) -> AttributeValueList(request.diseaseUseRequired.toIndexedSeq.map(AttributeString(_)))) } - - /** - * Looks at a DuosDataUse object (likely previously retrieved from ORSP) and translates it into a - * set of structured Data Use Restriction attributes. - * - * @param duosDataUse - * @return - */ - def generateStructuredUseRestrictionAttribute(duosDataUse: DuosDataUse, ontologyDAO: OntologyDAO): Map[AttributeName, Attribute] = { - // these are straightforward mappings - val gru = duosDataUse.generalUse.map ( AttributeName.withLibraryNS(ConsentCodes.GRU) -> AttributeBoolean(_) ) - val hmb = duosDataUse.hmbResearch.map ( AttributeName.withLibraryNS(ConsentCodes.HMB) -> AttributeBoolean(_) ) - val rspd = duosDataUse.pediatric.map ( AttributeName.withLibraryNS(ConsentCodes.RSPD) -> AttributeBoolean(_) ) - val ncu = duosDataUse.commercialUse.map ( AttributeName.withLibraryNS(ConsentCodes.NCU) -> AttributeBoolean(_) ) - val nmds = duosDataUse.methodsResearch.map ( AttributeName.withLibraryNS(ConsentCodes.NMDS) -> AttributeBoolean(_) ) - - // FC supports both NCU and NPU; DUOS only supports one (NCU) - // val npu = duosDataUse.commercialUse.map ( AttributeName.withLibraryNS("NPU") -> AttributeBoolean(_) ) - - // DUOS represents NAGR and NCTRL as strings ("yes"|"no") - val nagr = duosDataUse.aggregateResearch match { - case Some(s) if "yes".equals(s.toLowerCase) => Some(AttributeName.withLibraryNS(ConsentCodes.NAGR) -> AttributeBoolean(true)) - case Some(s) if "no".equals(s.toLowerCase) => Some(AttributeName.withLibraryNS(ConsentCodes.NAGR) -> AttributeBoolean(false)) - case _ => None - } - val nctrl = duosDataUse.controlSetOption match { - case Some(s) if "yes".equals(s.toLowerCase) => Some(AttributeName.withLibraryNS(ConsentCodes.NCTRL) -> AttributeBoolean(true)) - case Some(s) if "no".equals(s.toLowerCase) => Some(AttributeName.withLibraryNS(ConsentCodes.NCTRL) -> AttributeBoolean(false)) - case _ => None - } - - // DUOS has no concept of "IRB review required" - // val irb = None - - // disease restrictions: DS, DS_URL - val ds = duosDataUse.diseaseRestrictions match { - case Some(Seq()) => Map.empty[AttributeName,Attribute] - case Some(nodeList) => - Map( - AttributeName.withLibraryNS(ConsentCodes.DSURL) -> AttributeValueList(nodeList.map( AttributeString )), - AttributeName.withLibraryNS(ConsentCodes.DS) -> AttributeValueList(nodeList.map{ nodeid => - ontologyDAO.search(nodeid) match { - case termResource :: Nil => AttributeString(termResource.label) - case _ => AttributeString(nodeid) - }}) - ) - case _ => Map.empty[AttributeName,Attribute] - } - - // gender restrictions: RS-G, RS-FM, RS-M - val rsg = duosDataUse.gender match { - case Some(f:String) if "female".equals(f.toLowerCase) => Map( - AttributeName.withLibraryNS("RS-G") -> AttributeBoolean(true), - AttributeName.withLibraryNS("RS-FM") -> AttributeBoolean(true) - ) - case Some(m:String) if "male".equals(m.toLowerCase) => Map( - AttributeName.withLibraryNS("RS-G") -> AttributeBoolean(true), - AttributeName.withLibraryNS("RS-M") -> AttributeBoolean(true) - ) - case _ => Map.empty[AttributeName,Attribute] - } - - val result = Map.empty[AttributeName, Attribute] ++ gru ++ hmb ++ ncu ++ nmds ++ - rspd ++ nagr ++ nctrl ++ ds ++ rsg // ++ npu ++ irb - - logger.debug("inbound DuosDataUse: " + duosDataUse) - logger.debug("outbound attrs: " + result) - - result - } - /** * Create a display-friendly version of the structured data use restriction in the form of a * list of code strings. diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/service/LibraryService.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/service/LibraryService.scala index db7d206a2..992af3919 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/service/LibraryService.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/service/LibraryService.scala @@ -31,7 +31,7 @@ object LibraryService { final val schemaLocation = "library/attribute-definitions.json" def constructor(app: Application)(userInfo: UserInfo)(implicit executionContext: ExecutionContext) = - new LibraryService(userInfo, app.rawlsDAO, app.samDAO, app.searchDAO, app.ontologyDAO, app.consentDAO) + new LibraryService(userInfo, app.rawlsDAO, app.samDAO, app.searchDAO, app.ontologyDAO) } @@ -39,8 +39,7 @@ class LibraryService (protected val argUserInfo: UserInfo, val rawlsDAO: RawlsDAO, val samDao: SamDAO, val searchDAO: SearchDAO, - val ontologyDAO: OntologyDAO, - val consentDAO: ConsentDAO) + val ontologyDAO: OntologyDAO) (implicit protected val executionContext: ExecutionContext) extends LibraryServiceSupport with AttributeSupport with PermissionsSupport with SprayJsonSupport with LazyLogging with WorkspacePublishingSupport { lazy val log = LoggerFactory.getLogger(getClass) @@ -142,7 +141,7 @@ class LibraryService (protected val argUserInfo: UserInfo, private def internalPatchWorkspaceAndRepublish(ns: String, name: String, allOperations: Seq[AttributeUpdateOperation], isPublished: Boolean): Future[WorkspaceDetails] = { for { newws <- rawlsDAO.updateLibraryAttributes(ns, name, allOperations) - _ <- republishDocument(newws, ontologyDAO, searchDAO, consentDAO) + _ <- republishDocument(newws, ontologyDAO, searchDAO) } yield newws } @@ -164,7 +163,7 @@ class LibraryService (protected val argUserInfo: UserInfo, Future(RequestCompleteWithErrorReport(BadRequest, errorMessage.getOrElse(BadRequest.defaultMessage))) else { // user requested a change in published flag, and metadata is valid; make the change. - setWorkspacePublishedStatus(workspaceResponse.workspace, publishArg, rawlsDAO, ontologyDAO, searchDAO, consentDAO) map { ws => + setWorkspacePublishedStatus(workspaceResponse.workspace, publishArg, rawlsDAO, ontologyDAO, searchDAO) map { ws => RequestComplete(ws) } } @@ -179,7 +178,7 @@ class LibraryService (protected val argUserInfo: UserInfo, Future(RequestComplete(NoContent)) else { logger.info("reindex: requesting ontology parents for workspaces ...") - val toIndex: Future[Seq[Document]] = indexableDocuments(workspaces, ontologyDAO, consentDAO) + val toIndex: Future[Seq[Document]] = indexableDocuments(workspaces, ontologyDAO) toIndex map { documents => logger.info("reindex: resetting index ...") searchDAO.recreateIndex() diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/service/LibraryServiceSupport.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/service/LibraryServiceSupport.scala index e8c853033..ac07de901 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/service/LibraryServiceSupport.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/service/LibraryServiceSupport.scala @@ -2,9 +2,7 @@ package org.broadinstitute.dsde.firecloud.service import com.typesafe.scalalogging.LazyLogging import org.broadinstitute.dsde.firecloud.FireCloudConfig -import org.broadinstitute.dsde.firecloud.dataaccess.{ConsentDAO, OntologyDAO, RawlsDAO, SamDAO} -import org.broadinstitute.dsde.firecloud.model.DUOS.DuosDataUse -import org.broadinstitute.dsde.firecloud.model.DataUse._ +import org.broadinstitute.dsde.firecloud.dataaccess.{OntologyDAO, SamDAO} import org.broadinstitute.dsde.firecloud.model.ModelJsonProtocol._ import org.broadinstitute.dsde.firecloud.model.Ontology.TermParent import org.broadinstitute.dsde.firecloud.model.{ConsentCodes, Document, ElasticSearch, UserInfo, WithAccessToken} @@ -36,51 +34,32 @@ trait LibraryServiceSupport extends DataUseRestrictionSupport with LazyLogging { else Seq(RemoveAttribute(LibraryService.publishedFlag)) } - def indexableDocuments(workspaces: Seq[WorkspaceDetails], ontologyDAO: OntologyDAO, consentDAO: ConsentDAO)(implicit userToken: WithAccessToken, ec: ExecutionContext): Future[Seq[Document]] = { + def indexableDocuments(workspaces: Seq[WorkspaceDetails], ontologyDAO: OntologyDAO)(implicit userToken: WithAccessToken, ec: ExecutionContext): Future[Seq[Document]] = { // find all the ontology nodes in this list of workspaces val nodes = uniqueWorkspaceStringAttributes(workspaces, AttributeName.withLibraryNS("diseaseOntologyID")) // query ontology for this set of nodes, save in a map - val parentCache = nodes map {id => (id, lookupParentNodes(id, ontologyDAO))} + val parentCache = nodes map { id => (id, lookupParentNodes(id, ontologyDAO)) } val parentMap = parentCache.toMap.filter(e => e._2.nonEmpty) // remove nodes that have no parent logger.debug(s"have parent results for ${parentMap.size} ontology nodes") - // identify the unique ORSP codes in this list of workspaces - val orspIds = uniqueWorkspaceStringAttributes(workspaces, orspIdAttribute) - - // set up an exception-resilient Future to get the ORSP restrictions for those codes - val futureRestrictions:Future[Set[(String, Option[DuosDataUse])]] = Future.sequence(orspIds map {orspId => - consentDAO.getRestriction(orspId) map { restriction => - orspId -> restriction - } recover { - case e:Exception => - // content owners regularly publish datasets that reference an orspId that has yet to be approved - // or even doesn't exist yet. Therefore, this exception case is benign. - logger.info(e.getMessage) - orspId -> None + // as of Nov 27 2023 (actually "some time ago" before that), the DUOS/Consent system no longer supports + // lookup of ORSP ids; these lookups will always return 404. The code below previously looked up DU attributes + // from consent for a given ORSP id and updated the workspace attributes with consent's result. Now, the code + // simply updates workspace attributes with a Map.empty, reflecting the fact that consent always 404s. + val annotatedWorkspaces = workspaces map { ws => + // does this workspace have an orsp id? + ws.attributes.getOrElse(Map.empty).get(orspIdAttribute) match { + case Some(_) => + // if so, remove explicit DU attributes + val newAttrs = replaceDataUseAttributes(ws.attributes.getOrElse(Map.empty), Map.empty[AttributeName, Attribute]) + ws.copy(attributes = Option(newAttrs)) + case _ => + // this workspace does not have an ORSP id; leave it untouched + ws } - }) - - futureRestrictions.map { restrictions => - val restrictionMap:Map[String,AttributeMap] = restrictions.map { - case (orspId, None) => orspId -> Map.empty[AttributeName, Attribute] - case (orspId, Some(dataUse)) => orspId -> generateStructuredUseRestrictionAttribute(dataUse, ontologyDAO) - }.toMap - - val annotatedWorkspaces = workspaces map { ws => - // does this workspace have an orsp id? - ws.attributes.getOrElse(Map.empty).get(orspIdAttribute) match { - case Some(s:AttributeString) => - val orspAttrs = restrictionMap.getOrElse(s.value, Map.empty[AttributeName, Attribute]) - val newAttrs = replaceDataUseAttributes(ws.attributes.getOrElse(Map.empty), orspAttrs) - ws.copy(attributes = Option(newAttrs)) - case _ => - // this workspace does not have an ORSP id; leave it untouched - ws - } - } - annotatedWorkspaces map {w => indexableDocument(w, parentMap, ontologyDAO)} } + Future.successful(annotatedWorkspaces map { w => indexableDocument(w, parentMap, ontologyDAO) }) } private def indexableDocument(workspace: WorkspaceDetails, parentCache: Map[String,Seq[TermParent]], ontologyDAO: OntologyDAO)(implicit ec: ExecutionContext): Document = { diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/service/WorkspacePublishingSupport.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/service/WorkspacePublishingSupport.scala index cc7e39068..69cddf55b 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/service/WorkspacePublishingSupport.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/service/WorkspacePublishingSupport.scala @@ -1,7 +1,7 @@ package org.broadinstitute.dsde.firecloud.service import org.broadinstitute.dsde.firecloud.FireCloudException -import org.broadinstitute.dsde.firecloud.dataaccess.{ConsentDAO, OntologyDAO, RawlsDAO, SearchDAO} +import org.broadinstitute.dsde.firecloud.dataaccess.{OntologyDAO, RawlsDAO, SearchDAO} import org.broadinstitute.dsde.firecloud.model.WithAccessToken import org.broadinstitute.dsde.firecloud.service.LibraryService.publishedFlag import org.broadinstitute.dsde.rawls.model._ @@ -15,8 +15,8 @@ trait WorkspacePublishingSupport extends LibraryServiceSupport { implicit val userToken: WithAccessToken - def publishDocument(ws: WorkspaceDetails, ontologyDAO: OntologyDAO, searchDAO: SearchDAO, consentDAO: ConsentDAO)(implicit userToken: WithAccessToken): Future[Unit] = { - indexableDocuments(Seq(ws), ontologyDAO, consentDAO) map { ws => + def publishDocument(ws: WorkspaceDetails, ontologyDAO: OntologyDAO, searchDAO: SearchDAO)(implicit userToken: WithAccessToken): Future[Unit] = { + indexableDocuments(Seq(ws), ontologyDAO) map { ws => assert(ws.size == 1) searchDAO.indexDocument(ws.head) } @@ -26,11 +26,11 @@ trait WorkspacePublishingSupport extends LibraryServiceSupport { searchDAO.deleteDocument(ws.workspaceId) } - def republishDocument(ws: WorkspaceDetails, ontologyDAO: OntologyDAO, searchDAO: SearchDAO, consentDAO: ConsentDAO)(implicit userToken: WithAccessToken): Future[Unit] = { + def republishDocument(ws: WorkspaceDetails, ontologyDAO: OntologyDAO, searchDAO: SearchDAO)(implicit userToken: WithAccessToken): Future[Unit] = { if (isPublished(ws)) { // if already published, republish // we do not need to delete before republish - publishDocument(ws, ontologyDAO, searchDAO, consentDAO) + publishDocument(ws, ontologyDAO, searchDAO) } else { Future.successful(()) } @@ -44,10 +44,10 @@ trait WorkspacePublishingSupport extends LibraryServiceSupport { workspace.attributes.getOrElse(Map.empty).get(publishedFlag).fold(false)(_.asInstanceOf[AttributeBoolean].value) } - def setWorkspacePublishedStatus(ws: WorkspaceDetails, publishArg: Boolean, rawlsDAO: RawlsDAO, ontologyDAO: OntologyDAO, searchDAO: SearchDAO, consentDAO: ConsentDAO)(implicit userToken: WithAccessToken): Future[WorkspaceDetails] = { + def setWorkspacePublishedStatus(ws: WorkspaceDetails, publishArg: Boolean, rawlsDAO: RawlsDAO, ontologyDAO: OntologyDAO, searchDAO: SearchDAO)(implicit userToken: WithAccessToken): Future[WorkspaceDetails] = { rawlsDAO.updateLibraryAttributes(ws.namespace, ws.name, updatePublishAttribute(publishArg)) flatMap { workspace => val docPublishFuture = if (publishArg) { - publishDocument(workspace, ontologyDAO, searchDAO, consentDAO) + publishDocument(workspace, ontologyDAO, searchDAO) } else { Future(removeDocument(workspace, searchDAO)) } diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/service/WorkspaceService.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/service/WorkspaceService.scala index b99c0dff0..20d595974 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/service/WorkspaceService.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/service/WorkspaceService.scala @@ -26,10 +26,10 @@ import scala.util.{Failure, Success, Try} */ object WorkspaceService { def constructor(app: Application)(userToken: WithAccessToken)(implicit executionContext: ExecutionContext) = - new WorkspaceService(userToken, app.rawlsDAO, app.samDAO, app.thurloeDAO, app.googleServicesDAO, app.ontologyDAO, app.searchDAO, app.consentDAO, app.shareLogDAO) + new WorkspaceService(userToken, app.rawlsDAO, app.samDAO, app.thurloeDAO, app.googleServicesDAO, app.ontologyDAO, app.searchDAO, app.shareLogDAO) } -class WorkspaceService(protected val argUserToken: WithAccessToken, val rawlsDAO: RawlsDAO, val samDao: SamDAO, val thurloeDAO: ThurloeDAO, val googleServicesDAO: GoogleServicesDAO, val ontologyDAO: OntologyDAO, val searchDAO: SearchDAO, val consentDAO: ConsentDAO, val shareLogDAO: ShareLogDAO) +class WorkspaceService(protected val argUserToken: WithAccessToken, val rawlsDAO: RawlsDAO, val samDao: SamDAO, val thurloeDAO: ThurloeDAO, val googleServicesDAO: GoogleServicesDAO, val ontologyDAO: OntologyDAO, val searchDAO: SearchDAO, val shareLogDAO: ShareLogDAO) (implicit protected val executionContext: ExecutionContext) extends AttributeSupport with TSVFileSupport with PermissionsSupport with WorkspacePublishingSupport with SprayJsonSupport with LazyLogging { implicit val userToken: WithAccessToken = argUserToken @@ -55,7 +55,7 @@ class WorkspaceService(protected val argUserToken: WithAccessToken, val rawlsDAO def updateWorkspaceAttributes(workspaceNamespace: String, workspaceName: String, workspaceUpdateJson: Seq[AttributeUpdateOperation]) = { for { ws <- rawlsDAO.patchWorkspaceAttributes(workspaceNamespace, workspaceName, workspaceUpdateJson) - _ <- republishDocument(ws, ontologyDAO, searchDAO, consentDAO) + _ <- republishDocument(ws, ontologyDAO, searchDAO) } yield RequestComplete(ws) } @@ -66,7 +66,7 @@ class WorkspaceService(protected val argUserToken: WithAccessToken, val rawlsDAO val allOperations = generateAttributeOperations(workspaceResponse.workspace.attributes.getOrElse(Map.empty), newAttributes, _.namespace != AttributeName.libraryNamespace) for { ws <- rawlsDAO.patchWorkspaceAttributes(workspaceNamespace, workspaceName, allOperations) - _ <- republishDocument(ws, ontologyDAO, searchDAO, consentDAO) + _ <- republishDocument(ws, ontologyDAO, searchDAO) } yield RequestComplete(ws) } } @@ -156,7 +156,7 @@ class WorkspaceService(protected val argUserToken: WithAccessToken, val rawlsDAO private def patchAndRepublishWorkspace(workspaceNamespace: String, workspaceName: String, ops: Seq[AttributeUpdateOperation]) = { for { ws <- rawlsDAO.patchWorkspaceAttributes(workspaceNamespace, workspaceName, ops) - _ <- republishDocument(ws, ontologyDAO, searchDAO, consentDAO) + _ <- republishDocument(ws, ontologyDAO, searchDAO) } yield { val tags = getTagsFromWorkspace(ws) RequestComplete(StatusCodes.OK, formatTags(tags)) @@ -181,7 +181,7 @@ class WorkspaceService(protected val argUserToken: WithAccessToken, val rawlsDAO def deleteWorkspace(ns: String, name: String): Future[PerRequestMessage] = { rawlsDAO.getWorkspace(ns, name) flatMap { wsResponse => val unpublishFuture: Future[WorkspaceDetails] = if (isPublished(wsResponse)) - setWorkspacePublishedStatus(wsResponse.workspace, publishArg = false, rawlsDAO, ontologyDAO, searchDAO, consentDAO) + setWorkspacePublishedStatus(wsResponse.workspace, publishArg = false, rawlsDAO, ontologyDAO, searchDAO) else Future.successful(wsResponse.workspace) unpublishFuture flatMap { ws => diff --git a/src/main/scala/org/broadinstitute/dsde/firecloud/webservice/LibraryApiService.scala b/src/main/scala/org/broadinstitute/dsde/firecloud/webservice/LibraryApiService.scala index a1e1ab49e..fa5d886a3 100644 --- a/src/main/scala/org/broadinstitute/dsde/firecloud/webservice/LibraryApiService.scala +++ b/src/main/scala/org/broadinstitute/dsde/firecloud/webservice/LibraryApiService.scala @@ -1,7 +1,6 @@ package org.broadinstitute.dsde.firecloud.webservice import akka.http.scaladsl.model.StatusCodes._ -import akka.http.scaladsl.model.{HttpMethods, StatusCodes, Uri} import akka.http.scaladsl.server.Route import org.broadinstitute.dsde.firecloud.FireCloudConfig import org.broadinstitute.dsde.firecloud.model.DataUse._ @@ -25,8 +24,6 @@ trait LibraryApiService extends FireCloudDirectives val libraryServiceConstructor: UserInfo => LibraryService val ontologyServiceConstructor: () => OntologyService - val consentUrl = FireCloudConfig.Duos.baseConsentUrl + "/api/consent" - val libraryRoutes: Route = pathPrefix("duos") { path("autocomplete" / Segment) { (searchTerm) => @@ -52,18 +49,12 @@ trait LibraryApiService extends FireCloudDirectives pathPrefix("schemas") { path("library-attributedefinitions-v1") { withResourceFileContents(LibraryService.schemaLocation) { jsonContents => - complete(StatusCodes.OK, jsonContents) + complete(OK, jsonContents) } } } ~ pathPrefix("api") { requireUserInfo() { userInfo => - path("duos" / "consent" / "orsp" / Segment) { (orspId) => - get { - //note: not a true passthrough, slight manipulation of the query params here - passthrough(Uri(consentUrl).withQuery(Uri.Query(("name"->orspId))), HttpMethods.GET) - } - } ~ pathPrefix("library") { path("user" / "role" / "curator") { get { requestContext => diff --git a/src/test/resources/reference.conf b/src/test/resources/reference.conf index 6aac417eb..229d3410b 100644 --- a/src/test/resources/reference.conf +++ b/src/test/resources/reference.conf @@ -74,7 +74,6 @@ elasticsearch { } duos { - baseConsentUrl = "http://localhost:8992" baseOntologyUrl = "http://localhost:8993" dulvn = 4 } diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/EntityServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/EntityServiceSpec.scala index 479c5cb5b..b626bb2f4 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/EntityServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/EntityServiceSpec.scala @@ -217,9 +217,7 @@ class EntityServiceSpec extends BaseServiceSpec with BeforeAndAfterEach { private def getEntityService(mockGoogleServicesDAO: MockGoogleServicesDAO = new MockGoogleServicesDAO, mockImportServiceDAO: MockImportServiceDAO = new MockImportServiceDAO, rawlsDAO: MockRawlsDAO = new MockRawlsDAO) = { - val application = app.copy(googleServicesDAO = mockGoogleServicesDAO, - importServiceDAO = mockImportServiceDAO, - rawlsDAO = rawlsDAO) + val application = app.copy(googleServicesDAO = mockGoogleServicesDAO, rawlsDAO = rawlsDAO, importServiceDAO = mockImportServiceDAO) // instantiate an EntityService, specify importServiceDAO and googleServicesDAO implicit val modelSchema: ModelSchema = FirecloudModelSchema diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/dataaccess/MockConsentDAO.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/dataaccess/MockConsentDAO.scala deleted file mode 100644 index 25e89fea9..000000000 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/dataaccess/MockConsentDAO.scala +++ /dev/null @@ -1,35 +0,0 @@ -package org.broadinstitute.dsde.firecloud.dataaccess - -import org.broadinstitute.dsde.firecloud.FireCloudExceptionWithErrorReport -import org.broadinstitute.dsde.firecloud.model.DUOS.DuosDataUse -import org.broadinstitute.dsde.firecloud.model.ErrorReportExtensions.FCErrorReport -import org.broadinstitute.dsde.firecloud.model.WithAccessToken -import org.broadinstitute.dsde.workbench.util.health.SubsystemStatus -import akka.http.scaladsl.model.{HttpResponse, StatusCodes} -import org.broadinstitute.dsde.rawls.model.ErrorReport - -import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent.Future - -class MockConsentDAO extends ConsentDAO { - - - override def getRestriction(orspId: String)(implicit userInfo: WithAccessToken): Future[Option[DuosDataUse]] = { - orspId match { - case "MOCK-111" => - val ddu = new DuosDataUse( - commercialUse = Some(true), - controlSetOption = Some("Yes") - ) - Future.successful(Some(ddu)) - case "MOCK-NOTFOUND" => Future.failed(new FireCloudExceptionWithErrorReport(ErrorReport(StatusCodes.NotFound, "Not Found from Mock"))) - case "MOCK-EXCEPTION" => Future.failed(new FireCloudExceptionWithErrorReport(ErrorReport(StatusCodes.InternalServerError, "Internal Server Error from Mock"))) - case _ => Future.successful(None) - } - - - } - - def status: Future[SubsystemStatus] = Future(SubsystemStatus(ok = true, None)) - -} diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/integrationtest/DataUseRestrictionSearchSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/integrationtest/DataUseRestrictionSearchSpec.scala index afd275608..c2d1dd97f 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/integrationtest/DataUseRestrictionSearchSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/integrationtest/DataUseRestrictionSearchSpec.scala @@ -1,7 +1,7 @@ package org.broadinstitute.dsde.firecloud.integrationtest import akka.stream.Materializer -import org.broadinstitute.dsde.firecloud.dataaccess.{MockConsentDAO, MockOntologyDAO} +import org.broadinstitute.dsde.firecloud.dataaccess.MockOntologyDAO import org.broadinstitute.dsde.firecloud.integrationtest.ESIntegrationSupport._ import org.broadinstitute.dsde.firecloud.model.{AccessToken, LibrarySearchResponse, WithAccessToken} import org.broadinstitute.dsde.firecloud.service.DataUseRestrictionTestFixtures.DataUseRestriction @@ -28,7 +28,7 @@ class DataUseRestrictionSearchSpec extends AnyFreeSpec with SearchResultValidati // make sure we specify refresh=true here; otherwise, the documents may not be available in the index by the // time the tests start, leading to test failures. logger.info("indexing fixtures ...") - val docs = Await.result(indexableDocuments(datasets, new MockOntologyDAO, new MockConsentDAO), dur) + val docs = Await.result(indexableDocuments(datasets, new MockOntologyDAO), dur) searchDAO.bulkIndex(docs, refresh = true) logger.info("... fixtures indexed.") } diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/model/DuosModelSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/model/DuosModelSpec.scala deleted file mode 100644 index 7c199a228..000000000 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/model/DuosModelSpec.scala +++ /dev/null @@ -1,237 +0,0 @@ -package org.broadinstitute.dsde.firecloud.model - -import org.broadinstitute.dsde.firecloud.model.DUOS.DuosDataUse -import org.scalatest.freespec.AnyFreeSpec -import org.scalatest.matchers.should.Matchers -import spray.json._ - -class DuosModelSpec extends AnyFreeSpec with Matchers { - - private implicit val impDuosDataUse: ModelJsonProtocol.impDuosDataUse.type = ModelJsonProtocol.impDuosDataUse - - "DUOS DuosDataUse" - { - - "Partially formed valid data use json should parse what's valid" - { - "generalUse: true, fooBar: 7" in { - val jsValues: Map[String, JsValue] = Map( - "generalUse" -> JsBoolean(true), - "fooBar" -> JsNumber(7) - ) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.generalUse.getOrElse(false) shouldBe true - } - } - - "Incorrectly formed data use json should parse to an empty object" - { - - "generalUse: FOO" in { - val jsValues: Map[String, JsValue] = Map("generalUse" -> JsString("FOO")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - assertIsUndefined(duosDataUse) - } - - "diseaseRestrictions: true" in { - val jsValues: Map[String, JsValue] = Map("diseaseRestrictions" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - assertIsUndefined(duosDataUse) - } - - "aggregateResearch: true" in { - val jsValues: Map[String, JsValue] = Map("aggregateResearch" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - assertIsUndefined(duosDataUse) - } - - "fooBar: 7, barBaz: [FOO, BAR]" in { - val vals = JsArray(JsString("FOO"), JsString("BAR")) - val jsValues: Map[String, JsValue] = Map( - "barBaz" -> JsArray(vals), - "fooBar" -> JsNumber(7) - ) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - assertIsUndefined(duosDataUse) - } - } - - "Correctly formed duos data use json should parse to a DuosDataUse" - { - "generalUse: true" in { - val jsValues: Map[String, JsValue] = Map("generalUse" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.generalUse.getOrElse(false) shouldBe true - } - "hmbResearch: true" in { - val jsValues: Map[String, JsValue] = Map("hmbResearch" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.hmbResearch.getOrElse(false) shouldBe true - } - "diseaseRestrictions: [DOID_1]" in { - val diseases = JsArray(JsString("DOID_1")) - val jsValues: Map[String, JsValue] = Map("diseaseRestrictions" -> diseases) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - val duosDiseases: Seq[String] = duosDataUse.diseaseRestrictions.getOrElse(Seq.empty[String]) - duosDiseases should not be empty - duosDiseases should contain theSameElementsInOrderAs Seq("DOID_1") - } - "diseaseRestrictions: [DOID_1, DOID_2]" in { - val diseases = JsArray(JsString("DOID_1"), JsString("DOID_2")) - val jsValues: Map[String, JsValue] = Map("diseaseRestrictions" -> diseases) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - val duosDiseases: Seq[String] = duosDataUse.diseaseRestrictions.getOrElse(Seq.empty[String]) - duosDiseases should not be empty - duosDiseases should contain theSameElementsInOrderAs Seq("DOID_1", "DOID_2") - } - "diseaseRestrictions: [DOID_1, DOID_2, DOID_2]" in { - val diseases = JsArray(JsString("DOID_1"), JsString("DOID_2"), JsString("DOID_3")) - val jsValues: Map[String, JsValue] = Map("diseaseRestrictions" -> diseases) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - val duosDiseases: Seq[String] = duosDataUse.diseaseRestrictions.getOrElse(Seq.empty[String]) - duosDiseases should not be empty - duosDiseases should contain theSameElementsInOrderAs Seq("DOID_1", "DOID_2", "DOID_3") - } - "populationOriginsAncestry: true" in { - val jsValues: Map[String, JsValue] = Map("populationOriginsAncestry" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.populationOriginsAncestry.getOrElse(false) shouldBe true - } - "populationStructure: true" in { - val jsValues: Map[String, JsValue] = Map("populationStructure" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.populationStructure.getOrElse(false) shouldBe true - } - "commercialUse: true" in { - val jsValues: Map[String, JsValue] = Map("commercialUse" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.commercialUse.getOrElse(false) shouldBe true - } - "methodsResearch: true" in { - val jsValues: Map[String, JsValue] = Map("methodsResearch" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.methodsResearch.getOrElse(false) shouldBe true - } - "aggregateResearch: Yes" in { - val jsValues: Map[String, JsValue] = Map("aggregateResearch" -> JsString("Yes")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.aggregateResearch.getOrElse(false) should equal("Yes") - } - "controlSetOption: No" in { - val jsValues: Map[String, JsValue] = Map("controlSetOption" -> JsString("No")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.controlSetOption.getOrElse(false) should equal("No") - } - "gender: F" in { - val jsValues: Map[String, JsValue] = Map("gender" -> JsString("F")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.gender.getOrElse(false) should equal("F") - } - "pediatric: true" in { - val jsValues: Map[String, JsValue] = Map("pediatric" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.pediatric.getOrElse(false) shouldBe true - } - "populationRestrictions: [POP_1, POP_2]" in { - val pops = JsArray(JsString("POP_1"), JsString("POP_2")) - val jsValues: Map[String, JsValue] = Map("populationRestrictions" -> pops) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - val duosPops: Seq[String] = duosDataUse.populationRestrictions.getOrElse(Seq.empty[String]) - duosPops should not be empty - duosPops should contain theSameElementsInOrderAs Seq("POP_1", "POP_2") - } - "dateRestriction: 1/1/2018" in { - val jsValues: Map[String, JsValue] = Map("dateRestriction" -> JsString("1/1/2018")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.dateRestriction.getOrElse(false) should equal("1/1/2018") - } - "recontactingDataSubjects: true" in { - val jsValues: Map[String, JsValue] = Map("recontactingDataSubjects" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.recontactingDataSubjects.getOrElse(false) shouldBe true - } - "recontactMay: No" in { - val jsValues: Map[String, JsValue] = Map("recontactMay" -> JsString("No")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.recontactMay.getOrElse(false) should equal("No") - } - "recontactMust: Yes" in { - val jsValues: Map[String, JsValue] = Map("recontactMust" -> JsString("Yes")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.recontactMust.getOrElse(false) should equal("Yes") - } - "genomicPhenotypicData: Yes" in { - val jsValues: Map[String, JsValue] = Map("genomicPhenotypicData" -> JsString("Yes")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.genomicPhenotypicData.getOrElse(false) should equal("Yes") - } - "otherRestrictions: true" in { - val jsValues: Map[String, JsValue] = Map("otherRestrictions" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.otherRestrictions.getOrElse(false) shouldBe true - } - "cloudStorage: No" in { - val jsValues: Map[String, JsValue] = Map("cloudStorage" -> JsString("No")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.cloudStorage.getOrElse(false) should equal("No") - } - "ethicsApprovalRequired: true" in { - val jsValues: Map[String, JsValue] = Map("ethicsApprovalRequired" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.ethicsApprovalRequired.getOrElse(false) shouldBe true - } - "geographicalRestrictions: US" in { - val jsValues: Map[String, JsValue] = Map("geographicalRestrictions" -> JsString("US")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.geographicalRestrictions.getOrElse(false) should equal("US") - } - "other: Other" in { - val jsValues: Map[String, JsValue] = Map("other" -> JsString("Other")) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.other.getOrElse(false) should equal("Other") - } - "illegalBehavior: true" in { - val jsValues: Map[String, JsValue] = Map("illegalBehavior" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.illegalBehavior.getOrElse(false) shouldBe true - } - "addiction: true" in { - val jsValues: Map[String, JsValue] = Map("addiction" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.addiction.getOrElse(false) shouldBe true - } - "sexualDiseases: true" in { - val jsValues: Map[String, JsValue] = Map("sexualDiseases" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.sexualDiseases.getOrElse(false) shouldBe true - } - "stigmatizeDiseases: true" in { - val jsValues: Map[String, JsValue] = Map("stigmatizeDiseases" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.stigmatizeDiseases.getOrElse(false) shouldBe true - } - "vulnerablePopulations: true" in { - val jsValues: Map[String, JsValue] = Map("vulnerablePopulations" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.vulnerablePopulations.getOrElse(false) shouldBe true - } - "psychologicalTraits: true" in { - val jsValues: Map[String, JsValue] = Map("psychologicalTraits" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.psychologicalTraits.getOrElse(false) shouldBe true - } - "nonBiomedical: true" in { - val jsValues: Map[String, JsValue] = Map("nonBiomedical" -> JsBoolean(true)) - val duosDataUse: DuosDataUse = DuosDataUse.apply(jsValues) - duosDataUse.nonBiomedical.getOrElse(false) shouldBe true - } - } - } - - private def assertIsUndefined(duosDataUse: DuosDataUse): Unit = { - duosDataUse.getClass.getDeclaredFields map { f => - f.setAccessible(true) - f.get(duosDataUse) match { - case Some(x) => fail(s"Field ${f.getName} should not be defined") - case None => // passing cass - } - } - } - -} diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/service/BaseServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/service/BaseServiceSpec.scala index 33d3b6a33..e287ed19e 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/service/BaseServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/service/BaseServiceSpec.scala @@ -13,7 +13,6 @@ class BaseServiceSpec extends ServiceSpec with BeforeAndAfter { val agoraDao:MockAgoraDAO = new MockAgoraDAO val googleServicesDao:MockGoogleServicesDAO = new MockGoogleServicesDAO val ontologyDao:MockOntologyDAO = new MockOntologyDAO - val consentDao:MockConsentDAO = new MockConsentDAO val rawlsDao:MockRawlsDAO = new MockRawlsDAO val samDao:MockSamDAO = new MockSamDAO val searchDao:MockSearchDAO = new MockSearchDAO @@ -24,6 +23,6 @@ class BaseServiceSpec extends ServiceSpec with BeforeAndAfter { val shibbolethDao:MockShibbolethDAO = new MockShibbolethDAO val app:Application = - new Application(agoraDao, googleServicesDao, ontologyDao, consentDao, rawlsDao, samDao, searchDao, researchPurposeSupport, thurloeDao, shareLogDao, importServiceDao, shibbolethDao) + new Application(agoraDao, googleServicesDao, ontologyDao, rawlsDao, samDao, searchDao, researchPurposeSupport, thurloeDao, shareLogDao, importServiceDao, shibbolethDao) } diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/service/DataUseRestrictionSupportSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/service/DataUseRestrictionSupportSpec.scala index 5a10b33fc..27148e2d1 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/service/DataUseRestrictionSupportSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/service/DataUseRestrictionSupportSpec.scala @@ -4,7 +4,6 @@ import java.lang.reflect.Field import org.broadinstitute.dsde.firecloud.FireCloudConfig import org.broadinstitute.dsde.firecloud.dataaccess.MockOntologyDAO -import org.broadinstitute.dsde.firecloud.model.DUOS.DuosDataUse import org.broadinstitute.dsde.firecloud.model.DataUse.StructuredDataRequest import org.broadinstitute.dsde.firecloud.service.DataUseRestrictionTestFixtures._ import org.broadinstitute.dsde.rawls.model._ @@ -294,317 +293,6 @@ class DataUseRestrictionSupportSpec extends AnyFreeSpec with Matchers with DataU } } - - "ORSP-based restrictions" - { - val ontologyDAO = new MockOntologyDAO - - "when translating DUOS restrictions to FireCloud restrictions" - { - "should return no attributes if DUOS is empty" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse, ontologyDAO) - assert(attrs.isEmpty) - } - "should translate boolean TRUEs" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - generalUse = Some(true), - hmbResearch = Some(true), - commercialUse = Some(true), - pediatric = Some(true), - methodsResearch = Some(true) - ), ontologyDAO) - val expected = Map( - AttributeName.withLibraryNS("GRU") -> AttributeBoolean(true), - AttributeName.withLibraryNS("HMB") -> AttributeBoolean(true), - AttributeName.withLibraryNS("NCU") -> AttributeBoolean(true), - AttributeName.withLibraryNS("RS-PD") -> AttributeBoolean(true), - AttributeName.withLibraryNS("NMDS") -> AttributeBoolean(true) - ) - assertResult(expected) {attrs} - } - "should translate boolean FALSEs" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - generalUse = Some(false), - hmbResearch = Some(false), - commercialUse = Some(false), - pediatric = Some(false), - methodsResearch = Some(false) - ), ontologyDAO) - val expected = Map( - AttributeName.withLibraryNS("GRU") -> AttributeBoolean(false), - AttributeName.withLibraryNS("HMB") -> AttributeBoolean(false), - AttributeName.withLibraryNS("NCU") -> AttributeBoolean(false), - AttributeName.withLibraryNS("RS-PD") -> AttributeBoolean(false), - AttributeName.withLibraryNS("NMDS") -> AttributeBoolean(false) - ) - assertResult(expected) {attrs} - } - "should translate mixed boolean TRUE/FALSEs" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - generalUse = Some(true), - hmbResearch = Some(false), - commercialUse = Some(true), - pediatric = Some(false), - methodsResearch = Some(true) - ), ontologyDAO) - val expected = Map( - AttributeName.withLibraryNS("GRU") -> AttributeBoolean(true), - AttributeName.withLibraryNS("HMB") -> AttributeBoolean(false), - AttributeName.withLibraryNS("NCU") -> AttributeBoolean(true), - AttributeName.withLibraryNS("RS-PD") -> AttributeBoolean(false), - AttributeName.withLibraryNS("NMDS") -> AttributeBoolean(true) - ) - assertResult(expected) {attrs} - } - "should handle 'yes' string values from DUOS as boolean TRUEs" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - aggregateResearch = Some("Yes"), - controlSetOption = Some("yeS") - ), ontologyDAO) - val expected = Map( - AttributeName.withLibraryNS("NAGR") -> AttributeBoolean(true), - AttributeName.withLibraryNS("NCTRL") -> AttributeBoolean(true) - ) - assertResult(expected) {attrs} - } - "should handle 'no' string values from DUOS as boolean FALSEs" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - aggregateResearch = Some("No"), - controlSetOption = Some("NO") - ), ontologyDAO) - val expected = Map( - AttributeName.withLibraryNS("NAGR") -> AttributeBoolean(false), - AttributeName.withLibraryNS("NCTRL") -> AttributeBoolean(false) - ) - assertResult(expected) {attrs} - } - "should handle non-'yes' or 'no' string values from DUOS as invalid (Nones)" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - aggregateResearch = Some("yessir"), - controlSetOption = Some("nopers") - ), ontologyDAO) - assert(attrs.isEmpty) - } - "should translate disease ontology nodes, including labels" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - diseaseRestrictions = Some(Seq( - "http://purl.obolibrary.org/obo/DOID_2531", // hematologic cancer - "http://purl.obolibrary.org/obo/DOID_1240", // leukemia 1510 - "http://purl.obolibrary.org/obo/DOID_4325" // Ebola hemorrhagic fever - )) - ), ontologyDAO) - val expected = Map( - AttributeName.withLibraryNS("DS_URL") -> AttributeValueList(Seq( - AttributeString("http://purl.obolibrary.org/obo/DOID_2531"), - AttributeString("http://purl.obolibrary.org/obo/DOID_1240"), - AttributeString("http://purl.obolibrary.org/obo/DOID_4325") - )), - AttributeName.withLibraryNS("DS") -> AttributeValueList(Seq( - AttributeString("hematologic cancer"), - AttributeString("leukemia"), - AttributeString("Ebola hemorrhagic fever") - )) - ) - assertResult(expected) {attrs} - } - "should translate disease ontology nodes and use node id when label not found" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - diseaseRestrictions = Some(Seq( - "http://purl.obolibrary.org/obo/DOID_2531", // hematologic cancer - "http://purl.obolibrary.org/obo/DOID_1510", // -- not found in mock dao -- - "http://purl.obolibrary.org/obo/DOID_4325" // Ebola hemorrhagic fever - )) - ), ontologyDAO) - val expected = Map( - AttributeName.withLibraryNS("DS_URL") -> AttributeValueList(Seq( - AttributeString("http://purl.obolibrary.org/obo/DOID_2531"), - AttributeString("http://purl.obolibrary.org/obo/DOID_1510"), - AttributeString("http://purl.obolibrary.org/obo/DOID_4325") - )), - AttributeName.withLibraryNS("DS") -> AttributeValueList(Seq( - AttributeString("hematologic cancer"), - AttributeString("http://purl.obolibrary.org/obo/DOID_1510"), - AttributeString("Ebola hemorrhagic fever") - )) - ) - assertResult(expected) {attrs} - } - "should handle empty seq of disease ontology nodes" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - diseaseRestrictions = Some(Seq.empty[String]) - ), ontologyDAO) - assert(attrs.isEmpty) - } - "should handle populationRestrictions string lists" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - pediatric = Some(true) - ), ontologyDAO) - val expected = Map( - AttributeName.withLibraryNS("RS-PD") -> AttributeBoolean(true) - ) - assertResult(expected) {attrs} - } - "should handle empty populationRestrictions" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - populationRestrictions = Some(Seq.empty[String]) - ), ontologyDAO) - - assert(attrs.isEmpty) - } - "should handle gender = Male" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - gender = Some("Male") - ), ontologyDAO) - val expected = Map( - AttributeName.withLibraryNS("RS-G") -> AttributeBoolean(true), - AttributeName.withLibraryNS("RS-M") -> AttributeBoolean(true) - ) - assertResult(expected) {attrs} - } - "should handle gender = Female" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - gender = Some("Female") - ), ontologyDAO) - val expected = Map( - AttributeName.withLibraryNS("RS-G") -> AttributeBoolean(true), - AttributeName.withLibraryNS("RS-FM") -> AttributeBoolean(true) - ) - assertResult(expected) {attrs} - } - "should ignore invalid gender values" in { - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( - gender = Some("invalid") - ), ontologyDAO) - - assert(attrs.isEmpty) - } - "should ignore the DUOS keys that FireCloud doesn't implement" in { - - // The properties that are commented out are the ones that FireCloud implements. - val attrs = generateStructuredUseRestrictionAttribute(new DuosDataUse( -// generalUse = None, -// hmbResearch = None, -// diseaseRestrictions = None, -// commercialUse = None, -// methodsResearch = None, -// aggregateResearch = None, -// controlSetOption = None, -// pediatric = None, -// populationRestrictions = None, -// gender = None, - populationOriginsAncestry = Some(true), - populationStructure = Some(true), - vulnerablePopulations = Some(true), - dateRestriction = Some("today"), - recontactingDataSubjects = Some(true), - recontactMay = Some("sure"), - recontactMust = Some("yes"), - genomicPhenotypicData = Some("pheno"), - otherRestrictions = Some(true), - cloudStorage = Some("cloud"), - ethicsApprovalRequired = Some(true), - geographicalRestrictions = Some("nowhere"), - other = Some("other"), - illegalBehavior = Some(true), - addiction = Some(true), - sexualDiseases = Some(true), - stigmatizeDiseases = Some(true), - psychologicalTraits = Some(true), - nonBiomedical = Some(true) - ), ontologyDAO) - assert(attrs.isEmpty) - } - } - } - "when annotating a workspace with ORSP-based data use" - { - val mockDUCodes = Map( - AttributeName.withLibraryNS("GRU") -> AttributeBoolean(true), - AttributeName.withLibraryNS("HMB") -> AttributeBoolean(true), - AttributeName.withLibraryNS("NCU") -> AttributeBoolean(true), - AttributeName.withLibraryNS("NPU") -> AttributeBoolean(true), - AttributeName.withLibraryNS("NMDS") -> AttributeBoolean(true), - AttributeName.withLibraryNS("NAGR") -> AttributeBoolean(true), - AttributeName.withLibraryNS("NCTRL") -> AttributeBoolean(true), - AttributeName.withLibraryNS("RS-PD") -> AttributeBoolean(true), - AttributeName.withLibraryNS("IRB") -> AttributeBoolean(true), - AttributeName.withLibraryNS("RS-G") -> AttributeBoolean(true), - AttributeName.withLibraryNS("RS-FM") -> AttributeBoolean(true), - AttributeName.withLibraryNS("RS-M") -> AttributeBoolean(true), - AttributeName.withLibraryNS("DS_URL") -> AttributeValueList(Seq(AttributeString("one"),AttributeString("two"))), - AttributeName.withLibraryNS("DS_URL") -> AttributeValueList(Seq(AttributeString("five"),AttributeString("six"))), - AttributeName.withLibraryNS("consentCodes") -> AttributeValueList(Seq(AttributeString("seven"),AttributeString("eight"))), - AttributeName.withLibraryNS("structuredUseRestriction") -> AttributeValueRawJson("""{"foo":"bar"}""") - ) - - - "should add attributes when no previous attributes exist" in { - val existing = Map.empty[AttributeName,Attribute] - val preferred = Map( - AttributeName.withLibraryNS("GRU") -> AttributeBoolean(true) - ) - val actual = replaceDataUseAttributes(existing, preferred) - val expected = Map( - AttributeName.withLibraryNS("GRU") -> AttributeBoolean(true) - ) - assertResult(expected) {actual} - } - "should not add attributes when no new attributes exist" in { - val existing = Map.empty[AttributeName,Attribute] - val preferred = Map.empty[AttributeName,Attribute] - val actual = replaceDataUseAttributes(existing, preferred) - val expected = Map.empty[AttributeName,Attribute] - assertResult(expected) {actual} - } - "should preserve pre-existing non-DU attributes" in { - val existing = Map( - AttributeName.withDefaultNS("description") -> AttributeString("my description"), - AttributeName.withLibraryNS("datasetName") -> AttributeString("my dataset") - ) - val preferred = Map( - AttributeName.withLibraryNS("GRU") -> AttributeBoolean(true) - ) - val actual = replaceDataUseAttributes(existing, preferred) - val expected = Map( - AttributeName.withDefaultNS("description") -> AttributeString("my description"), - AttributeName.withLibraryNS("datasetName") -> AttributeString("my dataset"), - AttributeName.withLibraryNS("GRU") -> AttributeBoolean(true) - ) - assertResult(expected) {actual} - } - "should overwrite pre-existing DU attributes" in { - val existing = Map( - AttributeName.withLibraryNS("HMB") -> AttributeBoolean(true) - ) - val preferred = Map( - AttributeName.withLibraryNS("HMB") -> AttributeBoolean(false) - ) - val actual = replaceDataUseAttributes(existing, preferred) - val expected = Map( - AttributeName.withLibraryNS("HMB") -> AttributeBoolean(false) - ) - assertResult(expected) {actual} - } - "should remove pre-existing DU attributes when adding new" in { - val existing = Map( - AttributeName.withLibraryNS("HMB") -> AttributeBoolean(true), - AttributeName.withLibraryNS("NAGR") -> AttributeBoolean(true) - ) - val preferred = Map( - AttributeName.withLibraryNS("HMB") -> AttributeBoolean(false) - ) - val actual = replaceDataUseAttributes(existing, preferred) - val expected = Map( - AttributeName.withLibraryNS("HMB") -> AttributeBoolean(false) - ) - assertResult(expected) {actual} - } - "should remove pre-existing DU attributes even when adding nothing" in { - val existing = mockDUCodes - val preferred = Map.empty[AttributeName,Attribute] - val actual = replaceDataUseAttributes(existing, preferred) - val expected = Map.empty[AttributeName,Attribute] - assertResult(expected) {actual} - } - } - } diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/service/LibraryServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/service/LibraryServiceSpec.scala index cb9d7041c..7c2234cf1 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/service/LibraryServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/service/LibraryServiceSpec.scala @@ -248,7 +248,7 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } } @@ -269,7 +269,7 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } } @@ -286,7 +286,7 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } "should be the different for attribute operations" in { @@ -312,7 +312,7 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } } @@ -334,7 +334,7 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } } @@ -355,7 +355,7 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } } @@ -378,7 +378,7 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } } @@ -397,7 +397,7 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } "should generate indexable document with no parent info when DOID has no parents" in { @@ -412,7 +412,7 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } "should generate indexable document with no parent info when DOID not valid" in { @@ -427,101 +427,13 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } } "with an ORSP id in attributes" - { - // most of this is unit-tested in DataUseRestrictionSupportSpec; tests here are intentionally high level - - // default json object fields to represent the indexed data use restriction - val defaultDataUseFields = Map( - "NPU" -> JsBoolean(false), - "RS-PD" -> JsBoolean(false), - "NCU" -> JsBoolean(false), - "RS-G" -> JsBoolean(false), - "IRB" -> JsBoolean(false), - "NAGR" -> JsBoolean(false), - "RS-FM" -> JsBoolean(false), - "RS-M" -> JsBoolean(false), - "NMDS" -> JsBoolean(false), - "NCTRL" -> JsBoolean(false), - "GRU" -> JsBoolean(false), - "HMB" -> JsBoolean(false), - "DS" -> JsArray() - ) - - "should populate data use restrictions from Consent" in { - val w = testWorkspace.copy(attributes = Some(Map( - orspIdAttribute -> AttributeString("MOCK-111") - ))) - val expected = Document(testUUID.toString, Map( - orspIdAttribute -> AttributeString("MOCK-111"), - consentCodesAttributeName -> AttributeValueList(Seq(AttributeString("NCTRL"), AttributeString("NCU"))), - structuredUseRestrictionAttributeName -> AttributeValueRawJson(JsObject( - defaultDataUseFields ++ Map( - "NCU" -> JsBoolean(true), - "NCTRL" -> JsBoolean(true) - )).prettyPrint), - AttributeName.withDefaultNS("name") -> AttributeString(testWorkspace.name), - AttributeName.withDefaultNS("namespace") -> AttributeString(testWorkspace.namespace), - AttributeName.withDefaultNS("workspaceId") -> AttributeString(testWorkspace.workspaceId), - AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) - )) - assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head - } - } - "should clear and overwrite pre-existing data use attributes" in { - val w = testWorkspace.copy(attributes = Some(Map( - orspIdAttribute -> AttributeString("MOCK-111"), - AttributeName.withLibraryNS("NCU") -> AttributeBoolean(false), // should be overwritten by orsp DU - AttributeName.withLibraryNS("GRU") -> AttributeBoolean(true) // overrides the default, should be erased by orsp DU - ))) - val expected = Document(testUUID.toString, Map( - orspIdAttribute -> AttributeString("MOCK-111"), - consentCodesAttributeName -> AttributeValueList(Seq(AttributeString("NCTRL"), AttributeString("NCU"))), - structuredUseRestrictionAttributeName -> AttributeValueRawJson(JsObject( - defaultDataUseFields ++ Map( - "NCU" -> JsBoolean(true), - "NCTRL" -> JsBoolean(true) - )).prettyPrint), - AttributeName.withDefaultNS("name") -> AttributeString(testWorkspace.name), - AttributeName.withDefaultNS("namespace") -> AttributeString(testWorkspace.namespace), - AttributeName.withDefaultNS("workspaceId") -> AttributeString(testWorkspace.workspaceId), - AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) - )) - assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head - } - } - "should preserve pre-existing non-data use attributes" in { - val w = testWorkspace.copy(attributes = Some(Map( - orspIdAttribute -> AttributeString("MOCK-111"), - AttributeName.withLibraryNS("datasetName") -> AttributeString("my cohort"), - AttributeName.withLibraryNS("projectName") -> AttributeString("my project") - - ))) - val expected = Document(testUUID.toString, Map( - orspIdAttribute -> AttributeString("MOCK-111"), - consentCodesAttributeName -> AttributeValueList(Seq(AttributeString("NCTRL"), AttributeString("NCU"))), - structuredUseRestrictionAttributeName -> AttributeValueRawJson(JsObject( - defaultDataUseFields ++ Map( - "NCU" -> JsBoolean(true), - "NCTRL" -> JsBoolean(true) - )).prettyPrint), - AttributeName.withLibraryNS("datasetName") -> AttributeString("my cohort"), - AttributeName.withLibraryNS("projectName") -> AttributeString("my project"), - AttributeName.withDefaultNS("name") -> AttributeString(testWorkspace.name), - AttributeName.withDefaultNS("namespace") -> AttributeString(testWorkspace.namespace), - AttributeName.withDefaultNS("workspaceId") -> AttributeString(testWorkspace.workspaceId), - AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) - )) - assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head - } - } - "should generate indexable document without any data use restrictions if ORSP id not found" in { + // most of this is unit-tested in DataUseRestrictionSupportSpec; the test here is intentionally high level + "should generate indexable document without any data use restrictions if ORSP id is present" in { val w = testWorkspace.copy(attributes = Some(Map( orspIdAttribute -> AttributeString("MOCK-NOTFOUND") ))) @@ -533,22 +445,7 @@ class LibraryServiceSpec extends BaseServiceSpec with AnyFreeSpecLike with Libra AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) )) assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head - } - } - "should generate indexable document without any data use restrictions if ORSP request throws exception" in { - val w = testWorkspace.copy(attributes = Some(Map( - orspIdAttribute -> AttributeString("MOCK-EXCEPTION") - ))) - val expected = Document(testUUID.toString, Map( - orspIdAttribute -> AttributeString("MOCK-EXCEPTION"), - AttributeName.withDefaultNS("name") -> AttributeString(testWorkspace.name), - AttributeName.withDefaultNS("namespace") -> AttributeString(testWorkspace.namespace), - AttributeName.withDefaultNS("workspaceId") -> AttributeString(testWorkspace.workspaceId), - AttributeName.withDefaultNS("authorizationDomain") -> AttributeValueList(Seq(AttributeString(testGroup1Ref.membersGroupName.value), AttributeString(testGroup2Ref.membersGroupName.value))) - )) - assertResult(expected) { - Await.result(indexableDocuments(Seq(w), ontologyDao, consentDao), dur).head + Await.result(indexableDocuments(Seq(w), ontologyDao), dur).head } } } diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/service/UserServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/service/UserServiceSpec.scala index 851e48320..1dac0262f 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/service/UserServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/service/UserServiceSpec.scala @@ -15,7 +15,7 @@ import scala.concurrent.duration._ class UserServiceSpec extends BaseServiceSpec with BeforeAndAfterEach { - val customApp = Application(agoraDao, new MockGoogleServicesFailedGroupsDAO(), ontologyDao, consentDao, new MockRawlsDeleteWSDAO(), samDao, new MockSearchDeleteWSDAO(), new MockResearchPurposeSupport, thurloeDao, new MockShareLogDAO, new MockImportServiceDAO, shibbolethDao) + val customApp = Application(agoraDao, new MockGoogleServicesFailedGroupsDAO(), ontologyDao, new MockRawlsDeleteWSDAO(), samDao, new MockSearchDeleteWSDAO(), new MockResearchPurposeSupport, thurloeDao, new MockShareLogDAO, new MockImportServiceDAO, shibbolethDao) val userServiceConstructor: (UserInfo) => UserService = UserService.constructor(customApp) diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/service/WorkspaceServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/service/WorkspaceServiceSpec.scala index 3187dd103..62bdfe6ec 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/service/WorkspaceServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/service/WorkspaceServiceSpec.scala @@ -16,7 +16,7 @@ import scala.concurrent.{Await, ExecutionContext, Future} class WorkspaceServiceSpec extends BaseServiceSpec with BeforeAndAfterEach { - val customApp = Application(agoraDao, googleServicesDao, ontologyDao, consentDao, new MockRawlsDeleteWSDAO(), samDao, new MockSearchDeleteWSDAO(), new MockResearchPurposeSupport, thurloeDao, new MockShareLogDAO, new MockImportServiceDAO, shibbolethDao) + val customApp = Application(agoraDao, googleServicesDao, ontologyDao, new MockRawlsDeleteWSDAO(), samDao, new MockSearchDeleteWSDAO(), new MockResearchPurposeSupport, thurloeDao, new MockShareLogDAO, new MockImportServiceDAO, shibbolethDao) val workspaceServiceConstructor: (WithAccessToken) => WorkspaceService = WorkspaceService.constructor(customApp) diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/utils/ConsentStatusSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/utils/ConsentStatusSpec.scala deleted file mode 100644 index 972422022..000000000 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/utils/ConsentStatusSpec.scala +++ /dev/null @@ -1,89 +0,0 @@ -package org.broadinstitute.dsde.firecloud.utils - -import akka.actor.ActorSystem -import akka.http.scaladsl.model._ -import org.broadinstitute.dsde.firecloud.dataaccess.ReportsSubsystemStatus -import org.broadinstitute.dsde.workbench.util.health.SubsystemStatus -import org.scalatest.concurrent.ScalaFutures -import org.scalatest.freespec.AnyFreeSpec -import org.scalatest.time.{Millis, Seconds, Span} - -import scala.concurrent.{ExecutionContext, Future} - -class ConsentStatusSpec extends AnyFreeSpec with ScalaFutures with ReportsSubsystemStatus { - - override def status: Future[SubsystemStatus] = { - getStatusFromDropwizardChecks(Future.failed(new Exception("exception"))) - } - - override def serviceName: String = "ConsentStatusSpec" - - implicit val system: ActorSystem = ActorSystem("ConsentStatusSpec") - implicit val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global - implicit val defaultPatience: PatienceConfig = PatienceConfig(timeout = Span(30, Seconds), interval = Span(5, Millis)) - - "ReportsSubsystemStatus" - { - "getStatusFromDropwizardChecks" - { - "ConsentStatus Case" - { - "successfully parse OK with no errors" in { - val consentStatusJsonNoErrors: String = "{\n\"ok\": true,\n\"degraded\": false,\n\"systems\": {\n\"deadlocks\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479384812,\n\"duration\": 6,\n\"timestamp\": \"2021-08-20T17:09:44.812Z\"\n},\n\"elastic-search\": {\n\"healthy\": true,\n\"message\": \"ClusterHealth is GREEN\",\n\"error\": null,\n\"details\": null,\n\"time\": 1629479382379,\n\"duration\": 1116,\n\"timestamp\": \"2021-08-20T17:09:42.379Z\"\n},\n\"google-cloud-storage\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479384804,\n\"duration\": 1987,\n\"timestamp\": \"2021-08-20T17:09:44.804Z\"\n},\n\"ontology\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": {\n\"ok\": true,\n\"systems\": {\n\"deadlocks\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479385314,\n\"duration\": 0,\n\"timestamp\": \"2021-08-20T17:09:45.314Z\"\n},\n\"elastic-search\": {\n\"healthy\": true,\n\"message\": \"ClusterHealth is GREEN\",\n\"error\": null,\n\"details\": null,\n\"time\": 1629479385299,\n\"duration\": 1,\n\"timestamp\": \"2021-08-20T17:09:45.299Z\"\n},\n\"google-cloud-storage\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479385314,\n\"duration\": 14,\n\"timestamp\": \"2021-08-20T17:09:45.314Z\"\n}\n}\n},\n\"time\": 1629479385506,\n\"duration\": 694,\n\"timestamp\": \"2021-08-20T17:09:45.506Z\"\n},\n\"postgresql\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479382792,\n\"duration\": 433,\n\"timestamp\": \"2021-08-20T17:09:42.792Z\"\n},\n\"sam\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": {\n\"ok\": true,\n\"systems\": {\n\"GooglePubSub\": {\n\"ok\": true\n},\n\"Database\": {\n\"ok\": true\n},\n\"GoogleGroups\": {\n\"ok\": true\n},\n\"GoogleIam\": {\n\"ok\": true\n},\n\"OpenDJ\": {\n\"ok\": true\n}\n}\n},\n\"time\": 1629479385898,\n\"duration\": 392,\n\"timestamp\": \"2021-08-20T17:09:45.898Z\"\n}\n}\n}" - val subsystemStatus: Future[SubsystemStatus] = callGetStatusFromDropwizardChecks(consentStatusJsonNoErrors) - whenReady(subsystemStatus) { f => - assertResult(true)(f.ok) - assertResult(true)(f.messages.isEmpty) - } - } - "successfully parse OK with some errors" in { - val consentStatusJsonSomeErrors: String = "{\n\"ok\": true,\n\"degraded\": true,\n\"systems\": {\n\"deadlocks\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479384812,\n\"duration\": 6,\n\"timestamp\": \"2021-08-20T17:09:44.812Z\"\n},\n\"elastic-search\": {\n\"healthy\": false,\n\"message\": \"ClusterHealth is RED\",\n\"error\": null,\n\"details\": null,\n\"time\": 1629479382379,\n\"duration\": 1116,\n\"timestamp\": \"2021-08-20T17:09:42.379Z\"\n},\n\"google-cloud-storage\": {\n\"healthy\": false,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479384804,\n\"duration\": 1987,\n\"timestamp\": \"2021-08-20T17:09:44.804Z\"\n},\n\"ontology\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": {\n\"ok\": true,\n\"systems\": {\n\"deadlocks\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479385314,\n\"duration\": 0,\n\"timestamp\": \"2021-08-20T17:09:45.314Z\"\n},\n\"elastic-search\": {\n\"healthy\": true,\n\"message\": \"ClusterHealth is GREEN\",\n\"error\": null,\n\"details\": null,\n\"time\": 1629479385299,\n\"duration\": 1,\n\"timestamp\": \"2021-08-20T17:09:45.299Z\"\n},\n\"google-cloud-storage\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479385314,\n\"duration\": 14,\n\"timestamp\": \"2021-08-20T17:09:45.314Z\"\n}\n}\n},\n\"time\": 1629479385506,\n\"duration\": 694,\n\"timestamp\": \"2021-08-20T17:09:45.506Z\"\n},\n\"postgresql\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479382792,\n\"duration\": 433,\n\"timestamp\": \"2021-08-20T17:09:42.792Z\"\n},\n\"sam\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": {\n\"ok\": true,\n\"systems\": {\n\"GooglePubSub\": {\n\"ok\": true\n},\n\"Database\": {\n\"ok\": true\n},\n\"GoogleGroups\": {\n\"ok\": true\n},\n\"GoogleIam\": {\n\"ok\": true\n},\n\"OpenDJ\": {\n\"ok\": true\n}\n}\n},\n\"time\": 1629479385898,\n\"duration\": 392,\n\"timestamp\": \"2021-08-20T17:09:45.898Z\"\n}\n}\n}" - val subsystemStatus: Future[SubsystemStatus] = callGetStatusFromDropwizardChecks(consentStatusJsonSomeErrors) - whenReady(subsystemStatus) { f => - assertResult(true)(f.ok) - // This is counterintuitive. The original logic does not add messages if the overall status - // is OK. We should maintain that to be backwards compatible with any other downstream - // checks that might break. - assertResult(true)(f.messages.isEmpty) - } - } - "successfully parse NOT OK with some errors" in { - val consentStatusJsonNotOK: String = "{\n\"ok\": false,\n\"degraded\": true,\n\"systems\": {\n\"deadlocks\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479384812,\n\"duration\": 6,\n\"timestamp\": \"2021-08-20T17:09:44.812Z\"\n},\n\"elastic-search\": {\n\"healthy\": false,\n\"message\": \"ClusterHealth is RED\",\n\"error\": null,\n\"details\": null,\n\"time\": 1629479382379,\n\"duration\": 1116,\n\"timestamp\": \"2021-08-20T17:09:42.379Z\"\n},\n\"google-cloud-storage\": {\n\"healthy\": false,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479384804,\n\"duration\": 1987,\n\"timestamp\": \"2021-08-20T17:09:44.804Z\"\n},\n\"ontology\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": {\n\"ok\": true,\n\"systems\": {\n\"deadlocks\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479385314,\n\"duration\": 0,\n\"timestamp\": \"2021-08-20T17:09:45.314Z\"\n},\n\"elastic-search\": {\n\"healthy\": true,\n\"message\": \"ClusterHealth is GREEN\",\n\"error\": null,\n\"details\": null,\n\"time\": 1629479385299,\n\"duration\": 1,\n\"timestamp\": \"2021-08-20T17:09:45.299Z\"\n},\n\"google-cloud-storage\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479385314,\n\"duration\": 14,\n\"timestamp\": \"2021-08-20T17:09:45.314Z\"\n}\n}\n},\n\"time\": 1629479385506,\n\"duration\": 694,\n\"timestamp\": \"2021-08-20T17:09:45.506Z\"\n},\n\"postgresql\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629479382792,\n\"duration\": 433,\n\"timestamp\": \"2021-08-20T17:09:42.792Z\"\n},\n\"sam\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": {\n\"ok\": true,\n\"systems\": {\n\"GooglePubSub\": {\n\"ok\": true\n},\n\"Database\": {\n\"ok\": true\n},\n\"GoogleGroups\": {\n\"ok\": true\n},\n\"GoogleIam\": {\n\"ok\": true\n},\n\"OpenDJ\": {\n\"ok\": true\n}\n}\n},\n\"time\": 1629479385898,\n\"duration\": 392,\n\"timestamp\": \"2021-08-20T17:09:45.898Z\"\n}\n}\n}" - val subsystemStatus: Future[SubsystemStatus] = callGetStatusFromDropwizardChecks(consentStatusJsonNotOK) - whenReady(subsystemStatus) { f => - assertResult(false)(f.ok) - assertResult(false)(f.messages.isEmpty) - } - } - } - "Map[String, DropwizardHealth] Case" - { - "successfully parse with no errors" in { - val mapDWStatusJsonNoErrors: String = "{\n\"deadlocks\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629490921326,\n\"duration\": 0,\n\"timestamp\": \"2021-08-20T20:22:01.326Z\"\n},\n\"elastic-search\": {\n\"healthy\": true,\n\"message\": \"ClusterHealth is GREEN\",\n\"error\": null,\n\"details\": null,\n\"time\": 1629490921295,\n\"duration\": 1,\n\"timestamp\": \"2021-08-20T20:22:01.295Z\"\n},\n\"google-cloud-storage\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629490921325,\n\"duration\": 28,\n\"timestamp\": \"2021-08-20T20:22:01.325Z\"\n},\n\"ontology\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629490921359,\n\"duration\": 34,\n\"timestamp\": \"2021-08-20T20:22:01.359Z\"\n},\n\"postgresql\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629490921297,\n\"duration\": 1,\n\"timestamp\": \"2021-08-20T20:22:01.297Z\"\n}\n}" - val subsystemStatus: Future[SubsystemStatus] = callGetStatusFromDropwizardChecks(mapDWStatusJsonNoErrors) - whenReady(subsystemStatus) { f => - assertResult(true)(f.ok) - assertResult(true)(f.messages.isEmpty) - } - } - "successfully parse with errors" in { - val mapDWStatusJsonSomeErrors: String = "{\n\"deadlocks\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629490921326,\n\"duration\": 0,\n\"timestamp\": \"2021-08-20T20:22:01.326Z\"\n},\n\"elastic-search\": {\n\"healthy\": false,\n\"message\": \"ClusterHealth is RED\",\n\"error\": null,\n\"details\": null,\n\"time\": 1629490921295,\n\"duration\": 1,\n\"timestamp\": \"2021-08-20T20:22:01.295Z\"\n},\n\"google-cloud-storage\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629490921325,\n\"duration\": 28,\n\"timestamp\": \"2021-08-20T20:22:01.325Z\"\n},\n\"ontology\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629490921359,\n\"duration\": 34,\n\"timestamp\": \"2021-08-20T20:22:01.359Z\"\n},\n\"postgresql\": {\n\"healthy\": true,\n\"message\": null,\n\"error\": null,\n\"details\": null,\n\"time\": 1629490921297,\n\"duration\": 1,\n\"timestamp\": \"2021-08-20T20:22:01.297Z\"\n}\n}" - val subsystemStatus: Future[SubsystemStatus] = callGetStatusFromDropwizardChecks(mapDWStatusJsonSomeErrors) - whenReady(subsystemStatus) { f => - assertResult(false)(f.ok) - assertResult(false)(f.messages.isEmpty) - } - } - } - } - } - - private def callGetStatusFromDropwizardChecks(entityContent: String): Future[SubsystemStatus] = { - val mediaType: MediaType.WithFixedCharset = MediaTypes.`application/json` - val response: HttpResponse = HttpResponse.apply( - StatusCodes.OK, - List(headers.`Content-Type`.apply(mediaType)), - HttpEntity.apply(entityContent).withContentType(ContentType.apply(mediaType)), - HttpProtocols.`HTTP/2.0` - ) - val consentStatus: Future[HttpResponse] = Future.successful(response) - getStatusFromDropwizardChecks(consentStatus) - } -} - diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/ApiServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/ApiServiceSpec.scala index 569ac7c96..03737a6ff 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/ApiServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/ApiServiceSpec.scala @@ -28,7 +28,6 @@ trait ApiServiceSpec extends AnyFlatSpec with Matchers with ScalatestRouteTest w val agoraDao: MockAgoraDAO val googleDao: MockGoogleServicesDAO val ontologyDao: MockOntologyDAO - val consentDao: MockConsentDAO val rawlsDao: MockRawlsDAO val samDao: MockSamDAO val searchDao: MockSearchDAO @@ -41,7 +40,7 @@ trait ApiServiceSpec extends AnyFlatSpec with Matchers with ScalatestRouteTest w def actorRefFactory = system val nihServiceConstructor = NihService.constructor( - new Application(agoraDao, googleDao, ontologyDao, consentDao, rawlsDao, samDao, searchDao, researchPurposeSupport, thurloeDao, shareLogDao, importServiceDao, shibbolethDao) + new Application(agoraDao, googleDao, ontologyDao, rawlsDao, samDao, searchDao, researchPurposeSupport, thurloeDao, shareLogDao, importServiceDao, shibbolethDao) ) _ } diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/LibraryApiServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/LibraryApiServiceSpec.scala index e3a3875c9..24783e0d8 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/LibraryApiServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/LibraryApiServiceSpec.scala @@ -8,8 +8,6 @@ import akka.http.scaladsl.unmarshalling.Unmarshal import org.broadinstitute.dsde.firecloud.FireCloudConfig import org.broadinstitute.dsde.firecloud.dataaccess.MockRawlsDAO import org.broadinstitute.dsde.firecloud.mock.{MockUtils, SamMockserverUtils} -import org.broadinstitute.dsde.firecloud.mock.MockUtils._ -import org.broadinstitute.dsde.firecloud.model.DUOS.{Consent, ConsentError, DuosDataUse} import org.broadinstitute.dsde.firecloud.model.DataUse.ResearchPurposeRequest import org.broadinstitute.dsde.firecloud.model.ModelJsonProtocol._ import org.broadinstitute.dsde.firecloud.model._ @@ -18,7 +16,6 @@ import org.broadinstitute.dsde.rawls.model.Attributable.AttributeMap import org.broadinstitute.dsde.rawls.model.{AttributeFormat, AttributeName, AttributeString, PlainArrayAttributeListSerializer} import org.mockserver.integration.ClientAndServer import org.mockserver.integration.ClientAndServer._ -import org.mockserver.model.HttpRequest.request import org.scalatest.BeforeAndAfterEach import spray.json.DefaultJsonProtocol._ import spray.json._ @@ -34,7 +31,6 @@ class LibraryApiServiceSpec extends BaseServiceSpec with LibraryApiService def actorRefFactory = system override val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global - var consentServer: ClientAndServer = _ lazy val isCuratorPath = "/api/library/user/role/curator" private def publishedPath(ns:String="namespace", name:String="name") = @@ -47,7 +43,7 @@ class LibraryApiServiceSpec extends BaseServiceSpec with LibraryApiService private final val librarySuggestPath = "/api/library/suggest" private final val libraryPopulateSuggestPath = "/api/library/populate/suggest/" private final val libraryGroupsPath = "/api/library/groups" - private def duosConsentOrspIdPath(orspId: String): String = "/api/duos/consent/orsp/%s".format(orspId) + private final val duosResearchPurposeQuery = "/duos/researchPurposeQuery" val libraryServiceConstructor: (UserInfo) => LibraryService = LibraryService.constructor(app) @@ -104,32 +100,11 @@ class LibraryApiServiceSpec extends BaseServiceSpec with LibraryApiService var mockSamServer: ClientAndServer = _ override def beforeAll(): Unit = { - consentServer = startClientAndServer(consentServerPort) - - val consentPath = consentUrl.replace(FireCloudConfig.Duos.baseConsentUrl, "") - val duosDataUse = DuosDataUse(generalUse = Some(true)) - val consent = Consent(consentId = "consent-id-12345", name = "12345", translatedUseRestriction = Some("Translation"), dataUse = Some(duosDataUse)) - val consentError = ConsentError(message = "Unapproved", code = BadRequest.intValue) - val consentNotFound = ConsentError(message = "Not Found", code = NotFound.intValue) - - val okGet = request().withMethod("GET").withPath(consentPath).withQueryStringParameter("name", "12345") - val okResponse = org.mockserver.model.HttpResponse.response().withHeaders(MockUtils.header).withStatusCode(OK.intValue).withBody(consent.toJson.prettyPrint) - consentServer.when(okGet).respond(okResponse) - - val badRequestGet = request().withMethod("GET").withPath(consentPath).withQueryStringParameter("name", "unapproved") - val badRequestResponse = org.mockserver.model.HttpResponse.response().withHeaders(MockUtils.header).withStatusCode(BadRequest.intValue).withBody(consentError.toJson.prettyPrint) - consentServer.when(badRequestGet).respond(badRequestResponse) - - val notFoundGet = request().withMethod("GET").withPath(consentPath).withQueryStringParameter("name", "missing") - val notFoundResponse = org.mockserver.model.HttpResponse.response().withHeaders(MockUtils.header).withStatusCode(NotFound.intValue).withBody(consentNotFound.toJson.prettyPrint) - consentServer.when(notFoundGet).respond(notFoundResponse) - mockSamServer = startClientAndServer(MockUtils.samServerPort) returnEnabledUser(mockSamServer) } override def afterAll(): Unit = { - consentServer.stop() mockSamServer.stop() } @@ -339,36 +314,6 @@ class LibraryApiServiceSpec extends BaseServiceSpec with LibraryApiService } } - "when searching for ORSP IDs" - { - "DELETE, POST, PUT, POST should receive a MethodNotAllowed" in { - List(HttpMethods.DELETE, HttpMethods.POST, HttpMethods.PUT, HttpMethods.PATCH) map { - method => - new RequestBuilder(method)(duosConsentOrspIdPath("anything")) ~> dummyUserIdHeaders("1234") ~> sealRoute(libraryRoutes) ~> check { - status should equal(MethodNotAllowed) - } - } - } - "GET on " + duosConsentOrspIdPath("12345") - { - "should return a valid consent for '12345'" in { - Get(duosConsentOrspIdPath("12345")) ~> dummyUserIdHeaders("1234") ~> sealRoute(libraryRoutes) ~> check { - status should equal(OK) - val consent = Await.result(Unmarshal(response).to[Consent], Duration.Inf) - consent shouldNot equal(None) - consent.name should equal("12345") - } - } - "should return a Bad Request error on 'unapproved'" in { - Get(duosConsentOrspIdPath("unapproved")) ~> dummyUserIdHeaders("1234") ~> sealRoute(libraryRoutes) ~> check { - status should equal(BadRequest) - } - } - "should return a Not Found error on known 'missing'" in { - Get(duosConsentOrspIdPath("missing")) ~> dummyUserIdHeaders("1234") ~> sealRoute(libraryRoutes) ~> check { - status should equal(NotFound) - } - } - } - } "when working with Library discoverable groups" - { "should return the right groups on get" in { Get(setDiscoverableGroupsPath("libraryValid","unittest")) ~> dummyUserIdHeaders("1234") ~> sealRoute(libraryRoutes) ~> check { diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/NihApiServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/NihApiServiceSpec.scala index 10edb4cf3..30cbe9ebe 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/NihApiServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/NihApiServiceSpec.scala @@ -45,10 +45,10 @@ class NihApiServiceSpec extends ApiServiceSpec with BeforeAndAfterAll with SamMo //JWT for NIH username "not-on-whitelist" (don't ever add this to the mock whitelists in MockGoogleServicesDAO.scala) val validJwtNotOnWhitelist = JWTWrapper("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJlcmFDb21tb25zVXNlcm5hbWUiOiJub3Qtb24td2hpdGVsaXN0IiwiaWF0IjoxNjE0ODc3NTc4MDB9.WpDrgtui5mOgDc5WvdWYC-l6vljGVyRI7DbBnpRYm7QOq00VLU6FI5YzVFe1eyjnHIqdz_KkkQD604Bi3G1qdyzhk_KKFCSeT4k5in-zS4Em_I2rcyUFs9DeHyFqVrBMZK8eZM_oKtSs23AtwGJASQ-sMvfXeXLcjTFuLWUdeiQEYedj9oOOA93ne-5Kaw9V7sR1foX-ybLDDHfHuAwTN2Vnvpmz0Qlk5osvvv-NunCo4M6A4fQ2FQWjrCwXk8-1N4Wf06dgDJ7ymsw9HtwHhzctVDzodaVlVU_RaC2gtSOWeD5nPaAJ7h6aNmNeLRmNwzCBm3TyPDY-qznPVM0DRg") - case class TestApiService(agoraDao: MockAgoraDAO, googleDao: MockGoogleServicesDAO, ontologyDao: MockOntologyDAO, consentDao: MockConsentDAO, rawlsDao: MockRawlsDAO, samDao: MockSamDAO, searchDao: MockSearchDAO, researchPurposeSupport: MockResearchPurposeSupport, thurloeDao: MockThurloeDAO, shareLogDao: MockShareLogDAO, importServiceDao: MockImportServiceDAO, shibbolethDao: MockShibbolethDAO)(implicit val executionContext: ExecutionContext, implicit val materializer: Materializer) extends ApiServices + case class TestApiService(agoraDao: MockAgoraDAO, googleDao: MockGoogleServicesDAO, ontologyDao: MockOntologyDAO, rawlsDao: MockRawlsDAO, samDao: MockSamDAO, searchDao: MockSearchDAO, researchPurposeSupport: MockResearchPurposeSupport, thurloeDao: MockThurloeDAO, shareLogDao: MockShareLogDAO, importServiceDao: MockImportServiceDAO, shibbolethDao: MockShibbolethDAO)(implicit val executionContext: ExecutionContext, implicit val materializer: Materializer) extends ApiServices def withDefaultApiServices[T](testCode: TestApiService => T): T = { - val apiService = TestApiService(new MockAgoraDAO, new MockGoogleServicesDAO, new MockOntologyDAO, new MockConsentDAO, new MockRawlsDAO, new MockSamDAO, new MockSearchDAO, new MockResearchPurposeSupport, new MockThurloeDAO, new MockShareLogDAO, new MockImportServiceDAO, new MockShibbolethDAO) + val apiService = TestApiService(new MockAgoraDAO, new MockGoogleServicesDAO, new MockOntologyDAO, new MockRawlsDAO, new MockSamDAO, new MockSearchDAO, new MockResearchPurposeSupport, new MockThurloeDAO, new MockShareLogDAO, new MockImportServiceDAO, new MockShibbolethDAO) testCode(apiService) } diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/PermissionReportApiSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/PermissionReportApiSpec.scala index cd8b12bcb..16bf4f0ac 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/PermissionReportApiSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/PermissionReportApiSpec.scala @@ -25,7 +25,7 @@ class PermissionReportApiSpec extends BaseServiceSpec with WorkspaceApiService w override val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global - val testApp = app.copy(agoraDAO=new PermissionReportMockAgoraDAO(), rawlsDAO=new PermissionReportMockRawlsDAO()) + val testApp = app.copy(agoraDAO = new PermissionReportMockAgoraDAO(), rawlsDAO = new PermissionReportMockRawlsDAO()) val workspaceServiceConstructor: (WithAccessToken) => WorkspaceService = WorkspaceService.constructor(testApp) val permissionReportServiceConstructor: (UserInfo) => PermissionReportService = PermissionReportService.constructor(testApp) diff --git a/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/StatusApiServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/StatusApiServiceSpec.scala index dcb26f4ec..e5e2e9e2d 100644 --- a/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/StatusApiServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/firecloud/webservice/StatusApiServiceSpec.scala @@ -61,7 +61,7 @@ class StatusApiServiceSpec extends BaseServiceSpec with StatusApiService with Sp "should contain all the subsystems we care about" in { Get(statusPath) ~> statusRoutes ~> check { val statusCheckResponse = responseAs[StatusCheckResponse] - val expectedSystems = Set(Agora, Consent, GoogleBuckets, LibraryIndex, OntologyIndex, Rawls, Sam, Thurloe) + val expectedSystems = Set(Agora, GoogleBuckets, LibraryIndex, OntologyIndex, Rawls, Sam, Thurloe) assertResult(expectedSystems) { statusCheckResponse.systems.keySet } } }