diff --git a/src/main/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/AccessPolicyDAO.scala b/src/main/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/AccessPolicyDAO.scala index 57c42f1d1..c59ec84f4 100644 --- a/src/main/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/AccessPolicyDAO.scala +++ b/src/main/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/AccessPolicyDAO.scala @@ -130,7 +130,6 @@ trait AccessPolicyDAO { samRequestContext: SamRequestContext ): IO[Seq[FilterResourcesResult]] -// def checkPolicyGroupsInUse(resourceId: FullyQualifiedResourceId, samRequestContext: SamRequestContext): IO[List[Map[String, String]]] } sealed abstract class LoadResourceAuthDomainResult diff --git a/src/main/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/PostgresAccessPolicyDAO.scala b/src/main/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/PostgresAccessPolicyDAO.scala index 80126cccf..8b0fd10fa 100644 --- a/src/main/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/PostgresAccessPolicyDAO.scala +++ b/src/main/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/PostgresAccessPolicyDAO.scala @@ -997,37 +997,6 @@ class PostgresAccessPolicyDAO( } } -// override def checkPolicyGroupsInUse(resourceId: FullyQualifiedResourceId, samRequestContext: SamRequestContext): IO[List[Map[String, String]]] = { -// val g = GroupTable.syntax("g") -// val pg = GroupTable.syntax("pg") // problematic group -// val gm = GroupMemberTable.syntax("gm") -// val p = PolicyTable.syntax("p") -// -// readOnlyTransaction("checkPolicyGroupsInUse", samRequestContext) { implicit session => -// val problematicGroupsQuery = -// samsql"""select ${g.result.id}, ${g.result.name}, array_agg(${pg.name}) as ${pg.resultName.name} -// from ${GroupTable as g} -// join ${GroupMemberTable as gm} on ${g.id} = ${gm.memberGroupId} -// join ${GroupTable as pg} on ${gm.groupId} = ${pg.id} -// where ${g.id} in -// (select distinct ${gm.result.memberGroupId} -// from ${GroupMemberTable as gm} -// join ${PolicyTable as p} on ${gm.memberGroupId} = ${p.groupId} -// where ${p.resourceId} = (${loadResourcePKSubQuery(resourceId)})) -// group by ${g.id}, ${g.name}""" -// problematicGroupsQuery -// .map(rs => -// Map( -// "groupId" -> rs.get[GroupPK](g.resultName.id).value.toString, -// "groupName" -> rs.get[String](g.resultName.name), -// "still used in group(s):" -> rs.get[String](pg.resultName.name) -// ) -// ) -// .list() -// .apply() -// } -// } - override def loadPolicy(resourceAndPolicyName: FullyQualifiedPolicyId, samRequestContext: SamRequestContext): IO[Option[AccessPolicy]] = listPolicies(resourceAndPolicyName.resource, limitOnePolicy = Option(resourceAndPolicyName.accessPolicyName), samRequestContext).map(_.headOption) diff --git a/src/test/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/MockAccessPolicyDAO.scala b/src/test/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/MockAccessPolicyDAO.scala index dcabbb3bd..73f95d880 100644 --- a/src/test/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/MockAccessPolicyDAO.scala +++ b/src/test/scala/org/broadinstitute/dsde/workbench/sam/dataAccess/MockAccessPolicyDAO.scala @@ -123,9 +123,6 @@ class MockAccessPolicyDAO(private val resourceTypes: mutable.Map[ResourceTypeNam policies -= policy } -// override def checkPolicyGroupsInUse(resourceId: FullyQualifiedResourceId, samRequestContext: SamRequestContext): IO[List[Map[String, String]]] = -// IO.pure(List.empty) - override def listAccessPolicies( resourceTypeName: ResourceTypeName, user: WorkbenchUserId, diff --git a/src/test/scala/org/broadinstitute/dsde/workbench/sam/service/ResourceServiceSpec.scala b/src/test/scala/org/broadinstitute/dsde/workbench/sam/service/ResourceServiceSpec.scala index 7f2746157..5e85e19e3 100644 --- a/src/test/scala/org/broadinstitute/dsde/workbench/sam/service/ResourceServiceSpec.scala +++ b/src/test/scala/org/broadinstitute/dsde/workbench/sam/service/ResourceServiceSpec.scala @@ -2384,7 +2384,7 @@ class ResourceServiceSpec // Create a resource with a policy val ownerRoleName = ResourceRoleName("owner") val resourceType = ResourceType( - ResourceTypeName(UUID.randomUUID().toString), + defaultResourceType.name, Set(SamResourceActionPatterns.delete, ResourceActionPattern("view", "", false)), Set(ResourceRole(ownerRoleName, Set(ResourceAction("delete"), ResourceAction("view")))), ownerRoleName @@ -2428,7 +2428,7 @@ class ResourceServiceSpec service.listResourcePolicies(FullyQualifiedResourceId(resourceType.name, resourceName), samRequestContext).unsafeRunSync() policy2Emails.subsetOf(updatedPolicies.head.policy.memberEmails) shouldBe true // Delete resource; should not throw an error - runAndWait(service.deleteResource(FullyQualifiedResourceId(defaultResourceType.name, resourceName2), samRequestContext)) + runAndWait(service.deleteResource(FullyQualifiedResourceId(resourceType.name, resourceName2), samRequestContext)) // Verify that policies are no longer in group val updatedPolicies2: Seq[AccessPolicyResponseEntry] =