Skip to content

Commit

Permalink
Change enterpriseFeatures to additionalDetails in resp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-in-a-Jar committed May 20, 2024
1 parent d635c02 commit e091b55
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/main/resources/swagger/api-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -15,5 +15,5 @@ final case class SamUserCombinedStateResponse(
allowances: SamUserAllowances,
attributes: SamUserAttributes,
termsOfServiceDetails: TermsOfServiceDetails,
enterpriseFeatures: FilteredResourcesFlat
additionalDetails: Map[String, JsValue]
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
}
}

Expand Down

0 comments on commit e091b55

Please sign in to comment.