Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ignore me, not merging] WIP hello-world endpoint #4388

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class AppDependenciesBuilder(baselineDependenciesBuilder: BaselineDependenciesBu
as: ActorSystem,
dbReference: DbReference[IO]
): Resource[IO, ServicesDependencies] = {
val helloService = new HelloService()
val statusService = new StatusService(baselineDependencies.samDAO, dbReference)
val diskV2Service = new DiskV2ServiceInterp[IO](
ConfigReader.appConfig.persistentDisk,
Expand Down Expand Up @@ -125,6 +126,7 @@ class AppDependenciesBuilder(baselineDependenciesBuilder: BaselineDependenciesBu
Resource.make[IO, ServicesDependencies](
IO(
ServicesDependencies(
helloService,
statusService,
dependenciesRegistry,
diskV2Service,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

val httpRoutes = new HttpRoutes(
servicesDependencies.baselineDependencies.openIDConnectConfiguration,
servicesDependencies.helloService,

Check warning on line 63 in http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/Boot.scala

View check run for this annotation

Codecov / codecov/patch

http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/Boot.scala#L63

Added line #L63 was not covered by tests
servicesDependencies.statusService,
servicesDependencies.cloudSpecificDependenciesRegistry,
servicesDependencies.diskV2Service,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ final case class LeoAppDependencies(
* Contains all dependencies for the creation of the HTTP routes (services).
*/
final case class ServicesDependencies(
helloService: HelloService,
statusService: StatusService,
cloudSpecificDependenciesRegistry: ServicesRegistry,
diskV2Service: DiskV2Service[IO],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.broadinstitute.dsde.workbench.leonardo.http.api

import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server
import akka.http.scaladsl.server.Directives.{complete, get, pathEndOrSingleSlash, pathPrefix}
import org.broadinstitute.dsde.workbench.leonardo.http.service.HelloService

class HelloRoutes(helloService: HelloService) {
val routes: server.Route =
pathPrefix("hello") {
pathEndOrSingleSlash {
get {
complete(StatusCodes.OK -> helloService.getResponse)

Check warning on line 13 in http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/api/HelloRoutes.scala

View check run for this annotation

Codecov / codecov/patch

http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/api/HelloRoutes.scala#L11-L13

Added lines #L11 - L13 were not covered by tests
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import scala.concurrent.{ExecutionContext, Future}

class HttpRoutes(
oidcConfig: OpenIDConnectConfiguration,
helloService: HelloService,
statusService: StatusService,
gcpOnlyServicesRegistry: ServicesRegistry,
diskV2Service: DiskV2Service[IO],
Expand All @@ -41,6 +42,7 @@ class HttpRoutes(
enableAzureOnlyRoutes: Boolean = false
)(implicit ec: ExecutionContext, ac: ActorSystem, metrics: OpenTelemetryMetrics[IO], logger: StructuredLogger[IO]) {

private val helloRoutes = new HelloRoutes(helloService)
private val statusRoutes = new StatusRoutes(statusService)
private val corsSupport = new CorsSupport(contentSecurityPolicy, refererConfig)
private val kubernetesRoutes = new AppRoutes(kubernetesService, userInfoDirectives)
Expand Down Expand Up @@ -123,7 +125,8 @@ class HttpRoutes(
"swagger/api-docs.yaml"
) ~ oidcConfig.oauth2Routes ~ proxyRoutes.get.route ~ statusRoutes.route ~
pathPrefix("api") {
runtimeRoutes.get.routes ~ runtimeV2Routes.routes ~
helloRoutes.routes ~
runtimeRoutes.get.routes ~ runtimeV2Routes.routes ~
diskRoutes.get.routes ~ kubernetesRoutes.routes ~ appV2Routes.routes ~ diskV2Routes.routes ~ adminRoutes.routes ~
resourcesRoutes.get.routes
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.broadinstitute.dsde.workbench.leonardo.http.service;

import cats.effect.IO

class HelloService {
def getResponse: IO[String] = IO.pure("Hello, World!")

Check warning on line 6 in http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/service/HelloService.scala

View check run for this annotation

Codecov / codecov/patch

http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/http/service/HelloService.scala#L6

Added line #L6 was not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class HttpRoutesSpec
val routes =
new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
createGcpOnlyServicesRegistry(),
MockDiskV2ServiceInterp,
Expand All @@ -73,6 +74,7 @@ class HttpRoutesSpec

val httpRoutesAzureOnly = new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
createGcpOnlyServicesRegistry(),
MockDiskV2ServiceInterp,
Expand All @@ -88,6 +90,7 @@ class HttpRoutesSpec
val routesWithStrictRefererConfig =
new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
createGcpOnlyServicesRegistry(),
MockDiskV2ServiceInterp,
Expand All @@ -102,6 +105,7 @@ class HttpRoutesSpec
val routesWithWildcardReferer =
new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
createGcpOnlyServicesRegistry(),
MockDiskV2ServiceInterp,
Expand All @@ -116,6 +120,7 @@ class HttpRoutesSpec
val routesWithDisabledRefererConfig =
new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
createGcpOnlyServicesRegistry(),
MockDiskV2ServiceInterp,
Expand Down Expand Up @@ -963,6 +968,7 @@ class HttpRoutesSpec

new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
gcpOnlyServicesRegistry,
MockDiskV2ServiceInterp,
Expand All @@ -984,6 +990,7 @@ class HttpRoutesSpec

new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
gcpOnlyServicesRegistry,
MockDiskV2ServiceInterp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ class ProxyRoutesSpec

val httpRoutes = new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
gcpOnlyServicesRegistry,
MockDiskV2ServiceInterp,
Expand Down Expand Up @@ -728,6 +729,7 @@ class ProxyRoutesSpec

new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
gcpOnlyServicesRegistry,
MockDiskV2ServiceInterp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ trait TestLeoRoutes {
MockGoogleOAuth2Service
)

val helloService = new HelloService()
val statusService =
new StatusService(mockSamDAO, testDbRef, pollInterval = 1.second)
val timedUserInfo = defaultUserInfo.copy(tokenExpiresIn = tokenAge)
Expand Down Expand Up @@ -208,6 +209,7 @@ trait TestLeoRoutes {
val httpRoutes =
new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
gcpOnlyServicesRegistry,
MockDiskV2ServiceInterp,
Expand All @@ -222,6 +224,7 @@ trait TestLeoRoutes {
val timedHttpRoutes =
new HttpRoutes(
openIdConnectionConfiguration,
helloService,
statusService,
gcpOnlyServicesRegistry,
MockDiskV2ServiceInterp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class LeoProvider extends AnyFlatSpec with BeforeAndAfterAll with PactVerifier {
implicit val system: ActorSystem = ActorSystem("leotests")

val mockOpenIDConnectConfiguration: OpenIDConnectConfiguration = mock[OpenIDConnectConfiguration]
val mockHelloService: HelloService = mock[HelloService]
val mockStatusService: StatusService = mock[StatusService]
val mockProxyService: ProxyService = mock[ProxyService]
val mockRuntimeService: RuntimeService[IO] = mock[RuntimeService[IO]]
Expand All @@ -63,6 +64,7 @@ class LeoProvider extends AnyFlatSpec with BeforeAndAfterAll with PactVerifier {
val routes =
new HttpRoutes(
mockOpenIDConnectConfiguration,
mockHelloService,
mockStatusService,
gcpOnlyServicesRegistry,
mockDiskV2Service,
Expand Down
Loading