From a321af9642abd7cb2f7aca6faaf03ab35049a091 Mon Sep 17 00:00:00 2001 From: Greg Polumbo <36171087+gpolumbo-broad@users.noreply.github.com> Date: Mon, 23 Oct 2023 00:24:34 -0400 Subject: [PATCH] ID-807 stubbing out Routes for new ToS routes (#1213) * ID-807 stubbing out Routes for new ToS routes * ID-807 stubbing out Routes for new ToS routes * ID-807 stubbing out Routes for new ToS routes --------- Co-authored-by: Greg Polumbo <> --- project/Settings.scala | 2 +- .../dsde/workbench/sam/api/SamRoutes.scala | 1 + .../sam/api/TermsOfServiceRoutes.scala | 67 ++++++++++++++++++- .../workbench/sam/api/MockSamRoutes.scala | 1 + 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/project/Settings.scala b/project/Settings.scala index e2f9c35c7..6a5903566 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -37,7 +37,7 @@ object Settings { "-language:existentials", // Existential types (besides wildcard types) can be written and inferred "-unchecked", // Enable additional warnings where generated code depends on assumptions. "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. - "-Xfatal-warnings", // Fail the compilation if there are any warnings. + "-Wconf:cat=deprecation:ws,any:e", // Fail the compilation if there are any warnings, except for deprecation warnings. "-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver. "-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error. "-Xlint:delayedinit-select", // Selecting member of DelayedInit. diff --git a/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/SamRoutes.scala b/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/SamRoutes.scala index c57a18edb..7158bf917 100644 --- a/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/SamRoutes.scala +++ b/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/SamRoutes.scala @@ -63,6 +63,7 @@ abstract class SamRoutes( oidcConfig.swaggerRoutes("swagger/api-docs.yaml") ~ oidcConfig.oauth2Routes ~ statusRoutes ~ + oldTermsOfServiceRoutes ~ termsOfServiceRoutes ~ withExecutionContext(ExecutionContext.global) { withSamRequestContext { samRequestContext => diff --git a/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/TermsOfServiceRoutes.scala b/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/TermsOfServiceRoutes.scala index 889dbcc5a..b0f0abfeb 100644 --- a/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/TermsOfServiceRoutes.scala +++ b/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/TermsOfServiceRoutes.scala @@ -1,5 +1,6 @@ package org.broadinstitute.dsde.workbench.sam.api +import akka.http.scaladsl.model.StatusCodes import akka.http.scaladsl.server import akka.http.scaladsl.server.Directives._ import org.broadinstitute.dsde.workbench.sam.service.TosService @@ -10,7 +11,8 @@ trait TermsOfServiceRoutes { val tosService: TosService implicit val executionContext: ExecutionContext - def termsOfServiceRoutes: server.Route = + @deprecated("Being replaced by REST-ful termsOfService routes") + def oldTermsOfServiceRoutes: server.Route = pathPrefix("tos") { path("text") { pathEndOrSingleSlash { @@ -29,4 +31,67 @@ trait TermsOfServiceRoutes { } } } + + def termsOfServiceRoutes: server.Route = + pathPrefix("termsOfService") { + pathPrefix("v1") { // api/termsOfService/v1 + pathEndOrSingleSlash { + get { + complete(StatusCodes.NotImplemented) + } + } ~ + pathPrefix("docs") { // api/termsOfService/v1/docs + pathEndOrSingleSlash { + get { + complete(StatusCodes.NotImplemented) + } + } ~ + pathPrefix("redirect") { // api/termsOfService/v1/docs/redirect + pathEndOrSingleSlash { + get { + complete(StatusCodes.NotImplemented) + } + } + } + } ~ + pathPrefix("user") { // api/termsOfService/v1/user + pathPrefix("self") { // api/termsOfService/v1/user/self + pathEndOrSingleSlash { + get { + complete(StatusCodes.NotImplemented) + } + } ~ + pathPrefix("accept") { // api/termsOfService/v1/user/accept + pathEndOrSingleSlash { + put { + complete(StatusCodes.NotImplemented) + } + } + } ~ + pathPrefix("reject") { // api/termsOfService/v1/user/reject + pathEndOrSingleSlash { + put { + complete(StatusCodes.NotImplemented) + } + } + } + } ~ + // The {user_id} route must be last otherwise it will try to parse the other routes incorrectly as user id's + pathPrefix(Segment) { userId => // api/termsOfService/v1/user/{userId} + pathEndOrSingleSlash { + get { + complete(StatusCodes.NotImplemented) + } + } ~ + pathPrefix("history") { // api/termsOfService/v1/user/{userId}/history + pathEndOrSingleSlash { + get { + complete(StatusCodes.NotImplemented) + } + } + } + } + } + } + } } diff --git a/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/MockSamRoutes.scala b/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/MockSamRoutes.scala index e2aefe7ab..5f69dc602 100644 --- a/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/MockSamRoutes.scala +++ b/src/test/scala/org/broadinstitute/dsde/workbench/sam/api/MockSamRoutes.scala @@ -60,6 +60,7 @@ abstract class MockSamRoutes( oidcConfig.swaggerRoutes("swagger/api-docs.yaml") ~ oidcConfig.oauth2Routes ~ statusRoutes ~ + oldTermsOfServiceRoutes ~ termsOfServiceRoutes ~ withExecutionContext(ExecutionContext.global) { withSamRequestContext { samRequestContext =>