-
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.
ID-1369 Admin endpoint repair access (#1528)
* ID-1369 New admin endpoint - repair cloud access. * ID-1369 New admin endpoint - repair cloud access. * fix test
- Loading branch information
1 parent
524fbc0
commit b5048c1
Showing
7 changed files
with
119 additions
and
4 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
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
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ import cats.effect.IO | |
import cats.effect.unsafe.implicits.{global => globalEc} | ||
import org.broadinstitute.dsde.workbench.model._ | ||
import org.broadinstitute.dsde.workbench.sam.Generator.{arbNonPetEmail => _, _} | ||
import org.broadinstitute.dsde.workbench.sam.TestSupport.{databaseEnabled, databaseEnabledClue, truncateAll} | ||
import org.broadinstitute.dsde.workbench.sam.TestSupport.{databaseEnabled, databaseEnabledClue, googleServicesConfig, truncateAll} | ||
import org.broadinstitute.dsde.workbench.sam.dataAccess.{DirectoryDAO, PostgresDirectoryDAO} | ||
import org.broadinstitute.dsde.workbench.sam.google.GoogleExtensions | ||
import org.broadinstitute.dsde.workbench.sam.matchers.BeSameUserMatcher.beSameUserAs | ||
|
@@ -715,4 +715,40 @@ class OldUserServiceSpec(_system: ActorSystem) | |
assert(service.validateEmailAddress(WorkbenchEmail("[email protected]"), Seq.empty, Seq("bar.com")).attempt.unsafeRunSync().isLeft) | ||
assert(service.validateEmailAddress(WorkbenchEmail("[email protected]"), Seq.empty, Seq("bar.com")).attempt.unsafeRunSync().isLeft) | ||
} | ||
|
||
"UserService repairCloudAccess" should "create a proxy group for a user and add it to any groups they are a member of" in { | ||
assume(databaseEnabled, databaseEnabledClue) | ||
|
||
// Create user | ||
val inviteeEmail = genNonPetEmail.sample.get | ||
service.inviteUser(inviteeEmail, samRequestContext).unsafeRunSync() | ||
val invitedUserId = dirDAO.loadSubjectFromEmail(inviteeEmail, samRequestContext).unsafeRunSync().value.asInstanceOf[WorkbenchUserId] | ||
|
||
val userInPostgres = dirDAO.loadUser(invitedUserId, samRequestContext).unsafeRunSync() | ||
userInPostgres.value should { | ||
equal(SamUser(invitedUserId, None, inviteeEmail, None, false)) | ||
} | ||
|
||
val registeringUser = genWorkbenchUserGoogle.sample.get.copy(email = inviteeEmail) | ||
runAndWait(service.createUser(registeringUser, samRequestContext)) | ||
|
||
verify(googleExtensions).onUserCreate(SamUser(invitedUserId, None, inviteeEmail, None, false), samRequestContext) | ||
|
||
verify(googleExtensions).onGroupUpdate(Seq.empty, Set(invitedUserId), samRequestContext) | ||
|
||
val updatedUserInPostgres = dirDAO.loadUser(invitedUserId, samRequestContext).unsafeRunSync() | ||
updatedUserInPostgres.value shouldBe SamUser(invitedUserId, registeringUser.googleSubjectId, inviteeEmail, None, true) | ||
|
||
val proxyGroup = | ||
WorkbenchGroupName(s"${googleServicesConfig.resourceNamePrefix.getOrElse("")}PROXY_${invitedUserId.value}@${googleServicesConfig.appsDomain}") | ||
// delete proxy group | ||
runAndWait(dirDAO.deleteGroup(proxyGroup, samRequestContext)) | ||
|
||
// Run test | ||
service.repairCloudAccess(invitedUserId, samRequestContext).unsafeRunSync() | ||
|
||
verify(googleExtensions).onUserCreate(SamUser(invitedUserId, registeringUser.googleSubjectId, inviteeEmail, None, true), samRequestContext) | ||
|
||
verify(googleExtensions).onGroupUpdate(Seq(allUsersGroup.id), Set(invitedUserId), samRequestContext) | ||
} | ||
} |