Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(castor): clean up sonarcloud issues and unused configurations #784

Merged
merged 4 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))(
Expand Down
30 changes: 0 additions & 30 deletions infrastructure/charts/agent/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions infrastructure/charts/agent/templates/postgresql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,7 +27,6 @@ spec:
agent-application-user:
- login
databases:
castor: castor-admin
pollux: pollux-admin
connect: connect-admin
agent: agent-admin
Expand Down
52 changes: 6 additions & 46 deletions infrastructure/ci/docker-compose-multiple-actors.yml
Original file line number Diff line number Diff line change
@@ -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
##########################
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
3 changes: 1 addition & 2 deletions infrastructure/shared/docker-compose-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions infrastructure/shared/docker-compose-mt-keycloak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions infrastructure/shared/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
21 changes: 3 additions & 18 deletions infrastructure/single-tenant-testing-stack/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
devMode = false
devMode = ${?DEV_MODE}

prismNode {
service = {
host = "localhost"
Expand Down
Loading
Loading