From ec8ac69c50d937f021602b24d7ded8d1064a746c Mon Sep 17 00:00:00 2001 From: patlo-iog Date: Mon, 13 Nov 2023 12:21:24 +0700 Subject: [PATCH] chore(castor): clean up sonarcloud issues and unused configurations (#784) Signed-off-by: Pat Losoponkul --- .../core/util/DIDOperationValidator.scala | 36 ------------- .../core/util/DIDOperationValidatorSpec.scala | 38 -------------- .../charts/agent/templates/deployment.yaml | 30 ----------- .../charts/agent/templates/postgresql.yaml | 6 --- .../ci/docker-compose-multiple-actors.yml | 52 +++---------------- infrastructure/shared/docker-compose-demo.yml | 3 +- .../shared/docker-compose-mt-keycloak.yml | 7 +-- infrastructure/shared/docker-compose.yml | 7 +-- .../docker-compose.yml | 21 ++------ .../src/main/resources/application.conf | 3 -- .../atala/agent/server/config/AppConfig.scala | 1 - 11 files changed, 12 insertions(+), 192 deletions(-) diff --git a/castor/lib/core/src/main/scala/io/iohk/atala/castor/core/util/DIDOperationValidator.scala b/castor/lib/core/src/main/scala/io/iohk/atala/castor/core/util/DIDOperationValidator.scala index 84c095a292..939b71408d 100644 --- a/castor/lib/core/src/main/scala/io/iohk/atala/castor/core/util/DIDOperationValidator.scala +++ b/castor/lib/core/src/main/scala/io/iohk/atala/castor/core/util/DIDOperationValidator.scala @@ -54,7 +54,6 @@ private object CreateOperationValidator extends BaseOperationValidator { _ <- validateKeyIdLength(config)(operation, extractKeyIds) _ <- validateServiceIdIsUriFragment(operation, extractServiceIds) _ <- validateServiceIdLength(config)(operation, extractServiceIds) - _ <- validateServiceEndpointNormalized(operation, extractServiceEndpoint) _ <- validateServiceEndpointLength(config)(operation, extractServiceEndpoint) _ <- validateServiceTypeLength(config)(operation, extractServiceType) _ <- validateUniqueContext(operation, _.context :: Nil) @@ -98,7 +97,6 @@ private object UpdateOperationValidator extends BaseOperationValidator { _ <- validateKeyIdLength(config)(operation, extractKeyIds) _ <- validateServiceIdIsUriFragment(operation, extractServiceIds) _ <- validateServiceIdLength(config)(operation, extractServiceIds) - _ <- validateServiceEndpointNormalized(operation, extractServiceEndpoint) _ <- validateServiceEndpointLength(config)(operation, extractServiceEndpoint) _ <- validateServiceTypeLength(config)(operation, extractServiceType) _ <- validateUniqueContext(operation, extractContexts) @@ -311,40 +309,6 @@ private trait BaseOperationValidator { ) } - // NOTE - // W3C spec requires URI to be normalized. In practice, it is impractical - // to ensure consistent normalization algorithm across all implementation / libraries. - // - // 2023-06-15 - // We decided that the URI normalization check will be omitted. - // This is not aligned with the W3C spec, but we'll wait and see what W3C - // comment will be around that normalization rule. - protected def validateServiceEndpointNormalized[T <: PrismDIDOperation]( - operation: T, - endpointExtractor: ServiceEndpointExtractor[T] - ): Either[OperationValidationError, Unit] = { - // val uris = endpointExtractor(operation) - // .flatMap { case (_, serviceEndpoint) => - // val ls: Seq[UriOrJsonEndpoint] = serviceEndpoint match { - // case ServiceEndpoint.Single(value) => Seq(value) - // case i: ServiceEndpoint.Multiple => i.values - // } - // ls.flatMap { - // case UriOrJsonEndpoint.Uri(uri) => Some(uri.value) - // case _ => None - // } - // } - // val nonNormalizedUris = uris.filterNot(isUriNormalized) - // if (nonNormalizedUris.isEmpty) Right(()) - // else - // Left( - // OperationValidationError.InvalidArgument( - // s"serviceEndpoint URIs must be normalized: ${nonNormalizedUris.mkString("[", ", ", "]")}" - // ) - // ) - Right(()) - } - protected def validateServiceTypeLength[T <: PrismDIDOperation]( config: Config )(operation: T, serviceTypeExtractor: ServiceTypeExtractor[T]): Either[OperationValidationError, Unit] = { diff --git a/castor/lib/core/src/test/scala/io/iohk/atala/castor/core/util/DIDOperationValidatorSpec.scala b/castor/lib/core/src/test/scala/io/iohk/atala/castor/core/util/DIDOperationValidatorSpec.scala index 22bc016397..c44be521be 100644 --- a/castor/lib/core/src/test/scala/io/iohk/atala/castor/core/util/DIDOperationValidatorSpec.scala +++ b/castor/lib/core/src/test/scala/io/iohk/atala/castor/core/util/DIDOperationValidatorSpec.scala @@ -299,20 +299,6 @@ object DIDOperationValidatorSpec extends ZIOSpecDefault { invalidArgumentContainsString("operation must contain at least 1 master key") ) }, - test("reject CreateOperation when service URL is not normalized") { - val op = createPrismDIDOperation(services = - Seq( - Service( - id = "service-0", - `type` = ServiceType.Single("LinkedDomains"), - serviceEndpoint = "http://example.com/login/../login" - ) - ) - ) - assert(DIDOperationValidator(Config.default).validate(op))( - invalidArgumentContainsString("serviceEndpoint URIs must be normalized") - ) - } @@ TestAspect.ignore, test("accept CreateOperation when publicKeys is empty because master key always exist") { val op = createPrismDIDOperation(publicKeys = Nil) assert(DIDOperationValidator(Config.default).validate(op))(isRight) @@ -583,30 +569,6 @@ object DIDOperationValidatorSpec extends ZIOSpecDefault { invalidArgumentContainsString("operation must contain at least 1 update action") ) }, - test("reject UpdateOperation when action AddService serviceEndpoint is not normalized") { - val op = updatePrismDIDOperation( - Seq( - UpdateDIDAction.AddService( - Service( - "service-1", - ServiceType.Single("LinkedDomains"), - "http://example.com/login/../login" - ) - ) - ) - ) - assert(DIDOperationValidator(Config.default).validate(op))( - invalidArgumentContainsString("serviceEndpoint URIs must be normalized") - ) - } @@ TestAspect.ignore, - test("reject updateOperation when action UpdateService serviceEndpoint is not normalized") { - val op = updatePrismDIDOperation( - Seq(UpdateDIDAction.UpdateService("service-1", None, Some("http://example.com/login/../login"))) - ) - assert(DIDOperationValidator(Config.default).validate(op))( - invalidArgumentContainsString("serviceEndpoint URIs must be normalized") - ) - } @@ TestAspect.ignore, test("reject UpdateOperation when action UpdateService have both type and serviceEndpoint empty") { val op = updatePrismDIDOperation(Seq(UpdateDIDAction.UpdateService("service-1", None, None))) assert(DIDOperationValidator(Config.default).validate(op))( diff --git a/infrastructure/charts/agent/templates/deployment.yaml b/infrastructure/charts/agent/templates/deployment.yaml index db0b2dd4f0..459079739c 100644 --- a/infrastructure/charts/agent/templates/deployment.yaml +++ b/infrastructure/charts/agent/templates/deployment.yaml @@ -44,36 +44,6 @@ spec: name: agent-api-key-salt key: salt optional: false - - name: CASTOR_DB_HOST - value: "{{ .Values.database.postgres.managingTeam }}-prism-agent-postgres-cluster.{{.Release.Namespace}}" - - name: CASTOR_DB_PORT - value: "5432" - - name: CASTOR_DB_NAME - value: castor - - name: CASTOR_DB_USER - valueFrom: - secretKeyRef: - name: castor-admin.{{ .Values.database.postgres.managingTeam }}-prism-agent-postgres-cluster.credentials.postgresql.acid.zalan.do - key: username - optional: false - - name: CASTOR_DB_PASSWORD - valueFrom: - secretKeyRef: - name: castor-admin.{{ .Values.database.postgres.managingTeam }}-prism-agent-postgres-cluster.credentials.postgresql.acid.zalan.do - key: password - optional: false - - name: CASTOR_DB_APP_USER - valueFrom: - secretKeyRef: - name: castor-application-user.{{ .Values.database.postgres.managingTeam }}-prism-agent-postgres-cluster.credentials.postgresql.acid.zalan.do - key: username - optional: false - - name: CASTOR_DB_APP_PASSWORD - valueFrom: - secretKeyRef: - name: castor-application-user.{{ .Values.database.postgres.managingTeam }}-prism-agent-postgres-cluster.credentials.postgresql.acid.zalan.do - key: password - optional: false - name: POLLUX_DB_HOST value: "{{ .Values.database.postgres.managingTeam }}-prism-agent-postgres-cluster.{{.Release.Namespace}}" - name: POLLUX_DB_PORT diff --git a/infrastructure/charts/agent/templates/postgresql.yaml b/infrastructure/charts/agent/templates/postgresql.yaml index a87bb07296..d65da0554e 100644 --- a/infrastructure/charts/agent/templates/postgresql.yaml +++ b/infrastructure/charts/agent/templates/postgresql.yaml @@ -11,11 +11,6 @@ spec: size: "{{ .Values.database.postgres.databaseSize }}" numberOfInstances: {{ .Values.database.postgres.numberOfInstances }} users: - castor-admin: - - superuser - - createdb - castor-application-user: - - login pollux-admin: - superuser - createdb @@ -32,7 +27,6 @@ spec: agent-application-user: - login databases: - castor: castor-admin pollux: pollux-admin connect: connect-admin agent: agent-admin diff --git a/infrastructure/ci/docker-compose-multiple-actors.yml b/infrastructure/ci/docker-compose-multiple-actors.yml index 6cc4fa69e9..660755415e 100644 --- a/infrastructure/ci/docker-compose-multiple-actors.yml +++ b/infrastructure/ci/docker-compose-multiple-actors.yml @@ -1,44 +1,6 @@ -version: '3.8' +version: "3.8" services: - - ########################## - # Castor Databases - ########################## - db_castor_issuer: - image: postgres:13 - restart: always - environment: - POSTGRES_DB: castor_issuer - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - 5432:5432 - volumes: - - pg_data_castor_db_issuer:/var/lib/postgresql/data - healthcheck: - test: ["CMD", "pg_isready", "-U", "postgres", "-d", "castor_issuer"] - interval: 10s - timeout: 5s - retries: 5 - - db_castor_holder: - image: postgres:13 - restart: always - environment: - POSTGRES_DB: castor_holder - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - 5433:5432 - volumes: - - pg_data_castor_db_holder:/var/lib/postgresql/data - healthcheck: - test: [ "CMD", "pg_isready", "-U", "postgres", "-d", "castor_holder" ] - interval: 10s - timeout: 5s - retries: 5 - ########################## # Pollux Databases ########################## @@ -72,7 +34,7 @@ services: volumes: - pg_data_pollux_db_holder:/var/lib/postgresql/data healthcheck: - test: [ "CMD", "pg_isready", "-U", "postgres", "-d", "pollux_holder" ] + test: ["CMD", "pg_isready", "-U", "postgres", "-d", "pollux_holder"] interval: 10s timeout: 5s retries: 5 @@ -93,7 +55,7 @@ services: volumes: - pg_data_connect_db_issuer:/var/lib/postgresql/data healthcheck: - test: [ "CMD", "pg_isready", "-U", "postgres", "-d", "connect_issuer" ] + test: ["CMD", "pg_isready", "-U", "postgres", "-d", "connect_issuer"] interval: 10s timeout: 5s retries: 5 @@ -110,7 +72,7 @@ services: volumes: - pg_data_connect_db_holder:/var/lib/postgresql/data healthcheck: - test: [ "CMD", "pg_isready", "-U", "postgres", "-d", "connect_holder" ] + test: ["CMD", "pg_isready", "-U", "postgres", "-d", "connect_holder"] interval: 10s timeout: 5s retries: 5 @@ -147,7 +109,7 @@ services: - db_castor_issuer - db_pollux_issuer healthcheck: - test: [ "CMD", "curl", "-f", "http://prism-agent-issuer:8080/dids/xyz" ] + test: ["CMD", "curl", "-f", "http://prism-agent-issuer:8080/dids/xyz"] interval: 30s timeout: 10s retries: 5 @@ -180,15 +142,13 @@ services: - db_castor_holder - db_pollux_holder healthcheck: - test: [ "CMD", "curl", "-f", "http://prism-agent-holder:8090/dids/xyz" ] + test: ["CMD", "curl", "-f", "http://prism-agent-holder:8090/dids/xyz"] interval: 30s timeout: 10s retries: 5 volumes: - pg_data_castor_db_issuer: pg_data_pollux_db_issuer: - pg_data_castor_db_holder: pg_data_pollux_db_holder: pg_data_connect_db_issuer: pg_data_connect_db_holder: diff --git a/infrastructure/shared/docker-compose-demo.yml b/infrastructure/shared/docker-compose-demo.yml index 723cb82023..3ea5f8c296 100644 --- a/infrastructure/shared/docker-compose-demo.yml +++ b/infrastructure/shared/docker-compose-demo.yml @@ -5,7 +5,7 @@ services: db: image: postgres:13 environment: - POSTGRES_MULTIPLE_DATABASES: "castor,pollux,connect,agent,node_db" + POSTGRES_MULTIPLE_DATABASES: "pollux,connect,agent,node_db" POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres volumes: @@ -37,7 +37,6 @@ services: PRISM_NODE_PORT: 50053 SECRET_STORAGE_BACKEND: postgres DEV_MODE: true - CASTOR_DB_HOST: db POLLUX_DB_HOST: db CONNECT_DB_HOST: db AGENT_DB_HOST: db diff --git a/infrastructure/shared/docker-compose-mt-keycloak.yml b/infrastructure/shared/docker-compose-mt-keycloak.yml index c6af5eb386..d441ef8dc7 100644 --- a/infrastructure/shared/docker-compose-mt-keycloak.yml +++ b/infrastructure/shared/docker-compose-mt-keycloak.yml @@ -10,7 +10,7 @@ services: db: image: postgres:13 environment: - POSTGRES_MULTIPLE_DATABASES: "castor,pollux,connect,agent,node_db" + POSTGRES_MULTIPLE_DATABASES: "pollux,connect,agent,node_db" POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres volumes: @@ -72,11 +72,6 @@ services: prism-agent: image: ghcr.io/input-output-hk/prism-agent:${PRISM_AGENT_VERSION} environment: - CASTOR_DB_HOST: db - CASTOR_DB_PORT: 5432 - CASTOR_DB_NAME: castor - CASTOR_DB_USER: postgres - CASTOR_DB_PASSWORD: postgres POLLUX_DB_HOST: db POLLUX_DB_PORT: 5432 POLLUX_DB_NAME: pollux diff --git a/infrastructure/shared/docker-compose.yml b/infrastructure/shared/docker-compose.yml index 600bde8519..2c211ca67a 100644 --- a/infrastructure/shared/docker-compose.yml +++ b/infrastructure/shared/docker-compose.yml @@ -8,7 +8,7 @@ services: db: image: postgres:13 environment: - POSTGRES_MULTIPLE_DATABASES: "castor,pollux,connect,agent,node_db" + POSTGRES_MULTIPLE_DATABASES: "pollux,connect,agent,node_db" POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres volumes: @@ -70,11 +70,6 @@ services: prism-agent: image: ghcr.io/input-output-hk/prism-agent:${PRISM_AGENT_VERSION} environment: - CASTOR_DB_HOST: db - CASTOR_DB_PORT: 5432 - CASTOR_DB_NAME: castor - CASTOR_DB_USER: postgres - CASTOR_DB_PASSWORD: postgres POLLUX_DB_HOST: db POLLUX_DB_PORT: 5432 POLLUX_DB_NAME: pollux diff --git a/infrastructure/single-tenant-testing-stack/docker-compose.yml b/infrastructure/single-tenant-testing-stack/docker-compose.yml index 410c68076f..898453a037 100644 --- a/infrastructure/single-tenant-testing-stack/docker-compose.yml +++ b/infrastructure/single-tenant-testing-stack/docker-compose.yml @@ -5,7 +5,7 @@ services: issuer-db: image: postgres:13 environment: - POSTGRES_MULTIPLE_DATABASES: "castor,pollux,connect,agent" + POSTGRES_MULTIPLE_DATABASES: "pollux,connect,agent" POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres volumes: @@ -23,7 +23,7 @@ services: verifier-db: image: postgres:13 environment: - POSTGRES_MULTIPLE_DATABASES: "castor,pollux,connect,agent" + POSTGRES_MULTIPLE_DATABASES: "pollux,connect,agent" POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres volumes: @@ -41,7 +41,7 @@ services: holder-db: image: postgres:13 environment: - POSTGRES_MULTIPLE_DATABASES: "castor,pollux,connect,agent" + POSTGRES_MULTIPLE_DATABASES: "pollux,connect,agent" POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres volumes: @@ -87,11 +87,6 @@ services: issuer-oea: image: ghcr.io/input-output-hk/prism-agent:${PRISM_AGENT_VERSION} environment: - CASTOR_DB_HOST: issuer-db - CASTOR_DB_PORT: 5432 - CASTOR_DB_NAME: castor - CASTOR_DB_USER: postgres - CASTOR_DB_PASSWORD: postgres POLLUX_DB_HOST: issuer-db POLLUX_DB_PORT: 5432 POLLUX_DB_NAME: pollux @@ -150,11 +145,6 @@ services: verifier-oea: image: ghcr.io/input-output-hk/prism-agent:${PRISM_AGENT_VERSION} environment: - CASTOR_DB_HOST: verifier-db - CASTOR_DB_PORT: 5432 - CASTOR_DB_NAME: castor - CASTOR_DB_USER: postgres - CASTOR_DB_PASSWORD: postgres POLLUX_DB_HOST: verifier-db POLLUX_DB_PORT: 5432 POLLUX_DB_NAME: pollux @@ -213,11 +203,6 @@ services: holder-oea: image: ghcr.io/input-output-hk/prism-agent:${PRISM_AGENT_VERSION} environment: - CASTOR_DB_HOST: holder-db - CASTOR_DB_PORT: 5432 - CASTOR_DB_NAME: castor - CASTOR_DB_USER: postgres - CASTOR_DB_PASSWORD: postgres POLLUX_DB_HOST: holder-db POLLUX_DB_PORT: 5432 POLLUX_DB_NAME: pollux diff --git a/prism-agent/service/server/src/main/resources/application.conf b/prism-agent/service/server/src/main/resources/application.conf index 9864903c4f..1fd5185045 100644 --- a/prism-agent/service/server/src/main/resources/application.conf +++ b/prism-agent/service/server/src/main/resources/application.conf @@ -1,6 +1,3 @@ -devMode = false -devMode = ${?DEV_MODE} - prismNode { service = { host = "localhost" diff --git a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/config/AppConfig.scala b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/config/AppConfig.scala index b13225e9ea..cf98969a1f 100644 --- a/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/config/AppConfig.scala +++ b/prism-agent/service/server/src/main/scala/io/iohk/atala/agent/server/config/AppConfig.scala @@ -12,7 +12,6 @@ import java.time.Duration import scala.util.Try final case class AppConfig( - devMode: Boolean, pollux: PolluxConfig, agent: AgentConfig, connect: ConnectConfig,