Skip to content

Commit

Permalink
Add unit tests for sam policy maps
Browse files Browse the repository at this point in the history
  • Loading branch information
rtitle committed Sep 12, 2024
1 parent f999c28 commit dd8cb3b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3339,4 +3339,21 @@ class AppServiceInterpTest extends AnyFlatSpec with AppServiceInterpSpec with Le
.unsafeRunSync()(cats.effect.unsafe.IORuntime.global)
}
}

it should "get a correct sam policy map for apps" in {
val map1 = LeoAppServiceInterp.getAppSamPolicyMap(userEmail, None)
map1 should have size 1
map1 should contain key "creator"
map1("creator") shouldBe SamPolicyData(List(userEmail), List(AppRole.Creator.asString))

val map2 = LeoAppServiceInterp.getAppSamPolicyMap(userEmail, Some(AppAccessScope.UserPrivate))
map2 should have size 1
map2 should contain key "creator"
map2("creator") shouldBe SamPolicyData(List(userEmail), List(AppRole.Creator.asString))

val map3 = LeoAppServiceInterp.getAppSamPolicyMap(userEmail, Some(AppAccessScope.WorkspaceShared))
map3 should have size 1
map3 should contain key "owner"
map3("owner") shouldBe SamPolicyData(List(userEmail), List(SharedAppRole.Owner.asString))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,13 @@ class DiskServiceInterpTest

res.unsafeRunSync()(cats.effect.unsafe.IORuntime.global)
}

it should "get a correct sam policy map for disks" in {
val map = DiskServiceInterp.getDiskSamPolicyMap(userEmail)
map should have size 1
map should contain key "creator"
map("creator") shouldBe SamPolicyData(List(userEmail), List(PersistentDiskRole.Creator.asString))
}
}

class MockGoogleProjectDAOWithCustomAncestors(customAncestors: Map[GoogleProject, String])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.broadinstitute.dsde.workbench.leonardo.dao.MockDockerDAO
import org.broadinstitute.dsde.workbench.leonardo.db._
import org.broadinstitute.dsde.workbench.leonardo.http.service.RuntimeServiceInterp.{
calculateAutopauseThreshold,
getRuntimeSamPolicyMap,
getToolFromImages
}
import org.broadinstitute.dsde.workbench.leonardo.model.SamResourceAction.{
Expand Down Expand Up @@ -2481,6 +2482,13 @@ class RuntimeServiceInterpTest
tool shouldBe Some(Tool.RStudio)
}

it should "get a correct sam policy map for runtimes" in {
val map = getRuntimeSamPolicyMap(userEmail)
map should have size 1
map should contain key "creator"
map("creator") shouldBe SamPolicyData(List(userEmail), List(RuntimeRole.Creator.asString))
}

private def withLeoPublisher(
publisherQueue: Queue[IO, LeoPubsubMessage]
)(validations: IO[Assertion]): IO[Assertion] = {
Expand Down

0 comments on commit dd8cb3b

Please sign in to comment.