Skip to content

Commit

Permalink
fix UserServiceSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
tlangs committed Oct 20, 2023
1 parent 2b53f69 commit 8d64705
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.effect.IO
import cats.effect.unsafe.implicits.global
import org.broadinstitute.dsde.workbench.model._
import org.broadinstitute.dsde.workbench.sam.model.BasicWorkbenchGroup
import org.broadinstitute.dsde.workbench.sam.model.api.SamUser
import org.broadinstitute.dsde.workbench.sam.model.api.{SamUser, SamUserAttributes}
import org.broadinstitute.dsde.workbench.sam.util.SamRequestContext
import org.mockito.ArgumentMatchers
import org.mockito.IdiomaticMockito.StubbingOps
Expand Down Expand Up @@ -129,6 +129,11 @@ case class StatefulMockDirectoryDaoBuilder() extends MockitoSugar {
.when(mockedDirectoryDAO)
.deleteUser(any[WorkbenchUserId], any[SamRequestContext])

lenient()
.doReturn(IO.unit)
.when(mockedDirectoryDAO)
.setUserAttributes(any[SamUserAttributes], any[SamRequestContext])

def withExistingUser(samUser: SamUser): StatefulMockDirectoryDaoBuilder = withExistingUsers(Set(samUser))
def withExistingUsers(samUsers: Iterable[SamUser]): StatefulMockDirectoryDaoBuilder = {
samUsers.toSet.foreach(makeUserExist)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ case class MockUserServiceBuilder() extends IdiomaticMockito {
mockUserService.getUserAllowances(any[SamUser], any[SamRequestContext]) returns IO(
SamUserAllowances(allowed = false, enabled = false, termsOfService = false)
)
mockUserService.getUserAttributes(any[WorkbenchUserId], any[SamRequestContext]) returns IO(None)
}

private def makeUser(samUser: SamUser, mockUserService: UserService): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.broadinstitute.dsde.workbench.sam.google.GoogleExtensions
import org.broadinstitute.dsde.workbench.sam.matchers.BeSameUserMatcher.beSameUserAs
import org.broadinstitute.dsde.workbench.sam.matchers.TimeMatchers
import org.broadinstitute.dsde.workbench.sam.model._
import org.broadinstitute.dsde.workbench.sam.model.api.SamUser
import org.broadinstitute.dsde.workbench.sam.model.api.{SamUser, SamUserAttributes}
import org.broadinstitute.dsde.workbench.sam.service.UserServiceSpecs.{CreateUserSpec, GetUserStatusSpec, InviteUserSpec}
import org.broadinstitute.dsde.workbench.sam.util.SamRequestContext
import org.mockito.Mockito
Expand Down Expand Up @@ -123,6 +123,7 @@ class OldUserServiceMockSpec(_system: ActorSystem)
when(dirDAO.listUserDirectMemberships(defaultUser.id, samRequestContext)).thenReturn(IO(LazyList(allUsersGroup.id)))
when(dirDAO.setGoogleSubjectId(defaultUser.id, defaultUser.googleSubjectId.get, samRequestContext)).thenReturn(IO(()))
when(dirDAO.setUserAzureB2CId(defaultUser.id, defaultUser.azureB2CId.get, samRequestContext)).thenReturn(IO(()))
when(dirDAO.setUserAttributes(any[SamUserAttributes], any[SamRequestContext])).thenReturn(IO(()))

googleExtensions = mock[GoogleExtensions](RETURNS_SMART_NULLS)
when(googleExtensions.getOrCreateAllUsersGroup(any[DirectoryDAO], any[SamRequestContext])(any[ExecutionContext]))
Expand Down

0 comments on commit 8d64705

Please sign in to comment.