-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CORE-58] Cascade policy deletion #1564
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3616bde
try new api
calypsomatic abdf118
wrong tabbing?
calypsomatic 511f6cf
fix api
calypsomatic 5c2c881
update delete query
calypsomatic 4a80260
fix query
calypsomatic 08abd65
one more try
calypsomatic ef2be68
split into two
calypsomatic fc94de3
single transaction
calypsomatic e50536f
Merge branch 'develop' into core-58-cascade-policy
calypsomatic 4455509
test out sync and delete policies
calypsomatic 841c2c8
update order of operations
calypsomatic 2ad6f23
remove deletecascade
calypsomatic a9a3083
whoops
calypsomatic 5f1ac33
cleanup and add test
calypsomatic a6bcf06
removed commented out code and fix test
calypsomatic 8ba9c4e
Merge branch 'develop' into core-58-cascade-policy
calypsomatic 8c0ad7d
first pass updated delete resource
calypsomatic f78fb5a
scalafmt
calypsomatic 8b4fa1b
remove commented out code
calypsomatic bf02fc0
fix affected policy groups and add test
calypsomatic 34d18e8
sonar findings
calypsomatic 7428caf
expand test
calypsomatic 825b766
remove unnecessary method
calypsomatic e4f2975
don't sync policies
calypsomatic 71b8dd5
remove unused method
calypsomatic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3553,6 +3553,99 @@ class PostgresAccessPolicyDAOSpec extends AnyFreeSpec with Matchers with BeforeA | |
dao.listResourcesUsingAuthDomain(authDomainGroupName, samRequestContext).unsafeRunSync() shouldEqual Set.empty | ||
} | ||
} | ||
|
||
"findAffectedPolicyGroups" - { | ||
"returns parent and member policy groups" in { | ||
assume(databaseEnabled, databaseEnabledClue) | ||
|
||
// Create a resource with a policy | ||
dao.createResourceType(resourceType, samRequestContext).unsafeRunSync() | ||
|
||
val user = Generator.genWorkbenchUserBoth.sample.get | ||
dirDao.createUser(user, samRequestContext).unsafeRunSync() | ||
|
||
val parentResourceFullyQualifiedId = FullyQualifiedResourceId(resourceType.name, ResourceId("parent_resource")) | ||
val childResourceFullyQualifiedId = FullyQualifiedResourceId(resourceType.name, ResourceId("child_resource")) | ||
|
||
val parentPolicy = AccessPolicy( | ||
FullyQualifiedPolicyId(parentResourceFullyQualifiedId, AccessPolicyName("parentPolicyName")), | ||
Set(user.id), | ||
WorkbenchEmail("[email protected]"), | ||
resourceType.roles.map(_.roleName), | ||
Set(readAction, writeAction), | ||
Set.empty, | ||
false | ||
) | ||
val childPolicy = AccessPolicy( | ||
FullyQualifiedPolicyId(childResourceFullyQualifiedId, AccessPolicyName("childPolicyName")), | ||
Set(user.id), | ||
WorkbenchEmail("[email protected]"), | ||
resourceType.roles.map(_.roleName), | ||
Set(readAction, writeAction), | ||
Set.empty, | ||
false | ||
) | ||
|
||
val otherParentResourceFullyQualifiedId = FullyQualifiedResourceId(resourceType.name, ResourceId("other_parent_resource")) | ||
val otherParentPolicy = AccessPolicy( | ||
FullyQualifiedPolicyId(otherParentResourceFullyQualifiedId, AccessPolicyName("otherParentPolicyName")), | ||
Set(user.id), | ||
WorkbenchEmail("[email protected]"), | ||
resourceType.roles.map(_.roleName), | ||
Set(readAction, writeAction), | ||
Set.empty, | ||
false | ||
) | ||
|
||
val otherChildPolicy = AccessPolicy( | ||
FullyQualifiedPolicyId(childResourceFullyQualifiedId, AccessPolicyName("otherChildPolicyName")), | ||
Set(user.id), | ||
WorkbenchEmail("[email protected]"), | ||
resourceType.roles.map(_.roleName), | ||
Set(readAction, writeAction), | ||
Set.empty, | ||
false | ||
) | ||
|
||
val thirdPolicy = AccessPolicy( | ||
FullyQualifiedPolicyId(childResourceFullyQualifiedId, AccessPolicyName("thirdPolicyName")), | ||
Set(user.id), | ||
WorkbenchEmail("[email protected]"), | ||
resourceType.roles.map(_.roleName), | ||
Set(readAction, writeAction), | ||
Set.empty, | ||
false | ||
) | ||
|
||
val parentResource = | ||
Resource(parentResourceFullyQualifiedId.resourceTypeName, parentResourceFullyQualifiedId.resourceId, Set.empty, Set(parentPolicy)) | ||
val childResource = | ||
Resource( | ||
childResourceFullyQualifiedId.resourceTypeName, | ||
childResourceFullyQualifiedId.resourceId, | ||
Set.empty, | ||
Set(childPolicy, otherChildPolicy, thirdPolicy) | ||
) | ||
val otherResource = Resource( | ||
otherParentResourceFullyQualifiedId.resourceTypeName, | ||
otherParentResourceFullyQualifiedId.resourceId, | ||
Set.empty, | ||
Set(otherParentPolicy) | ||
) | ||
dao.createResource(parentResource, samRequestContext).unsafeRunSync() | ||
dao.createResource(childResource, samRequestContext).unsafeRunSync() | ||
dao.createResource(otherResource, samRequestContext).unsafeRunSync() | ||
|
||
dirDao.addGroupMember(otherParentPolicy.id, otherChildPolicy.id, samRequestContext).unsafeRunSync() | ||
|
||
// Add child policy to parent policy | ||
dirDao.addGroupMember(parentPolicy.id, childPolicy.id, samRequestContext).unsafeRunSync() | ||
|
||
val policyGroups = dao.findPolicyGroupsInUse(childResourceFullyQualifiedId, samRequestContext).unsafeRunSync() | ||
|
||
policyGroups should contain theSameElementsAs List((parentPolicy.id, childPolicy.id), (otherParentPolicy.id, otherChildPolicy.id)) | ||
} | ||
} | ||
} | ||
|
||
private def uuid: String = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findPolicyGroupMemberhips? findPolicyGroupParticipation? maybe findPolicyGroupsInUse to reflect the method it is supplanting?