-
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
ID-1333 Add group version increment to onPolicyUpdate #1492
Merged
Ghost-in-a-Jar
merged 7 commits into
develop
from
PROD-972-add-policy-update-group-version-increment
Jul 16, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e9694ee
PROD-972 Add group version increment to onPolicyUpdate
Ghost-in-a-Jar e90559b
PROD-972 Add group version increment to onPolicyUpdate
Ghost-in-a-Jar e7b6492
add logging on group sync skip
Ghost-in-a-Jar de9bcb1
Add ancestor policy group version update
Ghost-in-a-Jar df10db6
fix GoogleExtensionSpec
Ghost-in-a-Jar 4715f7f
Add ResourceServiceSpec test case
Ghost-in-a-Jar f425110
Add test for constrained policy group version update
Ghost-in-a-Jar 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 |
---|---|---|
|
@@ -286,6 +286,8 @@ class ResourceServiceSpec | |
service.setPublic(policyToUpdate, false, samRequestContext).unsafeRunSync() | ||
service.isPublic(policyToUpdate, samRequestContext).unsafeRunSync() should equal(false) | ||
|
||
service.loadPolicy(policyToUpdate, samRequestContext).unsafeRunSync().get.version shouldEqual 3 | ||
|
||
// cleanup | ||
runAndWait(service.deleteResource(resource, samRequestContext)) | ||
} | ||
|
@@ -1164,7 +1166,7 @@ class ResourceServiceSpec | |
val policies = | ||
policyDAO.listAccessPolicies(resource, samRequestContext).unsafeRunSync().map(_.copy(email = WorkbenchEmail("[email protected]"))) | ||
|
||
assert(policies.contains(newPolicy)) | ||
assert(policies.contains(newPolicy.copy(version = 2))) | ||
} | ||
|
||
it should "should add a memberPolicy as a member when specified through policy identifiers" in { | ||
|
@@ -1285,6 +1287,13 @@ class ResourceServiceSpec | |
) | ||
).thenReturn(IO.unit) | ||
|
||
when( | ||
mockDirectoryDAO.updateGroupUpdatedDateAndVersionWithSession( | ||
any[WorkbenchGroupIdentity], | ||
any[SamRequestContext] | ||
) | ||
).thenReturn(IO.unit) | ||
|
||
runAndWait( | ||
resourceService.overwritePolicy( | ||
defaultResourceType, | ||
|
@@ -1325,6 +1334,12 @@ class ResourceServiceSpec | |
// function calls that should pass but what they return does not matter | ||
when(mockAccessPolicyDAO.overwritePolicy(ArgumentMatchers.eq(accessPolicy), any[SamRequestContext])).thenReturn(IO.pure(accessPolicy)) | ||
when(mockCloudExtensions.onGroupUpdate(ArgumentMatchers.eq(Seq(policyId)), ArgumentMatchers.eq(Set(member)), any[SamRequestContext])).thenReturn(IO.unit) | ||
when( | ||
mockDirectoryDAO.updateGroupUpdatedDateAndVersionWithSession( | ||
any[WorkbenchGroupIdentity], | ||
any[SamRequestContext] | ||
) | ||
).thenReturn(IO.unit) | ||
|
||
// overwrite policy with no members | ||
runAndWait( | ||
|
@@ -1412,7 +1427,7 @@ class ResourceServiceSpec | |
val policies = | ||
policyDAO.listAccessPolicies(resource, samRequestContext).unsafeRunSync().map(_.copy(email = WorkbenchEmail("[email protected]"))) | ||
|
||
assert(policies.contains(newPolicy)) | ||
assert(policies.contains(newPolicy.copy(version = 2))) | ||
} | ||
|
||
it should "fail if any members are not test.firecloud.org accounts" in { | ||
|
@@ -1486,7 +1501,7 @@ class ResourceServiceSpec | |
val policies = | ||
policyDAO.listAccessPolicies(resource, samRequestContext).unsafeRunSync().map(_.copy(email = WorkbenchEmail("[email protected]"))) | ||
|
||
assert(policies.contains(newPolicy)) | ||
assert(policies.contains(newPolicy.copy(version = 2))) | ||
} | ||
|
||
it should "call CloudExtensions.onGroupUpdate when members change" in { | ||
|
@@ -1516,6 +1531,12 @@ class ResourceServiceSpec | |
// function calls that should pass but what they return does not matter | ||
when(mockAccessPolicyDAO.overwritePolicyMembers(ArgumentMatchers.eq(policyId), ArgumentMatchers.eq(Set.empty), any[SamRequestContext])).thenReturn(IO.unit) | ||
when(mockCloudExtensions.onGroupUpdate(ArgumentMatchers.eq(Seq(policyId)), ArgumentMatchers.eq(Set(member)), any[SamRequestContext])).thenReturn(IO.unit) | ||
when( | ||
mockDirectoryDAO.updateGroupUpdatedDateAndVersionWithSession( | ||
any[WorkbenchGroupIdentity], | ||
any[SamRequestContext] | ||
) | ||
).thenReturn(IO.unit) | ||
|
||
// overwrite policy members with empty set | ||
runAndWait(resourceService.overwritePolicyMembers(policyId, Set.empty, samRequestContext)) | ||
|
@@ -1576,7 +1597,7 @@ class ResourceServiceSpec | |
|
||
val policies = policyDAO.listAccessPolicies(resource, samRequestContext).unsafeRunSync() | ||
|
||
assert(policies.contains(newPolicy)) | ||
assert(policies.contains(newPolicy.copy(version = 2))) | ||
} | ||
|
||
it should "fail when given an invalid action" in { | ||
|
@@ -2107,6 +2128,13 @@ class ResourceServiceSpec | |
IO.pure(LazyList(AccessPolicy(policyId, Set.empty, WorkbenchEmail(""), Set.empty, Set.empty, Set.empty, false))), | ||
IO.pure(LazyList(AccessPolicy(policyId, Set(member), WorkbenchEmail(""), Set.empty, Set.empty, Set.empty, false))) | ||
) | ||
when( | ||
mockDirectoryDAO.updateGroupUpdatedDateAndVersionWithSession( | ||
any[WorkbenchGroupIdentity], | ||
any[SamRequestContext] | ||
) | ||
).thenReturn(IO.unit) | ||
|
||
runAndWait(resourceService.addSubjectToPolicy(policyId, member, samRequestContext)) | ||
|
||
verify(mockCloudExtensions, Mockito.timeout(500)) | ||
|
@@ -2164,6 +2192,13 @@ class ResourceServiceSpec | |
IO.pure(LazyList(AccessPolicy(policyId, Set.empty, WorkbenchEmail(""), Set.empty, Set.empty, Set.empty, false))), | ||
IO.pure(LazyList(AccessPolicy(policyId, Set(member), WorkbenchEmail(""), Set.empty, Set.empty, Set.empty, false))) | ||
) | ||
when( | ||
mockDirectoryDAO.updateGroupUpdatedDateAndVersionWithSession( | ||
any[WorkbenchGroupIdentity], | ||
any[SamRequestContext] | ||
) | ||
).thenReturn(IO.unit) | ||
|
||
runAndWait(resourceService.removeSubjectFromPolicy(policyId, member, samRequestContext)) | ||
|
||
verify(mockCloudExtensions, Mockito.timeout(1000)) | ||
|
@@ -3122,7 +3157,9 @@ class ResourceServiceSpec | |
|
||
returnedPolicies should contain theSameElementsAs Set(expectedPolicy) | ||
|
||
policyDAO.loadPolicy(testPolicyId, samRequestContext).unsafeRunSync().map(_.copy(email = WorkbenchEmail(""))) shouldBe Some(expectedPolicy) | ||
policyDAO.loadPolicy(testPolicyId, samRequestContext).unsafeRunSync().map(_.copy(email = WorkbenchEmail(""))) shouldBe Some( | ||
expectedPolicy.copy(version = 2) | ||
) | ||
} | ||
|
||
it should "validate admin policies" in { | ||
|
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.
Note that the next thing that happens is onPolicyUpdateIfChanged which calls onPolicyUpdate if the policy actually changed.