Skip to content

Commit

Permalink
removed commented out code and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
calypsomatic committed Oct 21, 2024
1 parent 5f1ac33 commit a6bcf06
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] =
Expand Down

0 comments on commit a6bcf06

Please sign in to comment.