Skip to content

Commit

Permalink
ID-1369 Repair cloud access followup, increment group version (#1530)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-in-a-Jar authored Aug 29, 2024
1 parent 0bf45d3 commit ec415b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,11 @@ class UserService(
maybeUser.flatMap {
case Some(user) =>
for {
_ <- cloudExtensions.onUserCreate(user, samRequestContext)
_ <- cloudExtensions.onUserEnable(user, samRequestContext)
// if the user is already created and enabled, then recover and just add them to the groups they should be in
_ <- cloudExtensions.onUserCreate(user, samRequestContext).recover { case _ => () }
_ <- cloudExtensions.onUserEnable(user, samRequestContext).recover { case _ => () }
groups <- directoryDAO.listUserDirectMemberships(user.id, samRequestContext)
_ = groups.map(g => directoryDAO.updateGroupUpdatedDateAndVersionWithSession(g, samRequestContext))
_ <- cloudExtensions.onGroupUpdate(groups, Set(user.id), samRequestContext)
} yield IO.pure(())
case None => IO.raiseError(new WorkbenchExceptionWithErrorReport(ErrorReport(StatusCodes.NotFound, s"User $workbenchUserId not found")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,11 @@ class OldUserServiceSpec(_system: ActorSystem)
val updatedUserInPostgres = dirDAO.loadUser(invitedUserId, samRequestContext).unsafeRunSync()
updatedUserInPostgres.value shouldBe SamUser(invitedUserId, registeringUser.googleSubjectId, inviteeEmail, None, true)

// add user to group
val group = BasicWorkbenchGroup(WorkbenchGroupName("testGroup"), Set.empty, WorkbenchEmail("[email protected]"))
runAndWait(dirDAO.createGroup(group, None, samRequestContext))
runAndWait(dirDAO.addGroupMember(group.id, invitedUserId, samRequestContext))

val proxyGroup =
WorkbenchGroupName(s"${googleServicesConfig.resourceNamePrefix.getOrElse("")}PROXY_${invitedUserId.value}@${googleServicesConfig.appsDomain}")
// delete proxy group
Expand All @@ -749,6 +754,10 @@ class OldUserServiceSpec(_system: ActorSystem)

verify(googleExtensions).onUserCreate(updatedUserInPostgres.get, samRequestContext)
verify(googleExtensions).onUserEnable(updatedUserInPostgres.get, samRequestContext)
verify(googleExtensions).onGroupUpdate(Seq(allUsersGroup.id), Set(invitedUserId), samRequestContext)
verify(googleExtensions).onGroupUpdate(Seq(allUsersGroup.id, group.id), Set(invitedUserId), samRequestContext)

// get group from db
val groupWithUpdatedVersion = runAndWait(dirDAO.loadGroup(group.id, samRequestContext))
groupWithUpdatedVersion.get.version shouldBe group.version + 1
}
}

0 comments on commit ec415b9

Please sign in to comment.