From 9e6fa24b222d8dff05f76f2e6e0c85882e2bacad Mon Sep 17 00:00:00 2001 From: nttdata-rtorsoli Date: Thu, 28 Sep 2023 09:05:52 +0200 Subject: [PATCH 1/5] PIN-3996 Check when EService is published --- .../catalogprocess/api/impl/Converter.scala | 7 + .../api/impl/ProcessApiServiceImpl.scala | 18 ++ .../api/impl/ResponseHandlers.scala | 4 + .../errors/CatalogProcessErrors.scala | 3 + .../catalogprocess/CatalogProcessSpec.scala | 171 +++++++++++++++++- .../interop/catalogprocess/SpecData.scala | 110 ++++++++++- 6 files changed, 311 insertions(+), 2 deletions(-) diff --git a/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/Converter.scala b/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/Converter.scala index 33078b34..d282a22a 100644 --- a/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/Converter.scala +++ b/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/Converter.scala @@ -399,18 +399,25 @@ object Converter { singleAnswers = p.singleAnswers.map(_.toApi), multiAnswers = p.multiAnswers.map(_.toApi) ) + + def toTemplate: Commons.RiskAnalysisForm = Commons.RiskAnalysisForm( + version = p.version, + answers = (p.singleAnswers.map(_.toTemplate).flatten ++ p.multiAnswers.map(_.toTemplate).flatten).toMap + ) } implicit class CatalogRiskAnalysisSingleAnswerObjectWrapper(private val p: readmodel.CatalogRiskAnalysisSingleAnswer) extends AnyVal { def toApi: EServiceRiskAnalysisSingleAnswer = EServiceRiskAnalysisSingleAnswer(id = p.id, key = p.key, value = p.value) + def toTemplate: Map[String, Seq[String]] = Map(p.key -> p.value.toSeq) } implicit class CatalogRiskAnalysisMultiAnswerObjectWrapper(private val p: readmodel.CatalogRiskAnalysisMultiAnswer) extends AnyVal { def toApi: EServiceRiskAnalysisMultiAnswer = EServiceRiskAnalysisMultiAnswer(id = p.id, key = p.key, values = p.values) + def toTemplate: Map[String, Seq[String]] = Map(p.key -> p.values) } implicit class ReadModelModeWrapper(private val mode: readmodel.CatalogItemMode) extends AnyVal { diff --git a/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ProcessApiServiceImpl.scala b/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ProcessApiServiceImpl.scala index a2f2a904..00d6a414 100644 --- a/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ProcessApiServiceImpl.scala +++ b/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ProcessApiServiceImpl.scala @@ -203,6 +203,23 @@ final case class ProcessApiServiceImpl( val operationLabel = s"Publishing descriptor $descriptorId for EService $eServiceId" logger.info(operationLabel) + def verifyRiskAnalysisForPublication(catalogItem: CatalogItem): Future[Unit] = { + if (catalogItem.mode == Receive) { + for { + _ <- + if (catalogItem.riskAnalysis.isEmpty) Future.failed(EServiceRiskAnalysisIsRequired(catalogItem.id)) + else Future.unit + tenant <- tenantManagementService.getTenantById(catalogItem.producerId) + tenantKind <- tenant.kind.toFuture(TenantKindNotFound(tenant.id)) + _ <- catalogItem.riskAnalysis.traverse(risk => + isRiskAnalysisFormValid(riskAnalysisForm = risk.riskAnalysisForm.toTemplate, schemaOnlyValidation = false)( + tenantKind.toTemplate + ) + ) + } yield () + } else Future.unit + } + val result: Future[Unit] = for { organizationId <- getOrganizationIdFutureUUID(contexts) eServiceUuid <- eServiceId.toFutureUUID @@ -211,6 +228,7 @@ final case class ProcessApiServiceImpl( _ <- assertRequesterAllowed(catalogItem.producerId)(organizationId) descriptor <- assertDescriptorExists(catalogItem, descriptorUuid) _ <- verifyPublicationEligibility(descriptor) + _ <- verifyRiskAnalysisForPublication(catalogItem) currentActiveDescriptor = catalogItem.descriptors.find(d => d.state == Published) // Must be at most one _ <- catalogManagementService.publishDescriptor(eServiceId, descriptorId) _ <- currentActiveDescriptor diff --git a/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ResponseHandlers.scala b/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ResponseHandlers.scala index 769e78fb..05eeb512 100644 --- a/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ResponseHandlers.scala +++ b/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ResponseHandlers.scala @@ -188,7 +188,11 @@ object ResponseHandlers extends AkkaResponses { case Failure(ex: OperationForbidden.type) => forbidden(ex, logMessage) case Failure(ex: EServiceNotFound) => notFound(ex, logMessage) case Failure(ex: EServiceDescriptorNotFound) => notFound(ex, logMessage) + case Failure(ex: TenantNotFound) => notFound(ex, logMessage) + case Failure(ex: TenantKindNotFound) => notFound(ex, logMessage) case Failure(ex: EServiceDescriptorWithoutInterface) => badRequest(ex, logMessage) + case Failure(ex: EServiceRiskAnalysisIsRequired) => badRequest(ex, logMessage) + case Failure(ex: RiskAnalysisNotValid.type) => badRequest(ex, logMessage) case Failure(ex) => internalServerError(ex, logMessage) } diff --git a/src/main/scala/it/pagopa/interop/catalogprocess/errors/CatalogProcessErrors.scala b/src/main/scala/it/pagopa/interop/catalogprocess/errors/CatalogProcessErrors.scala index c443037e..641ea039 100644 --- a/src/main/scala/it/pagopa/interop/catalogprocess/errors/CatalogProcessErrors.scala +++ b/src/main/scala/it/pagopa/interop/catalogprocess/errors/CatalogProcessErrors.scala @@ -63,4 +63,7 @@ object CatalogProcessErrors { final case class EServiceRiskAnalysisNotFound(eServiceId: UUID, riskAnalysisId: UUID) extends ComponentError("0017", s"Risk Analysis $riskAnalysisId not found for EService $eServiceId") + + final case class EServiceRiskAnalysisIsRequired(eServiceId: UUID) + extends ComponentError("0018", s"At least one Risk Analysis is required for EService $eServiceId") } diff --git a/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala b/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala index 8df89b51..8a5f1bb3 100644 --- a/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala +++ b/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala @@ -13,7 +13,8 @@ import it.pagopa.interop.commons.cqrs.service.ReadModelService import it.pagopa.interop.catalogprocess.errors.CatalogProcessErrors.{ EServiceNotFound, DescriptorDocumentNotFound, - EServiceRiskAnalysisNotFound + EServiceRiskAnalysisNotFound, + TenantNotFound } import it.pagopa.interop.catalogmanagement.model.{ CatalogDescriptorState, @@ -1107,6 +1108,174 @@ class CatalogProcessSpec extends SpecHelper with AnyWordSpecLike with ScalatestR } } "Descriptor publication" should { + "succeed if mode is Receive" in { + val requesterId = UUID.randomUUID() + + implicit val context: Seq[(String, String)] = + Seq("bearer" -> bearerToken, USER_ROLES -> "admin", ORGANIZATION_ID_CLAIM -> requesterId.toString) + + (mockCatalogManagementService + .getEServiceById(_: UUID)(_: ExecutionContext, _: ReadModelService)) + .expects(SpecData.catalogItem.id, *, *) + .once() + .returns( + Future.successful( + SpecData.catalogItem.copy( + producerId = requesterId, + descriptors = + Seq(SpecData.catalogDescriptor.copy(state = Draft, interface = Option(SpecData.catalogDocument))), + riskAnalysis = Seq(SpecData.catalogRiskAnalysisFullValid), + mode = Receive + ) + ) + ) + + (mockTenantManagementService + .getTenantById(_: UUID)(_: ExecutionContext, _: ReadModelService)) + .expects(requesterId, *, *) + .once() + .returns(Future.successful(SpecData.persistentTenant.copy(id = requesterId))) + + (mockCatalogManagementService + .publishDescriptor(_: String, _: String)(_: Seq[(String, String)])) + .expects(SpecData.catalogItem.id.toString, SpecData.catalogDescriptor.id.toString, *) + .returning(Future.unit) + .once() + + (mockAuthorizationManagementService + .updateStateOnClients( + _: UUID, + _: UUID, + _: AuthorizationManagementDependency.ClientComponentState, + _: Seq[String], + _: Int + )(_: Seq[(String, String)])) + .expects( + SpecData.catalogItem.id, + SpecData.catalogDescriptor.id, + AuthorizationManagementDependency.ClientComponentState.ACTIVE, + SpecData.catalogDescriptor.audience, + SpecData.catalogDescriptor.voucherLifespan, + * + ) + .returning(Future.unit) + .once() + + Post() ~> service.publishDescriptor( + SpecData.catalogItem.id.toString, + SpecData.catalogDescriptor.id.toString + ) ~> check { + status shouldEqual StatusCodes.NoContent + } + } + "fail if mode is Receive and Catalog Item has not at least one Risk Analysis" in { + val requesterId = UUID.randomUUID() + + implicit val context: Seq[(String, String)] = + Seq("bearer" -> bearerToken, USER_ROLES -> "admin", ORGANIZATION_ID_CLAIM -> requesterId.toString) + + (mockCatalogManagementService + .getEServiceById(_: UUID)(_: ExecutionContext, _: ReadModelService)) + .expects(SpecData.catalogItem.id, *, *) + .once() + .returns( + Future.successful( + SpecData.catalogItem.copy( + producerId = requesterId, + descriptors = + Seq(SpecData.catalogDescriptor.copy(state = Draft, interface = Option(SpecData.catalogDocument))), + riskAnalysis = Seq.empty, + mode = Receive + ) + ) + ) + + Post() ~> service.publishDescriptor( + SpecData.catalogItem.id.toString, + SpecData.catalogDescriptor.id.toString + ) ~> check { + status shouldEqual StatusCodes.BadRequest + val problem = responseAs[Problem] + problem.status shouldBe StatusCodes.BadRequest.intValue + problem.errors.head.code shouldBe "009-0018" + } + } + "fail if mode is Receive and Tenant is not found" in { + val requesterId = UUID.randomUUID() + + implicit val context: Seq[(String, String)] = + Seq("bearer" -> bearerToken, USER_ROLES -> "admin", ORGANIZATION_ID_CLAIM -> requesterId.toString) + + (mockCatalogManagementService + .getEServiceById(_: UUID)(_: ExecutionContext, _: ReadModelService)) + .expects(SpecData.catalogItem.id, *, *) + .once() + .returns( + Future.successful( + SpecData.catalogItem.copy( + producerId = requesterId, + descriptors = + Seq(SpecData.catalogDescriptor.copy(state = Draft, interface = Option(SpecData.catalogDocument))), + riskAnalysis = Seq(SpecData.catalogRiskAnalysisFullValid), + mode = Receive + ) + ) + ) + + (mockTenantManagementService + .getTenantById(_: UUID)(_: ExecutionContext, _: ReadModelService)) + .expects(requesterId, *, *) + .once() + .returns(Future.failed(TenantNotFound(requesterId))) + + Post() ~> service.publishDescriptor( + SpecData.catalogItem.id.toString, + SpecData.catalogDescriptor.id.toString + ) ~> check { + status shouldEqual StatusCodes.NotFound + val problem = responseAs[Problem] + problem.status shouldBe StatusCodes.NotFound.intValue + problem.errors.head.code shouldBe "009-0014" + } + } + "fail if mode is Receive and Risk Analysis did not pass validation" in { + val requesterId = UUID.randomUUID() + + implicit val context: Seq[(String, String)] = + Seq("bearer" -> bearerToken, USER_ROLES -> "admin", ORGANIZATION_ID_CLAIM -> requesterId.toString) + + (mockCatalogManagementService + .getEServiceById(_: UUID)(_: ExecutionContext, _: ReadModelService)) + .expects(SpecData.catalogItem.id, *, *) + .once() + .returns( + Future.successful( + SpecData.catalogItem.copy( + producerId = requesterId, + descriptors = + Seq(SpecData.catalogDescriptor.copy(state = Draft, interface = Option(SpecData.catalogDocument))), + riskAnalysis = Seq(SpecData.catalogRiskAnalysisSchemaOnly), + mode = Receive + ) + ) + ) + + (mockTenantManagementService + .getTenantById(_: UUID)(_: ExecutionContext, _: ReadModelService)) + .expects(requesterId, *, *) + .once() + .returns(Future.successful(SpecData.persistentTenant.copy(id = requesterId))) + + Post() ~> service.publishDescriptor( + SpecData.catalogItem.id.toString, + SpecData.catalogDescriptor.id.toString + ) ~> check { + status shouldEqual StatusCodes.BadRequest + val problem = responseAs[Problem] + problem.status shouldBe StatusCodes.BadRequest.intValue + problem.errors.head.code shouldBe "009-0016" + } + } "succeed if descriptor is Draft" in { val requesterId = UUID.randomUUID() diff --git a/src/test/scala/it/pagopa/interop/catalogprocess/SpecData.scala b/src/test/scala/it/pagopa/interop/catalogprocess/SpecData.scala index 47b98a90..be762037 100644 --- a/src/test/scala/it/pagopa/interop/catalogprocess/SpecData.scala +++ b/src/test/scala/it/pagopa/interop/catalogprocess/SpecData.scala @@ -49,7 +49,7 @@ object SpecData { mode = CatalogManagement.Deliver ) - val catalogDocument: CatalogManagement.CatalogDocument = CatalogManagement.CatalogDocument( + val catalogDocument: CatalogManagement.CatalogDocument = CatalogManagement.CatalogDocument( id = docId, name = "name", contentType = "application/pdf", @@ -58,6 +58,114 @@ object SpecData { checksum = "checksum", uploadDate = OffsetDateTimeSupplier.get().minusDays(30) ) + + val catalogRiskAnalysisSchemaOnly = CatalogManagement.CatalogRiskAnalysis( + id = UUID.randomUUID(), + name = "name", + riskAnalysisForm = CatalogManagement.CatalogRiskAnalysisForm( + id = UUID.randomUUID(), + version = "3.0", + singleAnswers = Seq( + CatalogManagement + .CatalogRiskAnalysisSingleAnswer(id = UUID.randomUUID(), key = "purpose", value = Some("INSTITUTIONAL")) + ), + multiAnswers = Seq( + CatalogManagement + .CatalogRiskAnalysisMultiAnswer(id = UUID.randomUUID(), key = "personalDataTypes", values = Seq("OTHER")) + ) + ), + createdAt = OffsetDateTimeSupplier.get() + ) + + val catalogRiskAnalysisFullValid = CatalogManagement.CatalogRiskAnalysis( + id = UUID.randomUUID(), + name = "name", + riskAnalysisForm = CatalogManagement.CatalogRiskAnalysisForm( + id = UUID.randomUUID(), + version = "3.0", + singleAnswers = Seq( + CatalogManagement + .CatalogRiskAnalysisSingleAnswer(id = UUID.randomUUID(), key = "purpose", value = Some("INSTITUTIONAL")), + CatalogManagement.CatalogRiskAnalysisSingleAnswer( + id = UUID.randomUUID(), + key = "legalObligationReference", + value = Some("YES") + ), + CatalogManagement + .CatalogRiskAnalysisSingleAnswer(id = UUID.randomUUID(), key = "dataDownload", value = Some("YES")), + CatalogManagement.CatalogRiskAnalysisSingleAnswer( + id = UUID.randomUUID(), + key = "checkedExistenceMereCorrectnessInteropCatalogue", + value = Some("true") + ), + CatalogManagement + .CatalogRiskAnalysisSingleAnswer(id = UUID.randomUUID(), key = "deliveryMethod", value = Some("CLEARTEXT")), + CatalogManagement.CatalogRiskAnalysisSingleAnswer( + id = UUID.randomUUID(), + key = "legalBasisPublicInterest", + value = Some("RULE_OF_LAW") + ), + CatalogManagement.CatalogRiskAnalysisSingleAnswer( + id = UUID.randomUUID(), + key = "confirmPricipleIntegrityAndDiscretion", + value = Some("true") + ), + CatalogManagement + .CatalogRiskAnalysisSingleAnswer(id = UUID.randomUUID(), key = "ruleOfLawText", value = Some("TheLaw")), + CatalogManagement + .CatalogRiskAnalysisSingleAnswer( + id = UUID.randomUUID(), + key = "confirmDataRetentionPeriod", + value = Some("true") + ), + CatalogManagement + .CatalogRiskAnalysisSingleAnswer(id = UUID.randomUUID(), key = "usesThirdPartyData", value = Some("YES")), + CatalogManagement.CatalogRiskAnalysisSingleAnswer( + id = UUID.randomUUID(), + key = "otherPersonalDataTypes", + value = Some("MyThirdPartyData") + ), + CatalogManagement + .CatalogRiskAnalysisSingleAnswer(id = UUID.randomUUID(), key = "doesUseThirdPartyData", value = Some("YES")), + CatalogManagement + .CatalogRiskAnalysisSingleAnswer(id = UUID.randomUUID(), key = "knowsDataQuantity", value = Some("NO")), + CatalogManagement.CatalogRiskAnalysisSingleAnswer( + id = UUID.randomUUID(), + key = "institutionalPurpose", + value = Some("MyPurpose") + ), + CatalogManagement + .CatalogRiskAnalysisSingleAnswer(id = UUID.randomUUID(), key = "policyProvided", value = Some("NO")), + CatalogManagement.CatalogRiskAnalysisSingleAnswer( + id = UUID.randomUUID(), + key = "reasonPolicyNotProvided", + value = Some("Because") + ), + CatalogManagement.CatalogRiskAnalysisSingleAnswer(id = UUID.randomUUID(), key = "doneDpia", value = Some("NO")), + CatalogManagement.CatalogRiskAnalysisSingleAnswer( + id = UUID.randomUUID(), + key = "declarationConfirmGDPR", + value = Some("true") + ), + CatalogManagement.CatalogRiskAnalysisSingleAnswer( + id = UUID.randomUUID(), + key = "purposePursuit", + value = Some("MERE_CORRECTNESS") + ) + ), + multiAnswers = Seq( + CatalogManagement + .CatalogRiskAnalysisMultiAnswer(id = UUID.randomUUID(), key = "personalDataTypes", values = Seq("OTHER")), + CatalogManagement.CatalogRiskAnalysisMultiAnswer( + id = UUID.randomUUID(), + key = "legalBasis", + values = Seq("LEGAL_OBLIGATION", "PUBLIC_INTEREST") + ) + ) + ), + createdAt = OffsetDateTimeSupplier.get() + ) + val catalogDescriptor: CatalogManagement.CatalogDescriptor = CatalogManagement.CatalogDescriptor( id = descriptorId, version = "1", From 444dfd92299da75d568ec70ec8794547613a6a96 Mon Sep 17 00:00:00 2001 From: nttdata-rtorsoli Date: Thu, 28 Sep 2023 16:34:45 +0200 Subject: [PATCH 2/5] PR-3996 Resolved PR issues --- .../catalogprocess/api/impl/ProcessApiServiceImpl.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ProcessApiServiceImpl.scala b/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ProcessApiServiceImpl.scala index 50674fe9..59bb98c3 100644 --- a/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ProcessApiServiceImpl.scala +++ b/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ProcessApiServiceImpl.scala @@ -36,7 +36,8 @@ import it.pagopa.interop.catalogmanagement.model.{ Draft, Suspended, Deprecated, - Receive + Receive, + Deliver } final case class ProcessApiServiceImpl( @@ -203,8 +204,9 @@ final case class ProcessApiServiceImpl( val operationLabel = s"Publishing descriptor $descriptorId for EService $eServiceId" logger.info(operationLabel) - def verifyRiskAnalysisForPublication(catalogItem: CatalogItem): Future[Unit] = { - if (catalogItem.mode == Receive) { + def verifyRiskAnalysisForPublication(catalogItem: CatalogItem): Future[Unit] = catalogItem.mode match { + case Deliver => Future.unit + case Receive => for { _ <- if (catalogItem.riskAnalysis.isEmpty) Future.failed(EServiceRiskAnalysisIsRequired(catalogItem.id)) @@ -217,7 +219,6 @@ final case class ProcessApiServiceImpl( ) ) } yield () - } else Future.unit } val result: Future[Unit] = for { From 706f1d1f8053ef551b629a6f26e17d9138466d03 Mon Sep 17 00:00:00 2001 From: nttdata-rtorsoli Date: Fri, 29 Sep 2023 11:42:40 +0200 Subject: [PATCH 3/5] PIN-3996 Resolved PR issues --- .../interop/catalogprocess/api/impl/ResponseHandlers.scala | 2 -- .../pagopa/interop/catalogprocess/CatalogProcessSpec.scala | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ResponseHandlers.scala b/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ResponseHandlers.scala index b42a0f82..f66259ba 100644 --- a/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ResponseHandlers.scala +++ b/src/main/scala/it/pagopa/interop/catalogprocess/api/impl/ResponseHandlers.scala @@ -185,8 +185,6 @@ object ResponseHandlers extends AkkaResponses { case Failure(ex: OperationForbidden.type) => forbidden(ex, logMessage) case Failure(ex: EServiceNotFound) => notFound(ex, logMessage) case Failure(ex: EServiceDescriptorNotFound) => notFound(ex, logMessage) - case Failure(ex: TenantNotFound) => notFound(ex, logMessage) - case Failure(ex: TenantKindNotFound) => notFound(ex, logMessage) case Failure(ex: EServiceDescriptorWithoutInterface) => badRequest(ex, logMessage) case Failure(ex: EServiceRiskAnalysisIsRequired) => badRequest(ex, logMessage) case Failure(ex: RiskAnalysisNotValid.type) => badRequest(ex, logMessage) diff --git a/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala b/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala index 3a1484e8..6a885db2 100644 --- a/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala +++ b/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala @@ -1232,10 +1232,7 @@ class CatalogProcessSpec extends SpecHelper with AnyWordSpecLike with ScalatestR SpecData.catalogItem.id.toString, SpecData.catalogDescriptor.id.toString ) ~> check { - status shouldEqual StatusCodes.NotFound - val problem = responseAs[Problem] - problem.status shouldBe StatusCodes.NotFound.intValue - problem.errors.head.code shouldBe "009-0014" + status shouldEqual StatusCodes.InternalServerError } } "fail if mode is Receive and Risk Analysis did not pass validation" in { From dd5f3a4e9434b6e22629dd548dbc8cbb1f36d558 Mon Sep 17 00:00:00 2001 From: nttdata-rtorsoli Date: Fri, 29 Sep 2023 12:32:24 +0200 Subject: [PATCH 4/5] PIN-3996 Resolved PR issue --- .../catalogprocess/CatalogProcessSpec.scala | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala b/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala index 6a885db2..979b6871 100644 --- a/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala +++ b/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala @@ -1200,41 +1200,6 @@ class CatalogProcessSpec extends SpecHelper with AnyWordSpecLike with ScalatestR problem.errors.head.code shouldBe "009-0018" } } - "fail if mode is Receive and Tenant is not found" in { - val requesterId = UUID.randomUUID() - - implicit val context: Seq[(String, String)] = - Seq("bearer" -> bearerToken, USER_ROLES -> "admin", ORGANIZATION_ID_CLAIM -> requesterId.toString) - - (mockCatalogManagementService - .getEServiceById(_: UUID)(_: ExecutionContext, _: ReadModelService)) - .expects(SpecData.catalogItem.id, *, *) - .once() - .returns( - Future.successful( - SpecData.catalogItem.copy( - producerId = requesterId, - descriptors = - Seq(SpecData.catalogDescriptor.copy(state = Draft, interface = Option(SpecData.catalogDocument))), - riskAnalysis = Seq(SpecData.catalogRiskAnalysisFullValid), - mode = Receive - ) - ) - ) - - (mockTenantManagementService - .getTenantById(_: UUID)(_: ExecutionContext, _: ReadModelService)) - .expects(requesterId, *, *) - .once() - .returns(Future.failed(TenantNotFound(requesterId))) - - Post() ~> service.publishDescriptor( - SpecData.catalogItem.id.toString, - SpecData.catalogDescriptor.id.toString - ) ~> check { - status shouldEqual StatusCodes.InternalServerError - } - } "fail if mode is Receive and Risk Analysis did not pass validation" in { val requesterId = UUID.randomUUID() From dcb791e8a3cce6ec77fa100305de301e17c91cba Mon Sep 17 00:00:00 2001 From: nttdata-rtorsoli Date: Fri, 29 Sep 2023 12:49:24 +0200 Subject: [PATCH 5/5] PIN-3996 Cleaning --- .../it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala b/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala index 979b6871..9b190146 100644 --- a/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala +++ b/src/test/scala/it/pagopa/interop/catalogprocess/CatalogProcessSpec.scala @@ -13,8 +13,7 @@ import it.pagopa.interop.commons.cqrs.service.ReadModelService import it.pagopa.interop.catalogprocess.errors.CatalogProcessErrors.{ EServiceNotFound, DescriptorDocumentNotFound, - EServiceRiskAnalysisNotFound, - TenantNotFound + EServiceRiskAnalysisNotFound } import it.pagopa.interop.catalogmanagement.model.{ CatalogDescriptorState,