From 3ace4a8aa91689a78066671f8fcfc015f031ee01 Mon Sep 17 00:00:00 2001 From: Alessio Gallitano <25105748+galales@users.noreply.github.com> Date: Mon, 11 Dec 2023 14:11:40 +0100 Subject: [PATCH] PIN-4255: Remove ivass certified attribute assignment (#162) Co-authored-by: Stefano Perazzolo <13318704+beetlecrunch@users.noreply.github.com> --- .../src/main/resources/application.conf | 2 - .../Main.scala | 14 +--- .../system/ApplicationConfiguration.scala | 3 - .../util/Utils.scala | 37 +--------- .../CreateIvassActionSpec.scala | 72 ------------------- 5 files changed, 4 insertions(+), 124 deletions(-) delete mode 100644 tenants-certified-attributes-updater/src/test/scala/it/pagopa/interop/tenantscertifiedattributesupdater/CreateIvassActionSpec.scala diff --git a/tenants-certified-attributes-updater/src/main/resources/application.conf b/tenants-certified-attributes-updater/src/main/resources/application.conf index 53f07644..81335f8c 100644 --- a/tenants-certified-attributes-updater/src/main/resources/application.conf +++ b/tenants-certified-attributes-updater/src/main/resources/application.conf @@ -6,8 +6,6 @@ interop-be-tenants-certified-attributes-updater { ec-keys-identifiers = ${?EC_KEYS_IDENTIFIERS} rsa-keys-identifiers = ${?RSA_KEYS_IDENTIFIERS} - ivass-assurance-attribute-code = ${IVASS_ASSURANCE_ATTRIBUTE_CODE} - services { party-registry-proxy = ${PARTY_REGISTRY_PROXY_URL} tenant-process = ${TENANT_PROCESS_URL} diff --git a/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/Main.scala b/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/Main.scala index 1908cad2..dc0200ff 100644 --- a/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/Main.scala +++ b/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/Main.scala @@ -73,18 +73,10 @@ object Main extends App with Dependencies { uo <- retrieveAllInstitutions(uoRetriever, initPage, List.empty) allInstitutions = institutions ++ aoo ++ uo _ <- verifyInstitutionsCount(allInstitutions) - action = createAction(allInstitutions, tenants.toList, attributesIndex) - ivassAction = createIvassAction( - tenants.toList, - attributesIndex, - ApplicationConfiguration.ivassAssuranceAttributesCode - ) - _ <- processActivations( - tenantUpserter, - action.activations.grouped(groupDimension).toList :+ ivassAction.activations - ) + action = createAction(allInstitutions, tenants.toList, attributesIndex) + _ <- processActivations(tenantUpserter, action.activations.grouped(groupDimension).toList) _ = logger.info(s"Activated tenants/attributes") - _ <- processRevocations(revokerCertifiedAttribute, action.revocations.toList ++ ivassAction.revocations.toList) + _ <- processRevocations(revokerCertifiedAttribute, action.revocations.toList) _ = logger.info(s"Revoked tenants/attributes") } yield () diff --git a/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/system/ApplicationConfiguration.scala b/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/system/ApplicationConfiguration.scala index b27d528d..885c2b60 100644 --- a/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/system/ApplicationConfiguration.scala +++ b/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/system/ApplicationConfiguration.scala @@ -38,9 +38,6 @@ object ApplicationConfiguration { .toSet .filter(_.nonEmpty) - val ivassAssuranceAttributesCode: String = - config.getString("interop-be-tenants-certified-attributes-updater.ivass-assurance-attribute-code") - require( rsaKeysIdentifiers.nonEmpty || ecKeysIdentifiers.nonEmpty, "You MUST provide at least one signing key (either RSA or EC)" diff --git a/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/util/Utils.scala b/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/util/Utils.scala index 2480c4bf..682bb9e7 100644 --- a/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/util/Utils.scala +++ b/tenants-certified-attributes-updater/src/main/scala/it/pagopa/interop/tenantscertifiedattributesupdater/util/Utils.scala @@ -12,11 +12,7 @@ import it.pagopa.interop.commons.signer.service.SignerService import it.pagopa.interop.commons.utils.Digester import it.pagopa.interop.commons.utils.TypeConversions._ import it.pagopa.interop.partyregistryproxy.client.model.{Classification, Institution, Institutions} -import it.pagopa.interop.tenantmanagement.model.tenant.{ - PersistentCertifiedAttribute, - PersistentExternalId, - PersistentTenant -} +import it.pagopa.interop.tenantmanagement.model.tenant.{PersistentExternalId, PersistentTenant} import it.pagopa.interop.attributeregistryprocess.Utils.kindToBeExcluded import it.pagopa.interop.tenantprocess.client.model.{ExternalId, InternalAttributeSeed, InternalTenantSeed} import it.pagopa.interop.tenantscertifiedattributesupdater.system.ApplicationConfiguration @@ -28,8 +24,6 @@ import scala.concurrent.{ExecutionContext, Future} object Utils { - val IVASS_ORIGIN = "IVASS" - implicit class AttributeInfoOps(val a: AttributeInfo) extends AnyVal { def toInternalAttributeSeed: InternalAttributeSeed = InternalAttributeSeed(a.origin, a.code) } @@ -112,35 +106,6 @@ object Utils { } - def createIvassAction( - tenants: List[PersistentTenant], - attributesIndex: Map[UUID, AttributeInfo], - ivassAssuranceAttributesCode: String - ): TenantActions = { - val ivassAttribute = attributesIndex - .find(a => a._2.origin == IVASS_ORIGIN && a._2.code == ivassAssuranceAttributesCode) - val ivassAttributeInfo = ivassAttribute.map(_._2.toInternalAttributeSeed).toList - - def missingAttributes(tenant: PersistentTenant): Boolean = - tenant.attributes.collectFirst { - case a: PersistentCertifiedAttribute if ivassAttribute.exists(_._1 == a.id) && a.revocationTimestamp.isEmpty => - () - }.isEmpty - - val activations: List[InternalTenantSeed] = tenants - .filter(_.externalId.origin == IVASS_ORIGIN) - .filter(missingAttributes) - .map(tenant => - InternalTenantSeed( - TenantId(tenant.externalId.origin, tenant.externalId.value, tenant.name).toExternalId, - ivassAttributeInfo, - tenant.name - ) - ) - - TenantActions(activations, Map.empty) - } - def createAttributesIndex(attributes: Seq[PersistentAttribute]): Map[UUID, AttributeInfo] = attributes .filter(_.kind == Certified) diff --git a/tenants-certified-attributes-updater/src/test/scala/it/pagopa/interop/tenantscertifiedattributesupdater/CreateIvassActionSpec.scala b/tenants-certified-attributes-updater/src/test/scala/it/pagopa/interop/tenantscertifiedattributesupdater/CreateIvassActionSpec.scala deleted file mode 100644 index 30493325..00000000 --- a/tenants-certified-attributes-updater/src/test/scala/it/pagopa/interop/tenantscertifiedattributesupdater/CreateIvassActionSpec.scala +++ /dev/null @@ -1,72 +0,0 @@ -package it.pagopa.interop.tenantscertifiedattributesupdater - -import it.pagopa.interop.tenantmanagement.model.tenant.{ - PersistentCertifiedAttribute, - PersistentExternalId, - PersistentTenant -} -import it.pagopa.interop.tenantprocess.client.model.{ExternalId, InternalAttributeSeed, InternalTenantSeed} -import it.pagopa.interop.tenantscertifiedattributesupdater.SpecHelper._ -import it.pagopa.interop.tenantscertifiedattributesupdater.util.AttributeInfo -import it.pagopa.interop.tenantscertifiedattributesupdater.util.Utils._ -import munit.FunSuite - -import java.util.UUID - -class CreateIvassActionSpec extends FunSuite { - - test("Assign attributes to existing Tenant") { - val originIvass = "IVASS" - val otherOrigin = "IPA" - val originId = "001" - val attributeCodeIvass = "code" - val attributeUUID = UUID.randomUUID() - - val tenants: List[PersistentTenant] = - List(persistentTenant(originIvass, originId), persistentTenant(otherOrigin, originId)) - val attributesIndex: Map[UUID, AttributeInfo] = - Map(attributeUUID -> AttributeInfo(originIvass, attributeCodeIvass, None)) - - val result = createIvassAction(tenants, attributesIndex, attributeCodeIvass) - - val expectedActivations = List( - InternalTenantSeed( - externalId = ExternalId(originIvass, originId), - certifiedAttributes = List(InternalAttributeSeed(originIvass, attributeCodeIvass)), - name = defaultName - ) - ) - val expectedRevocations = Map.empty[PersistentExternalId, List[AttributeInfo]] - - assertEquals(result.activations, expectedActivations) - assertEquals(result.revocations, expectedRevocations) - } - - test("Assign only new attributes to existing Tenant") { - val originIvass = "IVASS" - val otherOrigin = "IPA" - val originId = "001" - val attributeCodeIvass = "Assicurazioni-code" - val attributeUUID = UUID.randomUUID() - - val tenants: List[PersistentTenant] = - List( - persistentTenant( - originIvass, - originId, - attributes = List(PersistentCertifiedAttribute(attributeUUID, timestamp, None)) - ), - persistentTenant(otherOrigin, originId) - ) - val attributesIndex: Map[UUID, AttributeInfo] = - Map(attributeUUID -> AttributeInfo(originIvass, attributeCodeIvass, None)) - - val result = createIvassAction(tenants, attributesIndex, attributeCodeIvass) - - val expectedActivations = Nil - val expectedRevocations = Map.empty[PersistentExternalId, List[AttributeInfo]] - - assertEquals(result.activations, expectedActivations) - assertEquals(result.revocations, expectedRevocations) - } -}