diff --git a/src/main/resources/swagger/api-docs.yaml b/src/main/resources/swagger/api-docs.yaml index 53925330f..4d143cbb7 100755 --- a/src/main/resources/swagger/api-docs.yaml +++ b/src/main/resources/swagger/api-docs.yaml @@ -4586,8 +4586,10 @@ components: $ref: '#/components/schemas/SamUserAllowances' userTermsOfServiceDetails: $ref: '#/components/schemas/UserTermsOfServiceDetails' - enterpriseFeatures: - $ref: '#/components/schemas/FilteredResourcesFlatResponse' + additionalDetails: + type: object + description: additional details about the user, such as enterprise features they have access to + | example: { "enterpriseFeatures": ["feature1", "feature2"] } SamUserRegistrationRequest: type: object properties: diff --git a/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/UserRoutesV2.scala b/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/UserRoutesV2.scala index b93dc495d..0f77ec43d 100644 --- a/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/UserRoutesV2.scala +++ b/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/UserRoutesV2.scala @@ -18,6 +18,7 @@ import org.broadinstitute.dsde.workbench.sam.model.api.{ } import org.broadinstitute.dsde.workbench.sam.service.{ResourceService, TosService, UserService} import org.broadinstitute.dsde.workbench.sam.util.SamRequestContext +import spray.json.enrichAny /** Created by tlangs on 10/12/2023. */ @@ -199,7 +200,9 @@ trait UserRoutesV2 extends SamUserDirectives with SamRequestContextDirectives { includePublic = false, samRequestContext ) - } yield maybeAttributes.map(SamUserCombinedStateResponse(samUser, allowances, _, termsOfServiceDetails, enterpriseFeatures)) + } yield maybeAttributes.map( + SamUserCombinedStateResponse(samUser, allowances, _, termsOfServiceDetails, Map("enterpriseFeatures" -> enterpriseFeatures.toJson)) + ) combinedStateResponse.map { case Some(response) => OK -> Some(response) case None => NotFound -> None diff --git a/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/SamUserCombinedStateResponse.scala b/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/SamUserCombinedStateResponse.scala index a44dcc71e..a221ecb28 100644 --- a/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/SamUserCombinedStateResponse.scala +++ b/src/main/scala/org/broadinstitute/dsde/workbench/sam/model/api/SamUserCombinedStateResponse.scala @@ -2,7 +2,7 @@ package org.broadinstitute.dsde.workbench.sam.model.api import org.broadinstitute.dsde.workbench.sam.model.TermsOfServiceDetails import spray.json.DefaultJsonProtocol._ -import spray.json.RootJsonFormat +import spray.json._ import org.broadinstitute.dsde.workbench.sam.model.api.SamUserAllowances.SamUserAllowedResponseFormat import org.broadinstitute.dsde.workbench.sam.model.api.SamUserAttributes.SamUserAttributesFormat import org.broadinstitute.dsde.workbench.sam.model.api.SamJsonSupport._ @@ -15,5 +15,5 @@ final case class SamUserCombinedStateResponse( allowances: SamUserAllowances, attributes: SamUserAttributes, termsOfServiceDetails: TermsOfServiceDetails, - enterpriseFeatures: FilteredResourcesFlat + additionalDetails: Map[String, JsValue] ) diff --git a/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/UserRoutesV2Spec.scala b/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/UserRoutesV2Spec.scala index 589a82c84..22bb63b65 100644 --- a/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/UserRoutesV2Spec.scala +++ b/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/UserRoutesV2Spec.scala @@ -29,6 +29,7 @@ import java.time.Instant import org.broadinstitute.dsde.workbench.sam.matchers.TimeMatchers import org.broadinstitute.dsde.workbench.sam.util.SamRequestContext import org.mockito.Mockito.lenient +import spray.json.enrichAny class UserRoutesV2Spec extends AnyFlatSpec with Matchers with TimeMatchers with ScalatestRouteTest with MockitoSugar with TestSupport { val defaultUser: SamUser = Generator.genWorkbenchUserGoogle.sample.get @@ -274,7 +275,7 @@ class UserRoutesV2Spec extends AnyFlatSpec with Matchers with TimeMatchers with SamUserAllowances(enabled = true, termsOfService = true), SamUserAttributes(defaultUser.id, marketingConsent = true), TermsOfServiceDetails("v1", Instant.now(), permitsSystemUsage = true, isCurrentVersion = true), - FilteredResourcesFlat(Set(enterpriseFeature)) + Map("enterpriseFeatures" -> FilteredResourcesFlat(Set(enterpriseFeature)).toJson) ) val samRoutes = new MockSamRoutesBuilder(allUsersGroup) @@ -308,7 +309,7 @@ class UserRoutesV2Spec extends AnyFlatSpec with Matchers with TimeMatchers with response.termsOfServiceDetails.isCurrentVersion should be(userCombinedStateResponse.termsOfServiceDetails.isCurrentVersion) response.termsOfServiceDetails.permitsSystemUsage should be(userCombinedStateResponse.termsOfServiceDetails.permitsSystemUsage) response.termsOfServiceDetails.latestAcceptedVersion should be(userCombinedStateResponse.termsOfServiceDetails.latestAcceptedVersion) - response.enterpriseFeatures should be(filteresResourcesFlat) + response.additionalDetails should be(Map("enterpriseFeatures" -> filteresResourcesFlat.toJson)) } }