From 56a69a06a96fd96dd0478922766a702f43f4eb8e Mon Sep 17 00:00:00 2001 From: Tristan Garwood Date: Fri, 26 Jan 2024 12:38:37 -0500 Subject: [PATCH] ID-1023 Fix list resources v2 endpoint bug. --- .../dsde/workbench/sam/model/api/FilteredResources.scala | 2 +- .../workbench/sam/model/api/FilteredResourcesFlat.scala | 8 +++----- .../sam/model/api/FilteredResourcesHierarchical.scala | 7 +++---- .../workbench/sam/api/StandardSamUserDirectivesSpec.scala | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResources.scala b/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResources.scala index 08f2dde17..ba95980d7 100644 --- a/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResources.scala +++ b/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResources.scala @@ -1,5 +1,5 @@ package org.broadinstitute.dsde.workbench.sam.model.api trait FilteredResources { - def format: String + val format: String } diff --git a/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResourcesFlat.scala b/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResourcesFlat.scala index 579d63f2a..18a361e94 100644 --- a/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResourcesFlat.scala +++ b/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResourcesFlat.scala @@ -2,19 +2,17 @@ package org.broadinstitute.dsde.workbench.sam.model.api import org.broadinstitute.dsde.workbench.model.WorkbenchGroupName import org.broadinstitute.dsde.workbench.sam.model.{AccessPolicyName, ResourceAction, ResourceId, ResourceRoleName, ResourceTypeName} -import spray.json.DefaultJsonProtocol.jsonFormat1 +import spray.json.DefaultJsonProtocol.jsonFormat2 import spray.json.RootJsonFormat import org.broadinstitute.dsde.workbench.sam.model.api.SamJsonSupport._ import org.broadinstitute.dsde.workbench.model.WorkbenchIdentityJsonSupport._ import spray.json.DefaultJsonProtocol._ object FilteredResourcesFlat { - implicit val FilteredResourcesFlatFormat: RootJsonFormat[FilteredResourcesFlat] = jsonFormat1(FilteredResourcesFlat.apply) + implicit val FilteredResourcesFlatFormat: RootJsonFormat[FilteredResourcesFlat] = jsonFormat2(FilteredResourcesFlat.apply) } -case class FilteredResourcesFlat(resources: Set[FilteredResourceFlat]) extends FilteredResources { - override def format: String = "flat" -} +case class FilteredResourcesFlat(resources: Set[FilteredResourceFlat], format: String = "flat") extends FilteredResources object FilteredResourceFlat { implicit val FilteredResourceFlatFormat: RootJsonFormat[FilteredResourceFlat] = jsonFormat7(FilteredResourceFlat.apply) diff --git a/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResourcesHierarchical.scala b/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResourcesHierarchical.scala index af3c0a33f..7de06976f 100644 --- a/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResourcesHierarchical.scala +++ b/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/FilteredResourcesHierarchical.scala @@ -8,12 +8,11 @@ import spray.json.RootJsonFormat import org.broadinstitute.dsde.workbench.model.WorkbenchIdentityJsonSupport._ object FilteredResourcesHierarchical { - implicit val FilteredResourcesHierarchicalFormat: RootJsonFormat[FilteredResourcesHierarchical] = jsonFormat1(FilteredResourcesHierarchical.apply) + implicit val FilteredResourcesHierarchicalFormat: RootJsonFormat[FilteredResourcesHierarchical] = jsonFormat2(FilteredResourcesHierarchical.apply) } -case class FilteredResourcesHierarchical(resources: Set[FilteredResourceHierarchical]) extends FilteredResources { - override def format: String = "hierarchical" -} +case class FilteredResourcesHierarchical(resources: Set[FilteredResourceHierarchical], format: String = "hierarchical") extends FilteredResources + case object FilteredResourceHierarchicalPolicy { implicit val filteredResourceHierarchicalPolicyFormat: RootJsonFormat[FilteredResourceHierarchicalPolicy] = jsonFormat5( FilteredResourceHierarchicalPolicy.apply diff --git a/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/StandardSamUserDirectivesSpec.scala b/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/StandardSamUserDirectivesSpec.scala index 0644723a8..c6b61c62d 100644 --- a/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/StandardSamUserDirectivesSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/StandardSamUserDirectivesSpec.scala @@ -182,7 +182,7 @@ class StandardSamUserDirectivesSpec extends AnyFlatSpec with PropertyBasedTestin Get("/").withHeaders(headers) ~> handleExceptions(myExceptionHandler)(services.withActiveUser(samRequestContext)(_ => complete(""))) ~> check { status shouldBe StatusCodes.Unauthorized - responseAs[String] should include("sam.testUrl.mock") + responseAs[String] should include("terms of service") } }