-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PROD-972 Add group version increment to onPolicyUpdate
- Loading branch information
1 parent
e9694ee
commit e90559b
Showing
1 changed file
with
40 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1164,7 +1164,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 +1285,13 @@ class ResourceServiceSpec | |
) | ||
).thenReturn(IO.unit) | ||
|
||
when( | ||
mockDirectoryDAO.updateGroupUpdatedDateAndVersionWithSession( | ||
any[WorkbenchGroupIdentity], | ||
any[SamRequestContext] | ||
) | ||
).thenReturn(IO.unit) | ||
|
||
runAndWait( | ||
resourceService.overwritePolicy( | ||
defaultResourceType, | ||
|
@@ -1325,6 +1332,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 +1425,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 +1499,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 +1529,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 +1595,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 +2126,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 +2190,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 +3155,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 { | ||
|