Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-in-a-Jar committed Jan 31, 2024
1 parent c1f964b commit cbba4ed
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,18 @@ class UserService(
val userUpdate = UserUpdate(request.azureB2CId.map(_.value), request.googleSubjectId.map(_.value))

userUpdate match {
case UserUpdate(Some("null"), None) if user.googleSubjectId.isEmpty => IO.raiseError(new WorkbenchExceptionWithErrorReport(ErrorReport(StatusCodes.BadRequest, "Cannot null a user's azureB2CId when the user has no googleSubjectId")))
case UserUpdate(None, Some("null")) if user.azureB2CId.isEmpty => IO.raiseError(new WorkbenchExceptionWithErrorReport(ErrorReport(StatusCodes.BadRequest, "Cannot null a user's googleSubjectId when the user has no azureB2CId")))
case UserUpdate(Some("null"), None) if user.googleSubjectId.isEmpty =>
IO.raiseError(
new WorkbenchExceptionWithErrorReport(
ErrorReport(StatusCodes.BadRequest, "Cannot null a user's azureB2CId when the user has no googleSubjectId")
)
)
case UserUpdate(None, Some("null")) if user.azureB2CId.isEmpty =>
IO.raiseError(
new WorkbenchExceptionWithErrorReport(
ErrorReport(StatusCodes.BadRequest, "Cannot null a user's googleSubjectId when the user has no azureB2CId")
)
)
case _ =>
val updatedUser = if (request.azureB2CId.isDefined || request.googleSubjectId.isDefined) {
directoryDAO.updateUser(user, userUpdate, samRequestContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ case class StatefulMockDirectoryDaoBuilder() extends MockitoSugar {

// A user that only "exists" but isn't enabled or anything also does not have a Cloud Identifier
lenient()
.doReturn(IO(Option(samUser)))
.doReturn(IO(Option(samUser.copy(googleSubjectId = None, azureB2CId = None))))
.when(mockedDirectoryDAO)
.loadUser(ArgumentMatchers.eq(samUser.id), any[SamRequestContext])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,14 @@ class UpdateUserSpec extends UserServiceTestTraits {
}

// Assert
assert(error.errorReport.statusCode.value equals StatusCodes.BadRequest, "Nulling a user's azureB2CId when the user has no googleSubjectId should have a Bad Request status")
assert(error.errorReport.message equals "Cannot null a user's azureB2CId when the user has no googleSubjectId", "Nulling a user's azureB2CId when the user has no googleSubjectId should send back a invalid update message")
assert(
error.errorReport.statusCode.value equals StatusCodes.BadRequest,
"Nulling a user's azureB2CId when the user has no googleSubjectId should have a Bad Request status"
)
assert(
error.errorReport.message equals "Cannot null a user's azureB2CId when the user has no googleSubjectId",
"Nulling a user's azureB2CId when the user has no googleSubjectId should send back a invalid update message"
)
}
}
}
Expand All @@ -207,8 +213,14 @@ class UpdateUserSpec extends UserServiceTestTraits {
}

// Assert
assert(error.errorReport.statusCode.value equals StatusCodes.BadRequest, "Nulling a user's azureB2CId when the user has no googleSubjectId should have a Bad Request status")
assert(error.errorReport.message equals "Cannot null a user's azureB2CId when the user has no googleSubjectId", "Nulling a user's azureB2CId when the user has no googleSubjectId should send back a invalid update message")
assert(
error.errorReport.statusCode.value equals StatusCodes.BadRequest,
"Nulling a user's azureB2CId when the user has no googleSubjectId should have a Bad Request status"
)
assert(
error.errorReport.message equals "Cannot null a user's azureB2CId when the user has no googleSubjectId",
"Nulling a user's azureB2CId when the user has no googleSubjectId should send back a invalid update message"
)
}
}
}
Expand Down

0 comments on commit cbba4ed

Please sign in to comment.