Skip to content

Commit

Permalink
fix existing tests and add httpRoute unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LizBaldo committed Feb 2, 2024
1 parent f2c4fca commit 2692942
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class HttpRoutesSpec
MockAppService,
new MockRuntimeV2Interp,
MockAdminServiceInterp,
MockResourcesService,
timedUserInfoDirectives,
contentSecurityPolicy,
refererConfig
Expand All @@ -74,6 +75,7 @@ class HttpRoutesSpec
MockAppService,
new MockRuntimeV2Interp,
MockAdminServiceInterp,
MockResourcesService,
timedUserInfoDirectives,
contentSecurityPolicy,
RefererConfig(Set("bvdp-saturn-dev.appspot.com/"), true)
Expand All @@ -90,6 +92,7 @@ class HttpRoutesSpec
MockAppService,
new MockRuntimeV2Interp,
MockAdminServiceInterp,
MockResourcesService,
timedUserInfoDirectives,
contentSecurityPolicy,
RefererConfig(Set("*", "bvdp-saturn-dev.appspot.com/"), true)
Expand All @@ -106,6 +109,7 @@ class HttpRoutesSpec
MockAppService,
new MockRuntimeV2Interp,
MockAdminServiceInterp,
MockResourcesService,
timedUserInfoDirectives,
contentSecurityPolicy,
RefererConfig(Set.empty, false)
Expand Down Expand Up @@ -851,6 +855,24 @@ class HttpRoutesSpec
}
}

it should "run a basic delete all resources request" in {
Delete(
"/api/google/v1/resources/googleProject1/deleteAll?deleteInCloud=true?deleteDisk=false"
) ~> httpRoutes.route ~> check {
status shouldEqual StatusCodes.Accepted
validateRawCookie(header("Set-Cookie"))
}
}

it should "fail to run a basic delete all resources request if both flags are false" in {
Delete(
"/api/google/v1/resources/googleProject1/deleteAll?deleteInCloud=false?deleteDisk=false"
) ~> httpRoutes.route ~> check {
status shouldEqual StatusCodes.BadRequest
validateRawCookie(header("Set-Cookie"))
}
}

// Validate encoding/decoding of RuntimeConfigRequest types
// TODO should these decoders move to JsonCodec in core module?

Expand Down Expand Up @@ -902,6 +924,7 @@ class HttpRoutesSpec
MockAppService,
runtimev2Service,
MockAdminServiceInterp,
MockResourcesService,
timedUserInfoDirectives,
contentSecurityPolicy,
refererConfig
Expand All @@ -918,6 +941,7 @@ class HttpRoutesSpec
kubernetesService,
runtimev2Service,
MockAdminServiceInterp,
MockResourcesService,
timedUserInfoDirectives,
contentSecurityPolicy,
refererConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ class ProxyRoutesSpec
leoKubernetesService,
runtimev2Service,
MockAdminServiceInterp,
MockResourcesService,
userInfoDirectives,
contentSecurityPolicy,
refererConfig
Expand Down Expand Up @@ -720,6 +721,7 @@ class ProxyRoutesSpec
leoKubernetesService,
runtimev2Service,
MockAdminServiceInterp,
MockResourcesService,
userInfoDirectives,
contentSecurityPolicy,
useRefererConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ trait TestLeoRoutes {
leoKubernetesService,
runtimev2Service,
MockAdminServiceInterp,
MockResourcesService,
userInfoDirectives,
contentSecurityPolicy,
refererConfig
Expand All @@ -222,6 +223,7 @@ trait TestLeoRoutes {
leoKubernetesService,
runtimev2Service,
MockAdminServiceInterp,
MockResourcesService,
timedUserInfoDirectives,
contentSecurityPolicy,
refererConfig
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.broadinstitute.dsde.workbench.leonardo.http.service

import cats.mtl.Ask
import cats.effect.IO
import org.broadinstitute.dsde.workbench.leonardo.AppContext
import org.broadinstitute.dsde.workbench.model.google.GoogleProject
import org.broadinstitute.dsde.workbench.model.UserInfo

object MockResourcesService extends ResourcesService[IO] {

def deleteAllResources(userInfo: UserInfo, googleProject: GoogleProject, deleteInCloud: Boolean, deleteDisk: Boolean)(
implicit as: Ask[IO, AppContext]
): IO[Unit] = IO.unit
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.broadinstitute.dsde.workbench.leonardo
package http
package service

import org.broadinstitute.dsde.workbench.leonardo.db.TestComponent
import org.scalatest.flatspec.AnyFlatSpec

final class ResourcesServiceInterpSpec extends AnyFlatSpec with LeonardoTestSuite with TestComponent {}

0 comments on commit 2692942

Please sign in to comment.