Skip to content

Commit

Permalink
restore tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marctalbott committed Dec 10, 2024
1 parent b0fd1d1 commit ce376a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,6 @@ class RuntimeServiceInterpTest
with MockitoSugar {

it should "fail if user doesn't have project level permission" in {
val samService = mock[SamService[IO]]
val runtimeService = makeRuntimeService(samService = samService)
when(
samService.checkAuthorized(isEq(unauthorizedUserInfo.accessToken.token),
isEq(ProjectSamResourceId(cloudContextGcp.value)),
isEq(ProjectAction.CreateRuntime)
)(any())
).thenReturn(IO.raiseError(ForbiddenError(unauthorizedUserInfo.userEmail)))
val res = for {
r <- runtimeService
.createRuntime(
Expand Down Expand Up @@ -849,23 +841,15 @@ class RuntimeServiceInterpTest
exc shouldBe a[RuntimeNotFoundException]
}

it should "throw RuntimeNotFoundException when users don't have permission on the runtime" in isolatedDbTest {
val samService = mock[SamService[IO]]
val runtimeService = makeRuntimeService(samService = samService)
val samResource = RuntimeSamResourceId(UUID.randomUUID.toString)
when(
samService.checkAuthorized(isEq(unauthorizedUserInfo.accessToken.token),
isEq(samResource),
isEq(RuntimeAction.GetRuntimeStatus)
)(any())
).thenReturn(IO.raiseError(ForbiddenError(unauthorizedUserInfo.userEmail)))
val res = for {
testRuntime <- IO(makeCluster(1).copy(samResource = samResource).save())
getResponse <- runtimeService
.getRuntime(unauthorizedUserInfo, testRuntime.cloudContext, testRuntime.runtimeName)
.attempt
} yield getResponse.swap.toOption.get.isInstanceOf[RuntimeNotFoundException] shouldBe true
res.unsafeRunSync()(cats.effect.unsafe.IORuntime.global)
it should "fail to get a runtime when users don't have access to the project" in isolatedDbTest {
val exc = runtimeService
.getRuntime(unauthorizedUserInfo, cloudContextGcp, RuntimeName("cluster"))
.attempt
.unsafeRunSync()(cats.effect.unsafe.IORuntime.global)
.swap
.toOption
.get
exc shouldBe a[ForbiddenError]
}

it should "list runtimes" in isolatedDbTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,6 @@ class RuntimeV2ServiceInterpSpec extends AnyFlatSpec with LeonardoTestSuite with
val runtimeName = RuntimeName("clusterName1")
val workspaceId = WorkspaceId(UUID.randomUUID())

val samService = mock[SamService[IO]]
when(
samService.checkAuthorized(unauthorizedUserInfo.accessToken.token,
WorkspaceResourceSamResourceId(workspaceId),
WorkspaceAction.Compute
)
).thenReturn(IO.raiseError(ForbiddenError(unauthorizedUserInfo.userEmail)))
val runtimeV2Service = makeInterp(samService = samService)

val thrown = the[ForbiddenError] thrownBy {
runtimeV2Service
.createRuntime(unauthorizedUserInfo, runtimeName, workspaceId, false, defaultCreateAzureRuntimeReq)
Expand Down

0 comments on commit ce376a0

Please sign in to comment.