Skip to content

Commit

Permalink
PIN-3515 Resolved PR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nttdata-rtorsoli committed Oct 25, 2023
1 parent 443fe43 commit 599902e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,16 @@ object ClientApiHandlers extends AkkaResponses {
success: T => Route
)(result: Try[T])(implicit contexts: Seq[(String, String)], logger: LoggerTakingImplicit[ContextFieldsToLog]): Route =
result match {
case Success(s) => success(s)
case Failure(ex: SecurityUserNotFound) => forbidden(ex, logMessage)
case Failure(ex: SelfcareEntityNotFilled) => forbidden(ex, logMessage)
case Failure(ex: InstitutionNotFound) => forbidden(ex, logMessage)
case Failure(ex: UserNotFound) => forbidden(ex, logMessage)
case Failure(ex) => internalServerError(ex, logMessage)
case Success(s) => success(s)
case Failure(ex) => internalServerError(ex, logMessage)
}

def getClientsWithKeysResponse[T](logMessage: String)(
success: T => Route
)(result: Try[T])(implicit contexts: Seq[(String, String)], logger: LoggerTakingImplicit[ContextFieldsToLog]): Route =
result match {
case Success(s) => success(s)
case Failure(ex: SecurityUserNotFound) => forbidden(ex, logMessage)
case Failure(ex: InstitutionNotFound) => forbidden(ex, logMessage)
case Failure(ex: UserNotFound) => forbidden(ex, logMessage)
case Failure(ex: SelfcareEntityNotFilled) => forbidden(ex, logMessage)
case Failure(ex) => internalServerError(ex, logMessage)
case Success(s) => success(s)
case Failure(ex) => internalServerError(ex, logMessage)
}

def deleteClientResponse[T](logMessage: String)(
Expand Down Expand Up @@ -119,8 +111,8 @@ object ClientApiHandlers extends AkkaResponses {
result match {
case Success(s) => success(s)
case Failure(ex: CreateKeysBadRequest) => badRequest(ex, logMessage)
case Failure(ex: InstitutionNotFound) => forbidden(ex, logMessage)
case Failure(ex: OrganizationNotAllowedOnClient) => forbidden(ex, logMessage)
case Failure(ex: UserNotFound) => forbidden(ex, logMessage)
case Failure(ex: ClientNotFound) => notFound(ex, logMessage)
case Failure(ex: KeysAlreadyExist) => conflict(ex, logMessage)
case Failure(ex) => internalServerError(ex, logMessage)
Expand All @@ -143,7 +135,6 @@ object ClientApiHandlers extends AkkaResponses {
case Success(s) => success(s)
case Failure(ex: OrganizationNotAllowedOnClient) => forbidden(ex, logMessage)
case Failure(ex: InstitutionNotFound) => forbidden(ex, logMessage)
case Failure(ex: UserNotFound) => forbidden(ex, logMessage)
case Failure(ex: ClientNotFound) => notFound(ex, logMessage)
case Failure(ex) => internalServerError(ex, logMessage)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ final case class ClientApiServiceImpl(
)(implicit contexts: Seq[(String, String)]): Future[Unit] = for {
users <- selfcareV2ClientService
.getInstitutionProductUsers(selfcareId, requesterUserId, userId.some, roles)
.map(_.map(_.toApi))
_ <- users.headOption.toFuture(SecurityUserNotFound(requesterUserId, userId))
} yield ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ class KeyOperationSpec
.returns(Future.successful(persistentClient))

Get() ~> service.createKeys(client.id.toString, keySeeds) ~> check {
status shouldEqual StatusCodes.InternalServerError
entityAs[Problem].errors.head.code shouldBe "007-9991"
status shouldEqual StatusCodes.Forbidden
entityAs[Problem].errors.head.code shouldBe "007-0023"
}
}

Expand Down

0 comments on commit 599902e

Please sign in to comment.