From 77cac97d280b387d51f55d375472b0cddd2042c6 Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Mon, 27 Nov 2023 10:00:53 +0100 Subject: [PATCH] chore: add documentation for policy hub Refs: CPLP-3362 --- .editorconfig | 2 +- .github/workflows/policy-hub-migrations.yml | 2 +- charts/policyhub/README.md | 14 +- charts/policyhub/README.md.gotmpl | 2 +- .../templates/deployment-backend-hub.yaml | 2 +- .../job-backend-policy-hub-migrations.yaml | 4 +- charts/policyhub/values.yaml | 10 +- .../argocd-app-templates/appsetup-beta.yaml | 12 +- .../argocd-app-templates/appsetup-dev.yaml | 10 +- .../argocd-app-templates/appsetup-int.yaml | 12 +- .../argocd-app-templates/appsetup-pen.yaml | 12 +- .../argocd-app-templates/appsetup-rc.yaml | 8 +- .../argocd-app-templates/appsetup-stable.yaml | 208 ++--------------- .../appsetup-upgrade.yaml | 12 +- consortia/environments/values-beta.yaml | 192 +--------------- consortia/environments/values-dev.yaml | 209 +---------------- consortia/environments/values-int.yaml | 207 +---------------- consortia/environments/values-pen.yaml | 210 +---------------- consortia/environments/values-rc.yaml | 211 +----------------- consortia/environments/values-upgrade.yaml | 7 +- docs/Release Process.md | 76 +++++++ .../Dev-Process/Dev-flow_deploy-dev-env.md | 31 +++ .../Dev-Process/Dev-flow_git-diagram.md | 133 +++++++++++ .../Dev-Process/Enumeration Handling.md | 40 ++++ ...-to-contribute.md => How to contribute.md} | 12 +- .../architecture/Architecture Constraints.md | 30 +++ .../architecture/Context and scope.md | 17 ++ .../architecture/Development Concept.md | 143 ++++++++++++ .../architecture/Requirements.md | 22 ++ .../architecture/Solution strategy.md | 14 ++ .../architecture/Whitebox Overall System.md | 15 ++ .../architecture/operational-concept.md | 47 ++++ .../authentication/authentication.md | 13 ++ .../database/db-view.md | 105 +++++++++ .../database/seeding.md | 44 ++++ scripts/add_notice_footer.sh | 57 +++++ scripts/license.sh | 50 +++++ src/Directory.Build.props | 25 +++ .../20231024084527_CPLP-3330-Initial.cs | 1 - .../Seeder/BatchInsertSeeder.cs | 2 +- .../Seeder/BatchUpdateSeeder.cs | 90 ++++++++ .../BusinessLogic/IPolicyHubBusinessLogic.cs | 2 +- .../BusinessLogic/PolicyHubBusinessLogic.cs | 2 +- .../Controllers/PolicyHubController.cs | 12 +- .../Extensions/StartupServiceExtensions.cs | 88 -------- .../StartupServiceWebApplicationExtensions.cs | 71 ------ .../Extensions/WebApplicationBuildRunner.cs | 72 ------ src/hub/PolicyHub.Service/Program.cs | 2 +- .../Properties/launchSettings.json | 4 +- .../PolicyRepositoryTests.cs | 26 +-- .../Setup/TestDbFixture.cs | 6 +- .../PolicyHub.DbAccess.Tests/Usings.cs | 1 - .../PolicyHubBusinessLogicTests.cs | 3 +- .../Controllers/PolicyHubControllerTests.cs | 87 +++----- .../Setup/IntegrationTestFactory.cs | 11 +- 55 files changed, 1147 insertions(+), 1553 deletions(-) create mode 100644 docs/Release Process.md create mode 100644 docs/developer/Technical-Documentation/Dev-Process/Dev-flow_deploy-dev-env.md create mode 100644 docs/developer/Technical-Documentation/Dev-Process/Dev-flow_git-diagram.md create mode 100644 docs/developer/Technical-Documentation/Dev-Process/Enumeration Handling.md rename docs/developer/Technical-Documentation/Dev-Process/{How-to-contribute.md => How to contribute.md} (87%) create mode 100644 docs/developer/Technical-Documentation/architecture/Architecture Constraints.md create mode 100644 docs/developer/Technical-Documentation/architecture/Context and scope.md create mode 100644 docs/developer/Technical-Documentation/architecture/Development Concept.md create mode 100644 docs/developer/Technical-Documentation/architecture/Requirements.md create mode 100644 docs/developer/Technical-Documentation/architecture/Solution strategy.md create mode 100644 docs/developer/Technical-Documentation/architecture/Whitebox Overall System.md create mode 100644 docs/developer/Technical-Documentation/architecture/operational-concept.md create mode 100644 docs/developer/Technical-Documentation/authentication/authentication.md create mode 100644 docs/developer/Technical-Documentation/database/db-view.md create mode 100644 docs/developer/Technical-Documentation/database/seeding.md create mode 100644 scripts/add_notice_footer.sh create mode 100644 scripts/license.sh create mode 100644 src/Directory.Build.props create mode 100644 src/database/PolicyHub.Migrations/Seeder/BatchUpdateSeeder.cs delete mode 100644 src/hub/PolicyHub.Service/Extensions/StartupServiceExtensions.cs delete mode 100644 src/hub/PolicyHub.Service/Extensions/StartupServiceWebApplicationExtensions.cs delete mode 100644 src/hub/PolicyHub.Service/Extensions/WebApplicationBuildRunner.cs diff --git a/.editorconfig b/.editorconfig index b651108..5945d4a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -148,7 +148,7 @@ dotnet_diagnostic.RS2008.severity = none # IDE0073: File header dotnet_diagnostic.IDE0073.severity = warning -#file_header_template = /********************************************************************************\n * Copyright (c) 2021,2022 BMW Group AG\n * Copyright (c) 2021,2022 Contributors to the CatenaX (ng) GitHub Organisation.\n *\n * \nSee the NOTICE file(s) distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This program and the accompanying materials are made available under the\n * terms of the \nApache License, Version 2.0 which is available at\n * https://www.apache.org/licenses/LICENSE-2.0.\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License \nis distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the \nLicense. *\n * SPDX-License-Identifier: Apache-2.0\n ********************************************************************************/\n +#file_header_template = /********************************************************************************\n * Copyright (c) 2021,2022 Contributors to the CatenaX (ng) GitHub Organisation.\n *\n * \nSee the NOTICE file(s) distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This program and the accompanying materials are made available under the\n * terms of the \nApache License, Version 2.0 which is available at\n * https://www.apache.org/licenses/LICENSE-2.0.\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License \nis distributed on an "AS IS" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * License for the specific language governing permissions and limitations\n * under the \nLicense. *\n * SPDX-License-Identifier: Apache-2.0\n ********************************************************************************/\n # IDE0035: Remove unreachable code dotnet_diagnostic.IDE0035.severity = warning diff --git a/.github/workflows/policy-hub-migrations.yml b/.github/workflows/policy-hub-migrations.yml index a2c8e87..1fdfa5c 100644 --- a/.github/workflows/policy-hub-migrations.yml +++ b/.github/workflows/policy-hub-migrations.yml @@ -24,7 +24,7 @@ on: # paths: # # service and transitive paths # - 'src/database/PolicyHub.Migrations/**' - # - 'src/database/PolicyHub.PortalEntities/**' + # - 'src/database/PolicyHub.Entities/**' # # workflow file # - '.github/workflows/policy-hub-migrations.yml' # # dockerfile diff --git a/charts/policyhub/README.md b/charts/policyhub/README.md index 5063d8d..ba77142 100644 --- a/charts/policyhub/README.md +++ b/charts/policyhub/README.md @@ -1,10 +1,10 @@ # Helm chart for Catena-X Policy Hub -![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) +![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square) This helm chart installs the Catena-X Policy Hub application v1.0.0. -For information on how to upgrade from previous versions please refer to [Version Upgrade](https://github.com/eclipse-tractusx/policy-hub/tree/v1.0.0/docs/developer/Technical%20Documentation/Version%20Upgrade/portal-upgrade-details.md). +For information on how to upgrade from previous versions please refer to [Version Upgrade](https://github.com/eclipse-tractusx/policy-hub/tree/v1.0.0/docs/developer/Technical%20Documentation/Version%20Upgrade/policy-hub-upgrade-details.md). For further information please refer to [Technical Documentation](https://github.com/eclipse-tractusx/policy-hub/tree/v1.0.0/docs/developer/Technical%20Documentation). @@ -65,13 +65,13 @@ dependencies: | backend.keycloak.central.jwtBearerOptions.metadataPath | string | `"/auth/realms/CX-Central/.well-known/openid-configuration"` | | | backend.keycloak.central.jwtBearerOptions.refreshInterval | string | `"00:00:30"` | | | backend.keycloak.central.jwtBearerOptions.requireHttpsMetadata | string | `"true"` | | -| backend.keycloak.central.jwtBearerOptions.tokenValidationParameters.validAudience | string | `"Cl2-CX-Portal"` | | +| backend.keycloak.central.jwtBearerOptions.tokenValidationParameters.validAudience | string | `"ClXX-CX-Policy-Hub"` | | | backend.keycloak.central.jwtBearerOptions.tokenValidationParameters.validIssuerPath | string | `"/auth/realms/CX-Central"` | | | backend.keycloak.central.tokenPath | string | `"/auth/realms/CX-Central/protocol/openid-connect/token"` | | | backend.keycloak.central.useAuthTrail | bool | `true` | Flag if the api should be used with an leading /auth path | -| backend.policyhub.image.name | string | `"tractusx/portal-hub-service"` | | +| backend.policyhub.image.name | string | `"tractusx/policy-hub-service"` | | | backend.policyhub.image.policyhubservicetag | string | `"29dbdeb9a8b3e809fdab2406140a226bc55de844"` | | -| backend.policyhub.keycloakClientId | string | `"Cl2-CX-Portal"` | | +| backend.policyhub.keycloakClientId | string | `"ClXX-CX-Policy-Hub"` | | | backend.policyhub.logging.businessLogic | string | `"Information"` | | | backend.policyhub.logging.default | string | `"Information"` | | | backend.policyhub.name | string | `"policy-hub-service"` | | @@ -89,7 +89,7 @@ dependencies: | externalDatabase.policyHubPassword | string | `""` | Password for the non-root username 'hub'. Secret-key 'policy-hub-password'. | | externalDatabase.policyHubUser | string | `"hub"` | Non-root username for hub. | | externalDatabase.port | int | `5432` | Database port number | -| externalDatabase.secret | string | `"secret-postgres-external-db"` | Secret containing the passwords non-root usernames portal and provisioning. | +| externalDatabase.secret | string | `"secret-postgres-external-db"` | Secret containing the passwords non-root username hub. | | livenessProbe.failureThreshold | int | `3` | | | livenessProbe.initialDelaySeconds | int | `10` | | | livenessProbe.periodSeconds | int | `10` | | @@ -103,7 +103,7 @@ dependencies: | postgresql.audit.logLinePrefix | string | `"%m %u %d "` | | | postgresql.audit.pgAuditLog | string | `"write, ddl"` | | | postgresql.auth.database | string | `"postgres"` | Database name | -| postgresql.auth.existingSecret | string | `"secret-postgres-init"` | Secret containing the passwords for root usernames postgres and non-root usernames repl_user, portal and provisioning. | +| postgresql.auth.existingSecret | string | `"secret-postgres-init"` | Secret containing the passwords for root usernames postgres and non-root usernames repl_user and hub. | | postgresql.auth.password | string | `""` | Password for the root username 'postgres'. Secret-key 'postgres-password'. | | postgresql.auth.policyHubPassword | string | `""` | Password for the non-root username 'hub'. Secret-key 'policy-hub-password'. | | postgresql.auth.policyHubUser | string | `"hub"` | Non-root username for hub. | diff --git a/charts/policyhub/README.md.gotmpl b/charts/policyhub/README.md.gotmpl index a5ee177..914412e 100644 --- a/charts/policyhub/README.md.gotmpl +++ b/charts/policyhub/README.md.gotmpl @@ -4,7 +4,7 @@ This helm chart installs the Catena-X Policy Hub application v1.0.0. -For information on how to upgrade from previous versions please refer to [Version Upgrade](https://github.com/eclipse-tractusx/policy-hub/tree/v1.0.0/docs/developer/Technical%20Documentation/Version%20Upgrade/portal-upgrade-details.md). +For information on how to upgrade from previous versions please refer to [Version Upgrade](https://github.com/eclipse-tractusx/policy-hub/tree/v1.0.0/docs/developer/Technical%20Documentation/Version%20Upgrade/policy-hub-upgrade-details.md). For further information please refer to [Technical Documentation](https://github.com/eclipse-tractusx/policy-hub/tree/v1.0.0/docs/developer/Technical%20Documentation). diff --git a/charts/policyhub/templates/deployment-backend-hub.yaml b/charts/policyhub/templates/deployment-backend-hub.yaml index 36bb1b2..0a755a2 100644 --- a/charts/policyhub/templates/deployment-backend-hub.yaml +++ b/charts/policyhub/templates/deployment-backend-hub.yaml @@ -60,7 +60,7 @@ spec: valueFrom: secretKeyRef: name: "{{ .Values.externalDatabase.secret }}" - key: "portal-password" + key: "policy-hub-password" - name: "CONNECTIONSTRINGS__POLICYHUBDB" value: "Server={{ .Values.externalDatabase.host }};Database={{ .Values.externalDatabase.database }};Port={{ .Values.externalDatabase.port }};User Id={{ .Values.externalDatabase.policyHubUser }};Password=$(POLICY_HUB_PASSWORD);Ssl Mode={{ .Values.backend.dbConnection.sslMode }};" - name: "HEALTHCHECKS__0__PATH" diff --git a/charts/policyhub/templates/job-backend-policy-hub-migrations.yaml b/charts/policyhub/templates/job-backend-policy-hub-migrations.yaml index f7780ac..01bdbfe 100644 --- a/charts/policyhub/templates/job-backend-policy-hub-migrations.yaml +++ b/charts/policyhub/templates/job-backend-policy-hub-migrations.yaml @@ -49,7 +49,7 @@ spec: valueFrom: secretKeyRef: name: "{{ .Values.postgresql.auth.existingSecret }}" - key: "portal-password" + key: "policy-hub-password" - name: "CONNECTIONSTRINGS__POLICYHUBDB" value: "Server={{ .Values.postgresql.fullnameOverride }}-primary;Database={{ .Values.postgresql.auth.database }};Port={{ .Values.postgresql.auth.port }};User Id={{ .Values.postgresql.auth.policyHubUser }};Password=$(POLICY_HUB_PASSWORD);Ssl Mode={{ .Values.backend.dbConnection.sslMode }};" {{- end }} @@ -58,7 +58,7 @@ spec: valueFrom: secretKeyRef: name: "{{ .Values.externalDatabase.secret }}" - key: "portal-password" + key: "policy-hub-password" - name: "CONNECTIONSTRINGS__POLICYHUBDB" value: "Server={{ .Values.externalDatabase.host }};Database={{ .Values.externalDatabase.database }};Port={{ .Values.externalDatabase.port }};User Id={{ .Values.externalDatabase.policyHubUser }};Password=$(POLICY_HUB_PASSWORD);Ssl Mode={{ .Values.backend.dbConnection.sslMode }};" {{- end }} diff --git a/charts/policyhub/values.yaml b/charts/policyhub/values.yaml index e278206..4ca2e53 100644 --- a/charts/policyhub/values.yaml +++ b/charts/policyhub/values.yaml @@ -62,7 +62,7 @@ backend: metadataPath: "/auth/realms/CX-Central/.well-known/openid-configuration" tokenValidationParameters: validIssuerPath: "/auth/realms/CX-Central" - validAudience: "Cl2-CX-Portal" + validAudience: "ClXX-CX-Policy-Hub" refreshInterval: "00:00:30" tokenPath: "/auth/realms/CX-Central/protocol/openid-connect/token" # -- Flag if the api should be used with an leading /auth path @@ -77,7 +77,7 @@ backend: policyhub: name: "policy-hub-service" image: - name: "tractusx/portal-hub-service" + name: "tractusx/policy-hub-service" policyhubservicetag: 29dbdeb9a8b3e809fdab2406140a226bc55de844 # -- We recommend not to specify default resources and to leave this as a conscious choice for the user. # If you do want to specify resources, uncomment the following lines, @@ -92,7 +92,7 @@ backend: logging: businessLogic: "Information" default: "Information" - keycloakClientId: "Cl2-CX-Portal" + keycloakClientId: "ClXX-CX-Policy-Hub" policyhubmigrations: name: "policy-hub-migrations" image: @@ -127,7 +127,7 @@ postgresql: database: "postgres" # -- Database port number port: 5432 - # -- Secret containing the passwords for root usernames postgres and non-root usernames repl_user, portal and provisioning. + # -- Secret containing the passwords for root usernames postgres and non-root usernames repl_user and hub. existingSecret: "secret-postgres-init" # -- Password for the root username 'postgres'. Secret-key 'postgres-password'. password: "" @@ -164,7 +164,7 @@ externalDatabase: database: "postgres" # -- Database port number port: 5432 - # -- Secret containing the passwords non-root usernames portal and provisioning. + # -- Secret containing the passwords non-root username hub. secret: "secret-postgres-external-db" # -- Non-root username for hub. policyHubUser: "hub" diff --git a/consortia/argocd-app-templates/appsetup-beta.yaml b/consortia/argocd-app-templates/appsetup-beta.yaml index fe0c59e..08cd0f3 100644 --- a/consortia/argocd-app-templates/appsetup-beta.yaml +++ b/consortia/argocd-app-templates/appsetup-beta.yaml @@ -20,19 +20,19 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: portal + name: policy-hub spec: destination: - namespace: product-portal + namespace: product-policy-hub server: 'https://kubernetes.default.svc' source: - path: charts/portal - repoURL: 'https://github.com/eclipse-tractusx/portal-cd.git' - targetRevision: portal-1.7.0-RC1 + path: charts/policy-hub + repoURL: 'https://github.com/eclipse-tractusx/policy-hub.git' + targetRevision: policy-hub-1.0.0 plugin: env: - name: AVP_SECRET value: vault-secret - name: helm_args value: '-f values.yaml -f ../../consortia/environments/values-beta.yaml' - project: project-portal + project: project-policy-hub diff --git a/consortia/argocd-app-templates/appsetup-dev.yaml b/consortia/argocd-app-templates/appsetup-dev.yaml index bc00d41..7301e8f 100644 --- a/consortia/argocd-app-templates/appsetup-dev.yaml +++ b/consortia/argocd-app-templates/appsetup-dev.yaml @@ -20,14 +20,14 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: portal-upgrade + name: policy-hub-upgrade spec: destination: - namespace: product-iam + namespace: policy-hub server: 'https://kubernetes.default.svc' source: - path: charts/portal - repoURL: 'https://github.com/eclipse-tractusx/portal-cd.git' + path: charts/policy-hub + repoURL: 'https://github.com/eclipse-tractusx/policy-hub-cd.git' targetRevision: dev plugin: env: @@ -35,7 +35,7 @@ spec: value: vault-secret - name: helm_args value: '-f values.yaml -f ../../consortia/environments/values-dev.yaml' - project: project-portal + project: project-policy-hub syncPolicy: automated: prune: true diff --git a/consortia/argocd-app-templates/appsetup-int.yaml b/consortia/argocd-app-templates/appsetup-int.yaml index 25baac2..c2d4696 100644 --- a/consortia/argocd-app-templates/appsetup-int.yaml +++ b/consortia/argocd-app-templates/appsetup-int.yaml @@ -20,19 +20,19 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: portal-upgrade + name: policy-hub-upgrade spec: destination: - namespace: product-portal + namespace: product-policy-hub server: 'https://kubernetes.default.svc' source: - path: charts/portal - repoURL: 'https://github.com/eclipse-tractusx/portal-cd.git' - targetRevision: portal-1.7.0-RC1 + path: charts/policy-hub + repoURL: 'https://github.com/eclipse-tractusx/policy-hub.git' + targetRevision: policy-hub-1.0.0 plugin: env: - name: AVP_SECRET value: vault-secret - name: helm_args value: '-f values.yaml -f ../../consortia/environments/values-int.yaml' - project: project-portal + project: project-policy-hub diff --git a/consortia/argocd-app-templates/appsetup-pen.yaml b/consortia/argocd-app-templates/appsetup-pen.yaml index 69996a3..0609895 100644 --- a/consortia/argocd-app-templates/appsetup-pen.yaml +++ b/consortia/argocd-app-templates/appsetup-pen.yaml @@ -20,19 +20,19 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: portal-pen + name: policy-hub-pen spec: destination: - namespace: product-portal-pen + namespace: product-policy-hub-pen server: 'https://kubernetes.default.svc' source: - path: charts/portal - repoURL: 'https://github.com/eclipse-tractusx/portal-cd.git' - targetRevision: portal-1.7.0-RC1 + path: charts/policy-hub + repoURL: 'https://github.com/eclipse-tractusx/policy-hub.git' + targetRevision: policy-hub-1.0.0 plugin: env: - name: AVP_SECRET value: vault-secret - name: helm_args value: '-f values.yaml -f ../../consortia/environments/values-pen.yaml' - project: project-portal + project: project-policy-hub diff --git a/consortia/argocd-app-templates/appsetup-rc.yaml b/consortia/argocd-app-templates/appsetup-rc.yaml index d807b82..e905585 100644 --- a/consortia/argocd-app-templates/appsetup-rc.yaml +++ b/consortia/argocd-app-templates/appsetup-rc.yaml @@ -20,14 +20,14 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: portal-rc + name: policy-hub-rc spec: destination: namespace: product-iam server: 'https://kubernetes.default.svc' source: - path: charts/portal - repoURL: 'https://github.com/eclipse-tractusx/portal-cd.git' + path: charts/policy-hub + repoURL: 'https://github.com/eclipse-tractusx/policy-hub.git' targetRevision: release-candidate plugin: env: @@ -35,4 +35,4 @@ spec: value: vault-secret - name: helm_args value: '-f values.yaml -f ../../consortia/environments/values-rc.yaml' - project: project-portal + project: project-policy-hub diff --git a/consortia/argocd-app-templates/appsetup-stable.yaml b/consortia/argocd-app-templates/appsetup-stable.yaml index eadc9c1..32c7261 100644 --- a/consortia/argocd-app-templates/appsetup-stable.yaml +++ b/consortia/argocd-app-templates/appsetup-stable.yaml @@ -20,11 +20,11 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: portal + name: policy-hub spec: destination: name: '' - namespace: product-portal + namespace: product-policy-hub server: 'https://kubernetes.default.svc' source: path: '' @@ -34,48 +34,7 @@ spec: env: - name: HELM_VALUES value: | - portalAddress: "https://portal.stable.demo.catena-x.net" - portalBackendAddress: "https://portal-backend.stable.demo.catena-x.net" - centralidpAddress: "https://centralidp.stable.demo.catena-x.net" - sharedidpAddress: "https://sharedidp.stable.demo.catena-x.net" - semanticsAddress: "https://semantics.stable.demo.catena-x.net" - bpdmPartnersPoolAddress: "https://business-partners.stable.demo.catena-x.net" - bpdmPortalGateAddress: "https://business-partners.stable.demo.catena-x.net" - custodianAddress: "https://managed-identity-wallets-new.stable.demo.catena-x.net" - sdfactoryAddress: "https://sdfactory.stable.demo.catena-x.net" - clearinghouseAddress: "https://validation.test.dih-cloud.com" - clearinghouseTokenAddress: "https://iam.test.dih-cloud.com/realms/carla/protocol/openid-connect/token" - frontend: - ingress: - enabled: true - className: "nginx" - annotations: - nginx.ingress.kubernetes.io/rewrite-target: "/$$1" - nginx.ingress.kubernetes.io/use-regex: "true" - nginx.ingress.kubernetes.io/enable-cors: "true" - nginx.ingress.kubernetes.io/cors-allow-origin: "http://localhost:3000, https://*.stable.demo.catena-x.net" - tls: - - secretName: "tls-secret" - hosts: - - "portal.stable.demo.catena-x.net" - hosts: - - host: "portal.stable.demo.catena-x.net" - paths: - - path: "/(.*)" - pathType: "Prefix" - backend: - service: "portal" - port: 8080 - - path: "/registration/(.*)" - pathType: "Prefix" - backend: - service: "registration" - port: 8080 - - path: "/((assets|documentation)/.*)" - pathType: "Prefix" - backend: - service: "assets" - port: 8080 + policyHubBackendAddress: "https://policy-hub.stable.demo.catena-x.net" backend: ingress: enabled: true @@ -88,170 +47,29 @@ spec: tls: - secretName: "tls-secret" hosts: - - "portal-backend.stable.demo.catena-x.net" + - "policy-hub.stable.demo.catena-x.net" hosts: - - host: "portal-backend.stable.demo.catena-x.net" + - host: "policy-hub.stable.demo.catena-x.net" paths: - - path: "/api/registration" - pathType: "Prefix" - backend: - service: "registration-service" - port: 8080 - - path: "/api/administration" - pathType: "Prefix" - backend: - service: "administration-service" - port: 8080 - - path: "/api/notification" - pathType: "Prefix" - backend: - service: "notification-service" - port: 8080 - - path: "/api/apps" - pathType: "Prefix" - backend: - service: "marketplace-app-service" - port: 8080 - - path: "/api/services" + - path: "/api/policy-hub" pathType: "Prefix" backend: - service: "services-service" + service: "policy-hub-service" port: 8080 - keycloak: - central: - clientId: "" - clientSecret: "" - dbConnection: - password: "" - shared: - clientId: "" - clientSecret: "" - mailing: - host: "" - port: "" - user: "" - password: "" - registration: - logging: - default: "Debug" - bpdmLibrary: "Debug" - registrationService: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - administration: + policyhubmigrations: logging: default: "Debug" - businessLogic: "Debug" - sdfactoryLibrary: "Debug" - bpdmLibrary: "Debug" - custodianLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - - name: "HEALTHCHECKS__0__TAGS__2" - value: "provisioningdb" - onboardingServiceProvider: - encryptionKey: "" - swaggerEnabled: true - provisioning: - sharedRealm: - smtpServer: - host: "" - port: "" - user: "" - password: "" - from: "" - replyTo: "" - appmarketplace: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - portalmigrations: - logging: - default: "Debug" - seeding: - testDataEnvironments: "consortia" - notification: - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - logging: - default: "Debug" - swaggerEnabled: true - services: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - processesworker: - logging: - default: "Debug" - processesLibrary: "Debug" - bpdmLibrary: "Debug" - clearinghouseLibrary: "Debug" - custodianLibrary: "Debug" - sdfactoryLibrary: "Debug" - offerProvider: "Debug" - bpdm: - clientId: "" - clientSecret: "" - clearinghouse: - clientId: "" - clientSecret: "" - custodian: - clientId: "" - clientSecret: "" - sdfactory: - issuerBpn: "BPNL00000003CRHK" - clientId: "" - clientSecret: "" - offerprovider: - clientId: "" - clientSecret: "" - onboardingServiceProvider: - encryptionKey: "" - postgresql: auth: - password: "" - replicationPassword: "" - portalPassword: "" - provisioningPassword: "" + password: "" + replicationPassword: "" + policy-hubPassword: "" primary: extendedConfiguration: | max_connections = 200 readReplicas: extendedConfiguration: | max_connections = 200 - chart: portal + chart: policy-hub sources: [] - project: project-portal + project: project-policy-hub diff --git a/consortia/argocd-app-templates/appsetup-upgrade.yaml b/consortia/argocd-app-templates/appsetup-upgrade.yaml index a72d5a1..1426a5b 100644 --- a/consortia/argocd-app-templates/appsetup-upgrade.yaml +++ b/consortia/argocd-app-templates/appsetup-upgrade.yaml @@ -20,19 +20,19 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: portal + name: policy-hub spec: destination: - namespace: product-portal + namespace: product-policy-hub server: 'https://kubernetes.default.svc' source: - path: charts/portal - repoURL: 'https://github.com/eclipse-tractusx/portal-cd.git' - targetRevision: portal-1.7.0-RC1 + path: charts/policy-hub + repoURL: 'https://github.com/eclipse-tractusx/policy-hub.git' + targetRevision: policy-hub-1.0.0 plugin: env: - name: AVP_SECRET value: vault-secret - name: helm_args value: '-f values.yaml -f ../../consortia/environments/values-upgrade.yaml' - project: project-portal + project: project-policy-hub diff --git a/consortia/environments/values-beta.yaml b/consortia/environments/values-beta.yaml index b362744..cc1afe5 100644 --- a/consortia/environments/values-beta.yaml +++ b/consortia/environments/values-beta.yaml @@ -17,17 +17,8 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -portalAddress: "https://portal.beta.demo.catena-x.net" -portalBackendAddress: "https://portal-backend.beta.demo.catena-x.net" +policyHubBackendAddress: "https://policy-hub.beta.demo.catena-x.net" centralidpAddress: "https://centralidp.beta.demo.catena-x.net" -sharedidpAddress: "https://sharedidp.beta.demo.catena-x.net" -semanticsAddress: "https://semantics.beta.demo.catena-x.net" -bpdmPartnersPoolAddress: "https://business-partners.beta.demo.catena-x.net" -bpdmPortalGateAddress: "https://business-partners.beta.demo.catena-x.net" -custodianAddress: "https://managed-identity-wallets-new.beta.demo.catena-x.net" -sdfactoryAddress: "https://sdfactory.beta.demo.catena-x.net" -clearinghouseAddress: "https://validation.test.dih-cloud.com" -clearinghouseTokenAddress: "https://iam.test.dih-cloud.com/realms/carla/protocol/openid-connect/token" frontend: @@ -42,24 +33,14 @@ frontend: tls: - secretName: "tls-secret" hosts: - - "portal.beta.demo.catena-x.net" + - "policy-hub.beta.demo.catena-x.net" hosts: - - host: "portal.beta.demo.catena-x.net" + - host: "policy-hub.beta.demo.catena-x.net" paths: - path: "/(.*)" pathType: "Prefix" backend: - service: "portal" - port: 8080 - - path: "/registration/(.*)" - pathType: "Prefix" - backend: - service: "registration" - port: 8080 - - path: "/((assets|documentation)/.*)" - pathType: "Prefix" - backend: - service: "assets" + service: "policy-hub" port: 8080 backend: @@ -74,174 +55,25 @@ backend: tls: - secretName: "tls-secret" hosts: - - "portal-backend.beta.demo.catena-x.net" + - "policy-hub.beta.demo.catena-x.net" hosts: - - host: "portal-backend.beta.demo.catena-x.net" + - host: "policy-hub.beta.demo.catena-x.net" paths: - - path: "/api/registration" - pathType: "Prefix" - backend: - service: "registration-service" - port: 8080 - - path: "/api/administration" - pathType: "Prefix" - backend: - service: "administration-service" - port: 8080 - - path: "/api/notification" - pathType: "Prefix" - backend: - service: "notification-service" - port: 8080 - - path: "/api/apps" + - path: "/api/policy-hub" pathType: "Prefix" backend: - service: "marketplace-app-service" + service: "policy-hub-service" port: 8080 - - path: "/api/services" - pathType: "Prefix" - backend: - service: "services-service" - port: 8080 - - keycloak: - central: - clientId: "" - clientSecret: "" - dbConnection: - password: "" - shared: - clientId: "" - clientSecret: "" - - mailing: - host: "" - port: "" - user: "" - password: "" - - registration: - logging: - default: "Debug" - bpdmLibrary: "Debug" - registrationService: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - administration: - logging: - default: "Debug" - businessLogic: "Debug" - sdfactoryLibrary: "Debug" - bpdmLibrary: "Debug" - custodianLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - - name: "HEALTHCHECKS__0__TAGS__2" - value: "provisioningdb" - onboardingServiceProvider: - encryptionKey: "" - swaggerEnabled: true - - provisioning: - sharedRealm: - smtpServer: - host: "" - port: "" - user: "" - password: "" - from: "" - replyTo: "" - - appmarketplace: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - portalmigrations: - logging: - default: "Debug" - seeding: - testDataEnvironments: "consortia" - - notification: - logging: - default: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - services: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - processesworker: + policyhubmigrations: logging: default: "Debug" - processesLibrary: "Debug" - bpdmLibrary: "Debug" - clearinghouseLibrary: "Debug" - custodianLibrary: "Debug" - sdfactoryLibrary: "Debug" - offerProvider: "Debug" - bpdm: - clientId: "" - clientSecret: "" - clearinghouse: - clientId: "" - clientSecret: "" - custodian: - clientId: "" - clientSecret: "" - sdfactory: - issuerBpn: "BPNL00000003CRHK" - clientId: "" - clientSecret: "" - offerprovider: - clientId: "" - clientSecret: "" - onboardingServiceProvider: - encryptionKey: "" postgresql: auth: - password: "" - replicationPassword: "" - portalPassword: "" - provisioningPassword: "" + password: "" + replicationPassword: "" + policyHubPassword: "" primary: extendedConfiguration: | max_connections = 200 diff --git a/consortia/environments/values-dev.yaml b/consortia/environments/values-dev.yaml index 4c297d9..8479e5b 100644 --- a/consortia/environments/values-dev.yaml +++ b/consortia/environments/values-dev.yaml @@ -17,50 +17,8 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -portalAddress: "https://portal.dev.demo.catena-x.net" -portalBackendAddress: "https://portal-backend.dev.demo.catena-x.net" +policyHubAddress: "https://policy-hub.dev.demo.catena-x.net" centralidpAddress: "https://centralidp.dev.demo.catena-x.net" -sharedidpAddress: "https://sharedidp.dev.demo.catena-x.net" -semanticsAddress: "https://semantics.dev.demo.catena-x.net" -bpdmPartnersPoolAddress: "https://business-partners.dev.demo.catena-x.net" -bpdmPortalGateAddress: "https://business-partners.dev.demo.catena-x.net" -custodianAddress: "https://managed-identity-wallets-new.dev.demo.catena-x.net" -sdfactoryAddress: "https://sdfactory.dev.demo.catena-x.net" -clearinghouseAddress: "https://validation.test.dih-cloud.com" -clearinghouseTokenAddress: "https://iam.test.dih-cloud.com/realms/carla/protocol/openid-connect/token" - -frontend: - - ingress: - enabled: true - className: "nginx" - annotations: - nginx.ingress.kubernetes.io/rewrite-target: "/$1" - nginx.ingress.kubernetes.io/use-regex: "true" - nginx.ingress.kubernetes.io/enable-cors: "true" - nginx.ingress.kubernetes.io/cors-allow-origin: "http://localhost:3000, https://*.dev.demo.catena-x.net" - tls: - - secretName: "tls-secret" - hosts: - - "portal.dev.demo.catena-x.net" - hosts: - - host: "portal.dev.demo.catena-x.net" - paths: - - path: "/(.*)" - pathType: "Prefix" - backend: - service: "portal" - port: 8080 - - path: "/registration/(.*)" - pathType: "Prefix" - backend: - service: "registration" - port: 8080 - - path: "/((assets|documentation)/.*)" - pathType: "Prefix" - backend: - service: "assets" - port: 8080 backend: ingress: @@ -74,174 +32,25 @@ backend: tls: - secretName: "tls-secret" hosts: - - "portal-backend.dev.demo.catena-x.net" + - "policy-hub.dev.demo.catena-x.net" hosts: - - host: "portal-backend.dev.demo.catena-x.net" + - host: "policy-hub.dev.demo.catena-x.net" paths: - - path: "/api/registration" - pathType: "Prefix" - backend: - service: "registration-service" - port: 8080 - - path: "/api/administration" - pathType: "Prefix" - backend: - service: "administration-service" - port: 8080 - - path: "/api/notification" - pathType: "Prefix" - backend: - service: "notification-service" - port: 8080 - - path: "/api/apps" - pathType: "Prefix" - backend: - service: "marketplace-app-service" - port: 8080 - - path: "/api/services" + - path: "/api/policy-hub" pathType: "Prefix" backend: - service: "services-service" + service: "policy-hub-service" port: 8080 - keycloak: - central: - clientId: "" - clientSecret: "" - dbConnection: - password: "" - shared: - clientId: "" - clientSecret: "" - - mailing: - host: "" - port: "" - user: "" - password: "" - - registration: - logging: - default: "Debug" - bpdmLibrary: "Debug" - registrationService: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - administration: - logging: - default: "Debug" - businessLogic: "Debug" - sdfactoryLibrary: "Debug" - bpdmLibrary: "Debug" - custodianLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - - name: "HEALTHCHECKS__0__TAGS__2" - value: "provisioningdb" - onboardingServiceProvider: - encryptionKey: "" - swaggerEnabled: true - - provisioning: - sharedRealm: - smtpServer: - host: "" - port: "" - user: "" - password: "" - from: "" - replyTo: "" - - appmarketplace: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - portalmigrations: - logging: - default: "Debug" - seeding: - testDataEnvironments: "consortia" - - notification: - logging: - default: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - services: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - processesworker: + policyhubmigrations: logging: default: "Debug" - processesLibrary: "Debug" - bpdmLibrary: "Debug" - clearinghouseLibrary: "Debug" - custodianLibrary: "Debug" - sdfactoryLibrary: "Debug" - offerProvider: "Debug" - bpdm: - clientId: "" - clientSecret: "" - clearinghouse: - clientId: "" - clientSecret: "" - custodian: - clientId: "" - clientSecret: "" - sdfactory: - issuerBpn: "BPNL00000003CRHK" - clientId: "" - clientSecret: "" - offerprovider: - clientId: "" - clientSecret: "" - onboardingServiceProvider: - encryptionKey: "" postgresql: auth: - password: "" - replicationPassword: "" - portalPassword: "" - provisioningPassword: "" + password: "" + replicationPassword: "" + policyHubPassword: "" primary: extendedConfiguration: | max_connections = 200 diff --git a/consortia/environments/values-int.yaml b/consortia/environments/values-int.yaml index 066d957..fc4bc8b 100644 --- a/consortia/environments/values-int.yaml +++ b/consortia/environments/values-int.yaml @@ -17,50 +17,8 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -portalAddress: "https://portal.int.demo.catena-x.net" -portalBackendAddress: "https://portal-backend.int.demo.catena-x.net" +policyHubAddress: "https://policy-hub.int.demo.catena-x.net" centralidpAddress: "https://centralidp.int.demo.catena-x.net" -sharedidpAddress: "https://sharedidp.int.demo.catena-x.net" -semanticsAddress: "https://semantics.int.demo.catena-x.net" -bpdmPartnersPoolAddress: "https://business-partners.int.demo.catena-x.net" -bpdmPortalGateAddress: "https://business-partners.int.demo.catena-x.net" -custodianAddress: "https://managed-identity-wallets-new.int.demo.catena-x.net" -sdfactoryAddress: "https://sdfactory.int.demo.catena-x.net" -clearinghouseAddress: "https://validation.test.dih-cloud.com" -clearinghouseTokenAddress: "https://iam.test.dih-cloud.com/realms/carla/protocol/openid-connect/token" - -frontend: - - ingress: - enabled: true - className: "nginx" - annotations: - nginx.ingress.kubernetes.io/rewrite-target: "/$1" - nginx.ingress.kubernetes.io/use-regex: "true" - nginx.ingress.kubernetes.io/enable-cors: "true" - nginx.ingress.kubernetes.io/cors-allow-origin: "http://localhost:3000, https://*.int.demo.catena-x.net" - tls: - - secretName: "tls-secret" - hosts: - - "portal.int.demo.catena-x.net" - hosts: - - host: "portal.int.demo.catena-x.net" - paths: - - path: "/(.*)" - pathType: "Prefix" - backend: - service: "portal" - port: 8080 - - path: "/registration/(.*)" - pathType: "Prefix" - backend: - service: "registration" - port: 8080 - - path: "/((assets|documentation)/.*)" - pathType: "Prefix" - backend: - service: "assets" - port: 8080 backend: ingress: @@ -74,174 +32,27 @@ backend: tls: - secretName: "tls-secret" hosts: - - "portal-backend.int.demo.catena-x.net" + - "policy-hub.int.demo.catena-x.net" hosts: - - host: "portal-backend.int.demo.catena-x.net" + - host: "policy-hub.int.demo.catena-x.net" paths: - - path: "/api/registration" - pathType: "Prefix" - backend: - service: "registration-service" - port: 8080 - - path: "/api/administration" - pathType: "Prefix" - backend: - service: "administration-service" - port: 8080 - - path: "/api/notification" - pathType: "Prefix" - backend: - service: "notification-service" - port: 8080 - - path: "/api/apps" - pathType: "Prefix" - backend: - service: "marketplace-app-service" - port: 8080 - - path: "/api/services" + - path: "/api/policy-hub" pathType: "Prefix" backend: - service: "services-service" + service: "policy-hub-service" port: 8080 - keycloak: - central: - clientId: "" - clientSecret: "" - dbConnection: - password: "" - shared: - clientId: "" - clientSecret: "" - - mailing: - host: "" - port: "" - user: "" - password: "" - - registration: - logging: - default: "Debug" - bpdmLibrary: "Debug" - registrationService: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - administration: - logging: - default: "Debug" - businessLogic: "Debug" - sdfactoryLibrary: "Debug" - bpdmLibrary: "Debug" - custodianLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - - name: "HEALTHCHECKS__0__TAGS__2" - value: "provisioningdb" - onboardingServiceProvider: - encryptionKey: "" - swaggerEnabled: true - - provisioning: - sharedRealm: - smtpServer: - host: "" - port: "" - user: "" - password: "" - from: "" - replyTo: "" - - appmarketplace: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - portalmigrations: + policyhubmigrations: logging: default: "Debug" seeding: testDataEnvironments: "consortia" - notification: - logging: - default: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - services: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - processesworker: - logging: - default: "Debug" - processesLibrary: "Debug" - bpdmLibrary: "Debug" - clearinghouseLibrary: "Debug" - custodianLibrary: "Debug" - sdfactoryLibrary: "Debug" - offerProvider: "Debug" - bpdm: - clientId: "" - clientSecret: "" - clearinghouse: - clientId: "" - clientSecret: "" - custodian: - clientId: "" - clientSecret: "" - sdfactory: - issuerBpn: "BPNL00000003CRHK" - clientId: "" - clientSecret: "" - offerprovider: - clientId: "" - clientSecret: "" - onboardingServiceProvider: - encryptionKey: "" - postgresql: auth: - password: "" - replicationPassword: "" - portalPassword: "" - provisioningPassword: "" + password: "" + replicationPassword: "" + policyHubPassword: "" primary: extendedConfiguration: | max_connections = 200 diff --git a/consortia/environments/values-pen.yaml b/consortia/environments/values-pen.yaml index 50e4fe3..1c07a94 100644 --- a/consortia/environments/values-pen.yaml +++ b/consortia/environments/values-pen.yaml @@ -17,50 +17,8 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -portalAddress: "https://portal-pen.dev.demo.catena-x.net" -portalBackendAddress: "https://portal-backend-pen.dev.demo.catena-x.net" +policyHubAddress: "https://policy-hub-pen.dev.demo.catena-x.net" centralidpAddress: "https://centralidp-pen.dev.demo.catena-x.net" -sharedidpAddress: "https://sharedidp-pen.dev.demo.catena-x.net" -semanticsAddress: "https://semantics-pen.dev.demo.catena-x.net" -bpdmPartnersPoolAddress: "https://business-partners-pen.dev.demo.catena-x.net" -bpdmPortalGateAddress: "https://business-partners-pen.dev.demo.catena-x.net" -custodianAddress: "https://managed-identity-wallets-pen-new.dev.demo.catena-x.net" -sdfactoryAddress: "https://sdfactory-pen.dev.demo.catena-x.net" -clearinghouseAddress: "https://validation.test.dih-cloud.com" -clearinghouseTokenAddress: "https://iam.test.dih-cloud.com/realms/carla/protocol/openid-connect/token" - -frontend: - - ingress: - enabled: true - className: "nginx" - annotations: - nginx.ingress.kubernetes.io/rewrite-target: "/$1" - nginx.ingress.kubernetes.io/use-regex: "true" - nginx.ingress.kubernetes.io/enable-cors: "true" - nginx.ingress.kubernetes.io/cors-allow-origin: "http://localhost:3000, https://*.dev.demo.catena-x.net" - tls: - - secretName: "tls-secret" - hosts: - - "portal-pen.dev.demo.catena-x.net" - hosts: - - host: "portal-pen.dev.demo.catena-x.net" - paths: - - path: "/(.*)" - pathType: "Prefix" - backend: - service: "portal" - port: 8080 - - path: "/registration/(.*)" - pathType: "Prefix" - backend: - service: "registration" - port: 8080 - - path: "/((assets|documentation)/.*)" - pathType: "Prefix" - backend: - service: "assets" - port: 8080 backend: ingress: @@ -74,175 +32,25 @@ backend: tls: - secretName: "tls-secret" hosts: - - "portal-backend-pen.dev.demo.catena-x.net" + - "policy-hub-backend-pen.dev.demo.catena-x.net" hosts: - - host: "portal-backend-pen.dev.demo.catena-x.net" + - host: "policy-hub-backend-pen.dev.demo.catena-x.net" paths: - - path: "/api/registration" - pathType: "Prefix" - backend: - service: "registration-service" - port: 8080 - - path: "/api/administration" - pathType: "Prefix" - backend: - service: "administration-service" - port: 8080 - - path: "/api/notification" - pathType: "Prefix" - backend: - service: "notification-service" - port: 8080 - - path: "/api/apps" - pathType: "Prefix" - backend: - service: "marketplace-app-service" - port: 8080 - - path: "/api/services" + - path: "/api/policy-hub" pathType: "Prefix" backend: - service: "services-service" + service: "policy-hub-service" port: 8080 - keycloak: - central: - clientId: "" - clientSecret: "" - dbConnection: - host: "centralidp-pen-postgresql-primary" - password: "" - shared: - clientId: "" - clientSecret: "" - - mailing: - host: "" - port: "" - user: "" - password: "" - - registration: - logging: - default: "Debug" - bpdmLibrary: "Debug" - registrationService: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - administration: - logging: - default: "Debug" - businessLogic: "Debug" - sdfactoryLibrary: "Debug" - bpdmLibrary: "Debug" - custodianLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - - name: "HEALTHCHECKS__0__TAGS__2" - value: "provisioningdb" - onboardingServiceProvider: - encryptionKey: "" - swaggerEnabled: true - - provisioning: - sharedRealm: - smtpServer: - host: "" - port: "" - user: "" - password: "" - from: "" - replyTo: "" - - appmarketplace: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - portalmigrations: - logging: - default: "Debug" - seeding: - testDataEnvironments: "consortia" - - notification: - logging: - default: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - services: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - processesworker: + policyhubmigrations: logging: default: "Debug" - processesLibrary: "Debug" - bpdmLibrary: "Debug" - clearinghouseLibrary: "Debug" - custodianLibrary: "Debug" - sdfactoryLibrary: "Debug" - offerProvider: "Debug" - bpdm: - clientId: "" - clientSecret: "" - clearinghouse: - clientId: "" - clientSecret: "" - custodian: - clientId: "" - clientSecret: "" - sdfactory: - issuerBpn: "BPNL00000003CRHK" - clientId: "" - clientSecret: "" - offerprovider: - clientId: "" - clientSecret: "" - onboardingServiceProvider: - encryptionKey: "" postgresql: auth: - password: "" - replicationPassword: "" - portalPassword: "" - provisioningPassword: "" + password: "" + replicationPassword: "" + policyHubPassword: "" primary: extendedConfiguration: | max_connections = 200 diff --git a/consortia/environments/values-rc.yaml b/consortia/environments/values-rc.yaml index 6acbdce..2f92194 100644 --- a/consortia/environments/values-rc.yaml +++ b/consortia/environments/values-rc.yaml @@ -17,50 +17,8 @@ # SPDX-License-Identifier: Apache-2.0 ############################################################### -portalAddress: "https://portal-rc.dev.demo.catena-x.net" -portalBackendAddress: "https://portal-backend-rc.dev.demo.catena-x.net" +policyHubAddress: "https://policy-hub-rc.dev.demo.catena-x.net" centralidpAddress: "https://centralidp-rc.dev.demo.catena-x.net" -sharedidpAddress: "https://sharedidp-rc.dev.demo.catena-x.net" -semanticsAddress: "https://semantics.dev.demo.catena-x.net" -bpdmPartnersPoolAddress: "https://business-partners.dev.demo.catena-x.net" -bpdmPortalGateAddress: "https://business-partners.dev.demo.catena-x.net" -custodianAddress: "https://managed-identity-wallets-new.dev.demo.catena-x.net" -sdfactoryAddress: "https://sdfactory.dev.demo.catena-x.net" -clearinghouseAddress: "https://validation.test.dih-cloud.com" -clearinghouseTokenAddress: "https://iam.test.dih-cloud.com/realms/carla/protocol/openid-connect/token" - -frontend: - - ingress: - enabled: true - className: "nginx" - annotations: - nginx.ingress.kubernetes.io/rewrite-target: "/$1" - nginx.ingress.kubernetes.io/use-regex: "true" - nginx.ingress.kubernetes.io/enable-cors: "true" - nginx.ingress.kubernetes.io/cors-allow-origin: "http://localhost:3000, https://*.dev.demo.catena-x.net" - tls: - - secretName: "tls-secret" - hosts: - - "portal-rc.dev.demo.catena-x.net" - hosts: - - host: "portal-rc.dev.demo.catena-x.net" - paths: - - path: "/(.*)" - pathType: "Prefix" - backend: - service: "portal" - port: 8080 - - path: "/registration/(.*)" - pathType: "Prefix" - backend: - service: "registration" - port: 8080 - - path: "/((assets|documentation)/.*)" - pathType: "Prefix" - backend: - service: "assets" - port: 8080 backend: ingress: @@ -74,175 +32,26 @@ backend: tls: - secretName: "tls-secret" hosts: - - "portal-backend-rc.dev.demo.catena-x.net" + - "policy-hub-backend-rc.dev.demo.catena-x.net" hosts: - - host: "portal-backend-rc.dev.demo.catena-x.net" + - host: "policy-hub-backend-rc.dev.demo.catena-x.net" paths: - - path: "/api/registration" - pathType: "Prefix" - backend: - service: "registration-service" - port: 8080 - - path: "/api/administration" - pathType: "Prefix" - backend: - service: "administration-service" - port: 8080 - - path: "/api/notification" - pathType: "Prefix" - backend: - service: "notification-service" - port: 8080 - - path: "/api/apps" - pathType: "Prefix" - backend: - service: "marketplace-app-service" - port: 8080 - - path: "/api/services" + - path: "/api/policy-hub" pathType: "Prefix" backend: - service: "services-service" + service: "policy-hub-service" port: 8080 - keycloak: - central: - clientId: "" - clientSecret: "" - dbConnection: - password: "" - shared: - clientId: "" - clientSecret: "" - - mailing: - host: "" - port: "" - user: "" - password: "" - - registration: - logging: - default: "Debug" - bpdmLibrary: "Debug" - registrationService: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - administration: - logging: - default: "Debug" - businessLogic: "Debug" - sdfactoryLibrary: "Debug" - bpdmLibrary: "Debug" - custodianLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - - name: "HEALTHCHECKS__0__TAGS__2" - value: "provisioningdb" - onboardingServiceProvider: - encryptionKey: "" - swaggerEnabled: true - - provisioning: - sharedRealm: - smtpServer: - host: "" - port: "" - user: "" - password: "" - from: "" - replyTo: "" - - appmarketplace: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - portalmigrations: - logging: - default: "Debug" - seeding: - testDataEnvironments: "consortia" - - notification: - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - logging: - default: "Debug" - swaggerEnabled: true - - services: - logging: - default: "Debug" - offersLibrary: "Debug" - healthChecks: - startup: - tags: - - name: "HEALTHCHECKS__0__TAGS__0" - value: "keycloak" - - name: "HEALTHCHECKS__0__TAGS__1" - value: "portaldb" - swaggerEnabled: true - - processesworker: + policyhubmigrations: logging: default: "Debug" - processesLibrary: "Debug" - bpdmLibrary: "Debug" - clearinghouseLibrary: "Debug" - custodianLibrary: "Debug" - sdfactoryLibrary: "Debug" - offerProvider: "Debug" - bpdm: - clientId: "" - clientSecret: "" - clearinghouse: - clientId: "" - clientSecret: "" - custodian: - clientId: "" - clientSecret: "" - sdfactory: - issuerBpn: "BPNL00000003CRHK" - clientId: "" - clientSecret: "" - offerprovider: - clientId: "" - clientSecret: "" - onboardingServiceProvider: - encryptionKey: "" postgresql: - fullnameOverride: "portal-backend-rc-postgresql" + fullnameOverride: "policy-hub-backend-rc-postgresql" auth: - password: "" - replicationPassword: "" - portalPassword: "" - provisioningPassword: "" + password: "" + replicationPassword: "" + policyHubPassword: "" primary: extendedConfiguration: | max_connections = 200 diff --git a/consortia/environments/values-upgrade.yaml b/consortia/environments/values-upgrade.yaml index eba6c62..8efce1b 100644 --- a/consortia/environments/values-upgrade.yaml +++ b/consortia/environments/values-upgrade.yaml @@ -21,7 +21,6 @@ replicaCount: 0 postgresql: auth: - password: "" - replicationPassword: "" - portalPassword: "" - provisioningPassword: "" + password: "" + replicationPassword: "" + policyHubPassword: "" diff --git a/docs/Release Process.md b/docs/Release Process.md new file mode 100644 index 0000000..0eaf558 --- /dev/null +++ b/docs/Release Process.md @@ -0,0 +1,76 @@ +# Release Process + +The release process for a new version can roughly be divided in the following steps: + +* Preparation +* Build of a versioned image +* Release of a new helm chart version +* Merge upstream to eclipse-tractusx + +The process builds on the development flow which takes place within the forks from eclipse-tractusx, located in the catenax-ng organization. + +## Preparation + +It's recommended to do step 1-3 in one preparatory pull request to main, or dev respectively. + +### 1. Update changelog file + +The changelog file tracks all notable changes since the last released version. +During development every developer should extend the changelog under the 'Unreleased' section when raising a pull request to main or dev. +Once a new version is ready to be released, the changelog of the version gets finalized and the release version gets set for the, up to then, unreleased changes. +In the released version, the changelog is structured as following: + +* Changes +* Features +* Technical Support +* Bug Fixes + +In case of breaking change, the breaking change will get highlighted with a breaking change tag => ![Tag](https://img.shields.io/static/v1?label=&message=BreakingChange&color=yellow&style=flat) + +### 2. Update dependencies file + +In order to have an up-to-date list, of the used third-party libraries, the dependencies file needs to be updated. + +This can be done by running the following statement: + +```bash +dotnet list src package --include-transitive > DEPENDENCIES-PREP +cat DEPENDENCIES-PREP | grep ">" | grep -Pv "\s(Org|Microsoft|NuGet|System|runtime|docker|Docker|NETStandard)" | sed -E -e "s/\s+> ([a-zA-Z\.\-]+).+\s([0-9]+\.[0-9]+\.[0-9]+)\s*/nuget\/nuget\/\-\/\1\/\2/g" > DEPENDENCIES +awk -i inplace '!seen[$0]++' DEPENDENCIES +``` + +Only commit the updated dependencies file, not the 'DEPENDENCIES-PREP' file. + +### 3. Version bump + +To update the version please adjust the version in the `src` directory within the `Directory.Build.props` file. + +TODO (EG): we might add something here + +### 4. Merge from dev into main branch + +The merge from dev into main, via pull request, needs to happen before releasing. + +## Build of a versioned image + +It's important to pull the latest state from main of every repository. +Then a tag for the released version (e.g. v0.10.0) needs to be created and pushed. +The push of the tag triggers the release workflow action (available in every repository) which creates the versioned image/s. + +## Release of a new helm chart version + +TODO (EG): depending on our process we need to add something here + +## Merge upstream to eclipse-tractusx + +Once a new version has been released, it should be merged upstream to eclipse-tractusx and tagged. + +- https://github.com/eclipse-tractusx/policy-hub + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/Dev-Process/Dev-flow_deploy-dev-env.md b/docs/developer/Technical-Documentation/Dev-Process/Dev-flow_deploy-dev-env.md new file mode 100644 index 0000000..4db0726 --- /dev/null +++ b/docs/developer/Technical-Documentation/Dev-Process/Dev-flow_deploy-dev-env.md @@ -0,0 +1,31 @@ +# Dev flow with deployment to dev environment + +```mermaid +flowchart LR + subgraph local + D(Developer) + end + subgraph eclipse-tractusx + direction LR + D -- PR* to dev*--> PH(policy-hub**) + click PH "https://github.com/eclipse-tractusx/policy-hub" + end + subgraph Argo CD - sync to k8s cluster + PH -- auto-sync --> A(Argo CD dev) + click A "https://argo.dev.demo.catena-x.net" + end +``` + +Note\* Every pull request (PR) requires at least one approving review by a committer + +Note\*\* Unit tests and Sonarcloud runs at pull request, Trivy and KICS scans at merge as well as daily and Veracode scan runs weekly + +Note\*\* Trivy and KICS scans are scheduled to daily + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/Dev-Process/Dev-flow_git-diagram.md b/docs/developer/Technical-Documentation/Dev-Process/Dev-flow_git-diagram.md new file mode 100644 index 0000000..92be5c1 --- /dev/null +++ b/docs/developer/Technical-Documentation/Dev-Process/Dev-flow_git-diagram.md @@ -0,0 +1,133 @@ +# Dev flow (git diagram) + +```mermaid +%%{init: { 'logLevel': 'debug', 'theme': 'base' } }%% +gitGraph + commit id: "release: v1.0.0" tag:"1.0.0" + branch dev order: 1 + checkout dev + branch feature/feature1 order: 2 + commit id:"feat(function): add feature1" + checkout dev + branch bug/bug1 order: 3 + commit id: "fix(function): change bug1" + checkout dev + branch feature/feature2 order: 4 + commit id:"feat(function)!: enable feature2" + checkout bug/bug1 + commit id:"fix(function): refactor bug1" + checkout dev + merge bug/bug1 + checkout dev + branch feature/feature3 order: 5 + commit id:"feat(function): wip - enable feature3" + checkout dev + checkout feature/feature3 + commit id: "feat(function): enable feature3" + checkout dev + merge feature/feature3 + checkout feature/feature1 + commit id:"feat(function): enable feature1" + checkout dev + merge feature/feature1 + branch release/1.1.0 order: 6 + commit id: "release(1.1.0): aggregate migrations (backend)" + commit id: "release(1.1.0): update version, changelog..." tag: "1.1.0" + checkout main + merge release/1.1.0 id: "1. merge into main" + checkout dev + merge main id: "2. merge main into dev" + checkout dev + branch feature/feature4 order: 7 + commit id: "feat(function): add feature4" + checkout feature/feature2 + commit id: "feat(function)!: change feature2" + checkout dev + merge feature/feature2 + checkout feature/feature4 + commit id: "feat(function): change feature4" + checkout dev + merge feature/feature4 + branch release/1.2.0 order: 8 + commit id: "release(1.2.0-RC1): prepare migration (backend)" + commit id: "release(1.2.0-RC1): update version, changelog..." tag: "1.2.0-RC1" + checkout main + merge release/1.2.0 + checkout dev + merge main + checkout release/1.2.0 + branch bug/bug2 order: 9 + commit id:"fix(function): change1 bug2" + checkout release/1.2.0 + branch bug/bug3 order: 10 + commit id:"fix(function): change bug3" + checkout release/1.2.0 + merge bug/bug3 + merge dev + checkout dev + branch feature/feature5 order: 11 + commit id: "feat(function): add feature5" + checkout bug/bug2 + commit id:"fix(function): change2 bug2" + checkout release/1.2.0 + merge bug/bug2 + commit id: "release(1.2.0-RC2): update version, changelog..." tag: "1.2.0-RC2" + checkout main + merge release/1.2.0 + checkout dev + merge main + checkout dev + branch feature/feature6 order: 12 + commit id: "feat(function): add feature for 1.4.0" + checkout feature/feature5 + commit id: "feat(function): change feature5" + checkout dev + merge feature/feature5 + branch release/1.3.0 order: 13 + commit id: "release(1.3.0): aggregate migrations (backend)" + commit id: "release(1.3.0): update version, changelog..." tag: "1.3.0" + checkout main + merge release/1.3.0 + checkout dev + merge main + checkout feature/feature6 + commit id: "feat(function): change feature for 1.4.0" + merge dev + checkout release/1.2.0 + branch bug/bug4 order: 14 + commit id:"fix(function): change1 bug4" + commit id:"fix(function): change2 bug4" + checkout release/1.2.0 + merge bug/bug4 + commit id: "release(1.2.0): update version, changelog..." tag: "1.2.0" + checkout main + merge release/1.2.0 + checkout dev + merge main + checkout release/1.2.0 + branch hotfix/1.2.1 order: 15 + branch bug/bug5 order: 16 + commit id:"fix(function): change1 bug5" + checkout hotfix/1.2.1 + branch bug/bug6 order: 17 + commit id:"fix(function): change bug6" + checkout hotfix/1.2.1 + merge bug/bug6 + checkout bug/bug5 + commit id:"fix(function): change2 bug5" + checkout hotfix/1.2.1 + merge bug/bug5 + commit id: "hotfix(1.2.1): update version, changelog..." tag: "1.2.1" + checkout main + merge hotfix/1.2.1 + checkout dev + merge main +``` + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/Dev-Process/Enumeration Handling.md b/docs/developer/Technical-Documentation/Dev-Process/Enumeration Handling.md new file mode 100644 index 0000000..e77f773 --- /dev/null +++ b/docs/developer/Technical-Documentation/Dev-Process/Enumeration Handling.md @@ -0,0 +1,40 @@ +## Enumeration + +Enum or enumeration are used for data type consisting of named values like elements, status workflow, types, etc., that represent integral constants. Enums are non-transactional (so called static data) which can only get changed in a new application version. Changes in the operation mode of an application are not allowed since this will result into possible system breaks. + +List of used enums in the policy hub application that are stored in the database + +- attribute_key_id +- policy_kinds +- policy_types +- use_cases + +### Add Enums + +New enums can get added easily be enhancing the enumeration table (via the seeding data). With the next deployment; the new enum is getting auto deployed to the respective env. +Since enums have an enhanced impact on the system functionality; it is mandatorily needed to test (FE wise) the impacted screens / flows before releasing new enums. It is likely that the enum has an enhanced impact on the user journey / flow and break the system if not well tested. + +### Change Enums + +Change of enums (labels) is possible but need to be done carefully and only if necessarily needed. +In the case a change is getting executed; the system configuration / appsettings / env. variables need to get checked to ensure that those don't refer to the enum which is getting changed/ updated. +Same applies to backend logic, since it might refer to the enum label and will automatically fail when an enum value is getting changed. + +### Delete Enums + +Deletion of enums have following impacts + +- Seeding data update needed (likely data need to get deleted / changed) +- Data inside the database in the different running environments need to get updated +- User flow process impacted +- Backend business logic impacted + +It is not recommended to delete enums; instead .......... to be updated; we need to define how enums can / should get changed if needed + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/Dev-Process/How-to-contribute.md b/docs/developer/Technical-Documentation/Dev-Process/How to contribute.md similarity index 87% rename from docs/developer/Technical-Documentation/Dev-Process/How-to-contribute.md rename to docs/developer/Technical-Documentation/Dev-Process/How to contribute.md index f069a52..ed4f051 100644 --- a/docs/developer/Technical-Documentation/Dev-Process/How-to-contribute.md +++ b/docs/developer/Technical-Documentation/Dev-Process/How to contribute.md @@ -1,6 +1,6 @@ # Contribution details -To contribute to the portal as part of the open source community, please read the details defined below. +To contribute to the policy hub as part of the open source community, please read the details defined below. Besides a generic "how to", some commit and pull request (PR) guidelines are defined to ensure readability and make newly created PRs easier to review. Additionally, changelogs can get validated as well as written with more ease. Moreover, similar patterns are in use across the contributor community. **Content**: @@ -100,4 +100,12 @@ The suggested naming convention is '{type}{(function)}: {short summary}' ### PR description Add details to the change, fix or feature in the PR description. -What was changed, why was it changed (e.g. which issue was fixed or which requirement was implemented), and how was it changed. \ No newline at end of file +What was changed, why was it changed (e.g. which issue was fixed or which requirement was implemented), and how was it changed. + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/architecture/Architecture Constraints.md b/docs/developer/Technical-Documentation/architecture/Architecture Constraints.md new file mode 100644 index 0000000..3d19338 --- /dev/null +++ b/docs/developer/Technical-Documentation/architecture/Architecture Constraints.md @@ -0,0 +1,30 @@ +# Architecture Constraints + +## General + +- This project is an readonly API project, there is no plan to implement an UI yet. + +- Run anywhere: can be deployed as a docker image, e. g. on Kubernetes (platform-independent, cloud, on prem or local). + +## Developer + +- OpenSource software first - FOSS licenses approved by the eclipse foundation has to be used. It could represent the initial set that the CX community agrees on to regulate the content contribution under FOSS licenses. + +- Coding guidelines for BE are defined and are to be followed for all policy hub related developments. + +- Apache License 2.0 - Apache License 2.0 is one of the approved licenses which should be used to respect and guarantee Intellectual property (IP). + +- Code Analysis, Linting and Code Coverage - Consistent style increases readability and maintainability of the code base. Hence, we use analyzers to enforce consistency and style rules. We enforce the code style and rules in the CI to avoid merging code that does not comply with standards. + +## Code analysis, linting and code coverage + +--comming soon--- +(Veracode; Eslinter, Sonarcloud, etc.) + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/architecture/Context and scope.md b/docs/developer/Technical-Documentation/architecture/Context and scope.md new file mode 100644 index 0000000..28b675c --- /dev/null +++ b/docs/developer/Technical-Documentation/architecture/Context and scope.md @@ -0,0 +1,17 @@ +# Content and Scope + +## Business Context + +TODO (PS): add description + +## Technical Context + +The policy hub comprise the technical foundation for interaction, monitoring, auditing and further functionalities. They are state of the art in terms of technology portfolio, consist of open-source components whenever possible and are open-sourced themselves 100%. + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/architecture/Development Concept.md b/docs/developer/Technical-Documentation/architecture/Development Concept.md new file mode 100644 index 0000000..e30eed4 --- /dev/null +++ b/docs/developer/Technical-Documentation/architecture/Development Concept.md @@ -0,0 +1,143 @@ +# Development Concept + +## Build, test, deploy + +Details to the build, test and deploy process can get found under the following md file: [Release Process](/docs/Release%20Process.md) + +## Development Guidelines + +The policy hub is using following key frameworks: + +- .Net +- Entity Framework + +### Swagger + +The API uses OpenAPI annotations to describe the endpoints with all necessary information. The annotations are then used to automatically generate the OpenAPI specification file, which can be viewed in the Swagger UI that is deployed with the application. + +#### API Dev Guidelines + +##### Implement authorization + +API's need to ensure that they only grant access to the authorized requester. For example, a user might be approved to access the API, but if they’re not allowed to add information to the application’s database via the POST method, any request to do so should be rejected. Authorization information can also be contained within a request as a token. + +Unlike some other API types, REST APIs must authenticate and authorize each request made to the server, even if multiple requests come from the same user. This is because REST communications are stateless — that is, each request can be understood by the API in isolation, without information from previous requests. + +Authorization can be governed by user roles, where each role comes with different permissions. Generally, API developers should adhere to the principle of least privilege, which states that users should only have access to the resources and methods necessary for their role, and nothing more. Predefined roles make it easier to oversee and change user permissions, reducing the chance that a bad actor can access sensitive data. + +In terms of implementation all endpoints should be secured with the highest restrictions as default. Restrictions should only be lessened through explicit exemptions. This ensures that in case of oversights an endpoint can be more secured than intended but never less secured. + +##### Validate all requests + +As mentioned, sometimes requests from perfectly valid sources may be hacking attempts. Therefore, APIs need rules to determine whether a request is friendly, friendly but invalid, or harmful, like an attempt to inject harmful code. + +An API request is only processed once its contents pass a thorough validation check — otherwise, the request should never reach the application data layer. + +Validation also includes sanity checks: Define sensible value ranges for the parameters a user provides. This especially is valid for the size of the request and the response. APIs should limit the possible number of records to process in order to prevent intentional or unintentional overloads of the system. + +##### Encrypt all requests and responses + +To prevent MITM attacks, any data transfer from the user to the API server or vice versa must be properly encrypted. This way, any intercepted requests or responses are useless to the intruder without the right decryption method. + +Since REST APIs use HTTP, encryption can be achieved by using the Transport Layer Security (TLS) protocol or Secure Sockets Layer (SSL) protocol. These protocols supply the S in “HTTPS” (“S” meaning “secure'') and are the standard for encrypting web pages and REST API communications. + +TLS/SSL only encrypts data when that data is being transferred. It doesn’t encrypt data sitting behind your API, which is why sensitive data should also be encrypted in the database layer as well. + +##### Only include necessary information in responses + +Like you might unintentionally let a secret slip when telling a story to a friend, it’s possible for an API response to expose information hackers can use. To prevent this, all responses sent to the end-user should include only the information to communicate the success or failure of the request, the resource requested (if any), and any other information directly related to these resources. + +In other words, avoid “oversharing” data — the response is a chance for you to inadvertently expose private data, either through the returned resources or verbose status messages. + +=> in the ownership of every API Developer + +##### Throttle API requests and establish quotas + +To prevent brute-force attacks like DDoS, an API can impose rate-limiting, a way to control the number of requests to the API server at any given time. + +There are two main ways to rate-limit API requests, quotas and throttling. Quotas limit the number of requests allowed from a user over a span of time, while throttling slows a user’s connection while still allowing them to use your API. + +Both methods should allow normal API requests but prevent floods of traffic intended to disrupt, as well as unexpected request spikes in general. + +##### Log API activity + +Logging API activities is extremely important when it comes to tracing user activity and in worst case hack activity. + +###### Conduct security tests + +=> see [Test Section](#tests) below + +##### Error Handling + +The simplest way we handle errors is to respond with an appropriate status code. + +Common agreed response codes: + +- 400 Bad Request – client sent an invalid request, such as lacking required request body or parameter. + Example: The same constraint has been configured multiple times in the request +- 401 Unauthorized – user authenticated but doesn't have permission to access the requested resource. + Example: User token doesn't have the access on the resource. +- 403 Forbidden – client failed to authenticate with the server. + Example: token expired oder invalid login. +- 404 Not Found – the requested resource does not exist. + Example: A specific policy was requested which does not exist in the database.. +- 500 Internal Server Error – a generic error occurred in the internal system logic. + Example: Unexpected server-side issue during policy validation. + Additionally to the generic error code, a detailed message/error is needed to ensure that the issue can get validated and resolved quickly. + +##### Repository Pattern + +The repositories are used via the Factory HubRepositories, which ensures that the same database instance is used for all repositories. + +Furthermore, it provides an implicit transaction functionality. + +The repositories themselves must not be registered for dependency injection in the corresponding startup; the method HubRepositories.GetInstance provides the instance of a requested repository. + +In the repository itself, you should not work with SaveChanges, it should only be called via the HubRepositories.SaveChanges to ensure that any transaction dependencies can be rolled back. + +#### Tests + +##### User Authentication Test + +If authentication mechanisms are implemented incorrectly, attackers can compromise authentication tokens or exploit implementation flaws to assume other users’ identities and gain access to your API’s endpoints. + +To test your authentication mechanisms, try sending API requests without proper authentication (either no tokens or credentials, or incorrect ones) and see if your API responds with the correct error and messaging. + +##### Parameter Tampering Test + +To run a parameter tampering test, try various combinations of invalid query parameters in your API requests and see if it responds with the correct error codes. If not, then your API likely has some backend validation errors that need to be resolved. + +##### Injection Test + +To test if your API is vulnerable to injections, try injecting SQL, NoSQL, LDAP, OS, or other commands in API inputs and see if your API executes them. These commands should be harmless, like reboot commands or cat commands. + +##### Unhandled HTTP Methods Test + +Most APIs have various HTTP methods that are used to retrieve, store, or delete data. Sometimes web servers will give access to unsupported HTTP methods by default, which makes your API vulnerable. + +To test for this vulnerability, you should try all the common HTTP methods (POST, GET, PUT, PATCH, and DELETE) as well as a few uncommon ones. TRY sending an API request with the HEAD verb instead of GET, for example, or a request with an arbitrary method like FOO. You should get an error code, but if you get a 200 OK response, then your API has a vulnerability. + +##### Load Test + +Load testing should be one of the last steps of your API security auditing process. This type is pushing the API to its limits in order to discover any functional or security issues that have yet to be revealed. + +To achieve this, send a large number of randomized requests, including SQL queries, system commands, arbitrary numbers, and other non-text characters, and see if your API responds with errors, processes any of these inputs incorrectly, or crashes. This type of testing will mimic Overflow and DDoS attacks. + +An API manager or gateway tool will handle or help address the API security guidelines described above (including testing). + +## Migration + +To run the policy hub, migrations are needed to load the initial data inside the policy hub db to enable the policy hub to work. +The migration will consist of an initial migration as well as delta migration files with future releases. As part of a new release, a migration file (if applicable) will get released and can get loaded via a delta load. + +## Configurability + +Policy Hub configuration is mainly possible via the appsettings files as well as the static data migration files. + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/architecture/Requirements.md b/docs/developer/Technical-Documentation/architecture/Requirements.md new file mode 100644 index 0000000..2918aa0 --- /dev/null +++ b/docs/developer/Technical-Documentation/architecture/Requirements.md @@ -0,0 +1,22 @@ +# Requirements overview + +## What is the Policy Hub Product? + +The Policy Hub is a central readonly API to receive information related policies of the Catena-X network. + +## Requirements + +For Catena-X Member Companies +|ID|Title|Requirement| +|--------|--------|--------| +|REQ-C-004|Identity Integration|Authentication is done vis IdP Federation to minimize administration overhead and to simplify logins. Authorization not included, this must be done Catena-X specific by the Central-IdP| + +TODO (PS): tbd with julia + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/architecture/Solution strategy.md b/docs/developer/Technical-Documentation/architecture/Solution strategy.md new file mode 100644 index 0000000..6893ebd --- /dev/null +++ b/docs/developer/Technical-Documentation/architecture/Solution strategy.md @@ -0,0 +1,14 @@ +# Solution Strategy + +- The technology portfolio and development stack are kept simple, based on commodity and oss components and products. +- APIs are always REST-based with token authentication. +- OIDC is used for authentication and authorization. +- IaC is fully realized via helm charts. + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/architecture/Whitebox Overall System.md b/docs/developer/Technical-Documentation/architecture/Whitebox Overall System.md new file mode 100644 index 0000000..43c2054 --- /dev/null +++ b/docs/developer/Technical-Documentation/architecture/Whitebox Overall System.md @@ -0,0 +1,15 @@ +# Whitebox Overall System + +## Summary + +In the following image you see the overall system overview of the Policy Hub + +TODO (PS): add image for system view + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/architecture/operational-concept.md b/docs/developer/Technical-Documentation/architecture/operational-concept.md new file mode 100644 index 0000000..485faae --- /dev/null +++ b/docs/developer/Technical-Documentation/architecture/operational-concept.md @@ -0,0 +1,47 @@ +# Operational concepts + +## Policy Hub Service + +### Configuration + +The Policy Hub can be configured using two methods: + +### appsettings.json + +If you build the Policy Hub, you can modify the appsettings.json for each backend service, to individually configure to a certain extend. This file contains all possible config entries for the application. + +### Helm Chart + +The most relevant config properties are exposed as environment variables and must be set in the Helm chart so the application can run at all. Check the Policy Hub Helm chart in Git for all available variables. + +### DB Migration File + +Static Data migration files provide a certain configuration possibility by adding or deleting static data records before the deployment. Be aware that touching static data files will always impact the application business process. It is suggested to always test the application with the planned changes carefully in INT before releasing to a productive env. + +## Disaster-Recovery + +Note: will be added soon + +## Scaling + +If the number of consumers raises, the IRS can be scaled up by using more resources for the Deployment Pod. Those resources can be used to utilize more parallel threads to handle Job execution. + +## Clustering + +Note: will be added soon + +## Monitoring + +Currently all backend services write log entries as structural data in json format. These logs can easily be monitored. There are several options to provide a stable monitoring solution, one of them is to setup loki and grafana. In this solution loki is used as a datasource and custom dashboards can be setup in grafana to monitor the services. Some general Properties to query with grafana are: + +- StatusCode - contains the status code of the response +- Elapsed - contains the time a endpoint took to response in milliseconds +- RenderedMessage - contains the log message with possible errors + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/authentication/authentication.md b/docs/developer/Technical-Documentation/authentication/authentication.md new file mode 100644 index 0000000..9ed3a9d --- /dev/null +++ b/docs/developer/Technical-Documentation/authentication/authentication.md @@ -0,0 +1,13 @@ +# Authentication + +The authentication process for the Policy Hub involves interaction with the central IAM (Identity and Access Management). The configuration for IAM can be customized either locally during development through secrets or within the chart for the Docker image. + +Currently, the Policy Hub performs a basic validation by checking for a valid token in the request. However, it's important to note that no permission checks are conducted at this stage. + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/database/db-view.md b/docs/developer/Technical-Documentation/database/db-view.md new file mode 100644 index 0000000..b96c247 --- /dev/null +++ b/docs/developer/Technical-Documentation/database/db-view.md @@ -0,0 +1,105 @@ + +# Database View + +- [Database View](#database-view) + - [Database Overview](#database-overview) + - [Database Structure](#database-structure) + - [Enum Value Tables](#enum-value-tables) + - [Mapping Tables](#mapping-tables) + - [Configuration Table](#configuration-table) + - [Attribute Mapping](#attribute-mapping) + - [Policy Information](#policy-information) + - [NOTICE](#notice) + +## Database Overview + +```mermaid +erDiagram + policies ||..|| policy_assigned_types : policy_id + policies ||..|| policy_assigned_use_case : policy_id + policies ||..|| policy_kinds : kind_id + policies ||..|| attribute_keys : attribute_key_id + policies ||..|| policy_attributes : policy_id + policy_attributes ||..|| attribute_keys : key + policies { + uuid id PK + integer kind_id FK + text left_operand_value + text technical_key + text description + boolean is_active + integer attribute_key FK + } + policy_assigned_types ||..|| policy_types : policy_type_id + policy_assigned_types { + uuid policy_id FK + integer policy_type_id FK + } + policy_types { + integer id PK + text label + bool is_active + } + policy_assigned_use_case ||..|| use_cases : use_case_id + policy_assigned_use_case { + uuid policy_id FK + integer use_case_id FK + } + use_cases{ + integer id PK + text label + bool is_active + } + policy_kinds ||..|| policy_kind_configuration : policy_kind_id + policy_kinds { + integer id PK + text label + boolean technical_enforced + } + policy_kind_configuration{ + integer policy_kind_id PK + text right_operand_value + } + attribute_keys { + uuid id PK + text label + } + policy_attributes{ + integer policy_id PK + integer key PK + text attribute_value PK + bool is_active + } +``` + +## Database Structure + +The database is organized into several key tables, each serving a specific purpose: + +### Enum Value Tables + +`attribute_keys`, `policy_kinds`, `policy_types`, and `use_cases` are tables designed to store enum values. They contain an id and label, derived from the backend enums. + +### Mapping Tables + +`policy_assigned_types` and `policy_assigned_use_cases` are used to map types and use cases to specific policies. + +### Configuration Table + +The `policy_kind_configurations` table is utilized to define specific right operand values for each policy_kind. + +### Attribute Mapping + +In the `policy_attributes` table, specific attributes are mapped to policies. This allows for multiple attributes to be assigned to a single policy. + +### Policy Information + +The `policies` table serves as the repository for comprehensive information about each policy. + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/docs/developer/Technical-Documentation/database/seeding.md b/docs/developer/Technical-Documentation/database/seeding.md new file mode 100644 index 0000000..ab92302 --- /dev/null +++ b/docs/developer/Technical-Documentation/database/seeding.md @@ -0,0 +1,44 @@ +# Seeding Mechanism + +## Database Seeding + +All data for the Policy Hub is stored in the database. Due to the absence of create or update logic in the API, a seeding process has been implemented to populate the database with initial data. + +## Execution + +The seeding process is triggered by the PolicyHub.migration job. During this process, data is sourced from .json files located in a configurable directory. The default directory for the base setup is Seeder -> Data. + +## Configuration + +To specify the data to be seeded, configure the `BatchInsertSeeder`. This configuration includes the following details: + +- Database Table: Identify the target database table +- File Name: Specify the name of the .json file containing the data +- Primary Keys: The primary keys which check for existing entries + +To specify the data which should be modified within the seeding, configure the `BatchUpdateSeeder`. This configuration includes the following details: + +- Database Table: Identify the target database table +- File Name: Specify the name of the .json file containing the data +- Primary Keys: The primary keys which check for existing entries +- Where Clause: Check for the entries in the table that should be modified +- Update Entries: The function that should be executed to modify the entries. + +Currently the update seeder will only modify the is_active flag. + +## Data Integrity + +The seeder includes a check to ensure that only data not yet existing in the database is written. This prevents duplication of records. + +## Limitations + +- While the seeder is designed to add new data, it does not support deletion. Any existing records in the database will not be removed by the seeding process. +- Modifications of the enum values, currently `AttributeKeyId`, `ConstraintOperandId`, `OperatorId`, `PolicyKindId`, `PolicyTypeId` and `UseCaseId` must be made with a migration. + +## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub diff --git a/scripts/add_notice_footer.sh b/scripts/add_notice_footer.sh new file mode 100644 index 0000000..c7b8cc7 --- /dev/null +++ b/scripts/add_notice_footer.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +############################################################### +# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +############################################################### + +print-usage() { + cat << EOF +# +# Add license notice to all md files +# +# usage: +# source ./scripts/add_notice_footer.sh +# cd path/to/your/documentation +# add-notice +# +EOF +} + +add-notice() { + notice_text='''## NOTICE + +This work is licensed under the [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0). + +- SPDX-License-Identifier: Apache-2.0 +- SPDX-FileCopyrightText: 2021-2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub''' + + # Find all .md files in the directory and its subdirectories, excluding directories from the search + find . -type f -name "*.md" -print0 | while IFS= read -r -d '' file; do + last_line=$(tail -n 7 "$file") + + # Check if the last line of the file matches the notice text + if [ "$last_line" != "$notice_text" ]; then + # Append the notice text if it's not already there + echo -e "\n$notice_text" >> "$file" + echo "Notice added to $file" + fi + done +} + +print-usage \ No newline at end of file diff --git a/scripts/license.sh b/scripts/license.sh new file mode 100644 index 0000000..98b9401 --- /dev/null +++ b/scripts/license.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +############################################################### +# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +############################################################### + +print-usage() { + cat << EOF +# +# Generate license files for all images in folder and subfolders +# +# usage: +# source ./scripts/license.sh +# cd path/to/your/images +# license-images +# +EOF +} + +license-images() { + for file in $(find . -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.svg' \)); + do + echo $file + cat << EOF > $file.license +This work is licensed under the [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode). + +- SPDX-License-Identifier: CC-BY-4.0 +- SPDX-FileCopyrightText: Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation +- Source URL: https://github.com/eclipse-tractusx/policy-hub + +EOF + done +} + +print-usage diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..085dfae --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,25 @@ + + + + + 1.0.0 + + + diff --git a/src/database/PolicyHub.Migrations/Migrations/20231024084527_CPLP-3330-Initial.cs b/src/database/PolicyHub.Migrations/Migrations/20231024084527_CPLP-3330-Initial.cs index d63672c..20c9bd3 100644 --- a/src/database/PolicyHub.Migrations/Migrations/20231024084527_CPLP-3330-Initial.cs +++ b/src/database/PolicyHub.Migrations/Migrations/20231024084527_CPLP-3330-Initial.cs @@ -18,7 +18,6 @@ ********************************************************************************/ using Microsoft.EntityFrameworkCore.Migrations; -using System; #nullable disable diff --git a/src/database/PolicyHub.Migrations/Seeder/BatchInsertSeeder.cs b/src/database/PolicyHub.Migrations/Seeder/BatchInsertSeeder.cs index cbae684..4d8b968 100644 --- a/src/database/PolicyHub.Migrations/Seeder/BatchInsertSeeder.cs +++ b/src/database/PolicyHub.Migrations/Seeder/BatchInsertSeeder.cs @@ -26,7 +26,7 @@ namespace Org.Eclipse.TractusX.PolicyHub.Migrations.Seeder; /// -/// Seeder to seed the base entities (those with an id as primary key) +/// Seeder to seed the all configured entities /// public class BatchInsertSeeder : ICustomSeeder { diff --git a/src/database/PolicyHub.Migrations/Seeder/BatchUpdateSeeder.cs b/src/database/PolicyHub.Migrations/Seeder/BatchUpdateSeeder.cs new file mode 100644 index 0000000..d3b4ab7 --- /dev/null +++ b/src/database/PolicyHub.Migrations/Seeder/BatchUpdateSeeder.cs @@ -0,0 +1,90 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Org.Eclipse.TractusX.PolicyHub.Entities; +using Org.Eclipse.TractusX.PolicyHub.Entities.Entities; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Seeding; + +namespace Org.Eclipse.TractusX.PolicyHub.Migrations.Seeder; + +/// +/// Seeder to modify the is_active flag of the configured entities +/// +public class BatchUpdateSeeder : ICustomSeeder +{ + private readonly PolicyHubContext _context; + private readonly ILogger _logger; + private readonly SeederSettings _settings; + + /// + /// Constructor + /// + /// The database context + /// The logger + /// The options + public BatchUpdateSeeder(PolicyHubContext context, ILogger logger, IOptions options) + { + _context = context; + _logger = logger; + _settings = options.Value; + } + + /// + public int Order => 2; + + /// + public async Task ExecuteAsync(CancellationToken cancellationToken) + { + if (!_settings.DataPaths.Any()) + { + _logger.LogInformation("There a no data paths configured, therefore the {SeederName} will be skipped", nameof(BatchUpdateSeeder)); + return; + } + + _logger.LogInformation("Start BaseEntityBatch Seeder"); + await SeedTable( + "policies", + x => new { x.Id }, + x => x.dbEntity.IsActive != x.dataEntity.IsActive, + (dbEntity, entity) => + { + dbEntity.IsActive = entity.IsActive; + }, cancellationToken).ConfigureAwait(false); + + await SeedTable( + "policy_attributes", + x => new { x.PolicyId, x.Key, x.AttributeValue }, + x => x.dbEntity.IsActive != x.dataEntity.IsActive, + (dbEntry, entry) => + { + dbEntry.IsActive = entry.IsActive; + }, cancellationToken).ConfigureAwait(false); + + await _context.SaveChangesAsync(cancellationToken).ConfigureAwait(false); + _logger.LogInformation("Finished BaseEntityBatch Seeder"); + } + + private async Task SeedTable(string fileName, Func keySelector, Func<(T dataEntity, T dbEntity), bool> whereClause, Action updateEntries, CancellationToken cancellationToken) where T : class + { + _logger.LogInformation("Start seeding {Filename}", fileName); + var additionalEnvironments = _settings.TestDataEnvironments ?? Enumerable.Empty(); + var data = await SeederHelper.GetSeedData(_logger, fileName, _settings.DataPaths, cancellationToken, additionalEnvironments.ToArray()).ConfigureAwait(false); + _logger.LogInformation("Found {ElementCount} data", data.Count); + if (data.Any()) + { + var typeName = typeof(T).Name; + var entriesForUpdate = data + .Join(_context.Set(), keySelector, keySelector, (dataEntry, dbEntry) => (DataEntry: dataEntry, DbEntry: dbEntry)) + .Where(whereClause.Invoke) + .ToList(); + if (entriesForUpdate.Any()) + { + _logger.LogInformation("Started to Update {EntryCount} entries of {TableName}", entriesForUpdate.Count, typeName); + foreach (var entry in entriesForUpdate) + { + updateEntries.Invoke(entry.DbEntry, entry.DataEntry); + } + _logger.LogInformation("Updated {TableName}", typeName); + } + } + } +} diff --git a/src/hub/PolicyHub.Service/BusinessLogic/IPolicyHubBusinessLogic.cs b/src/hub/PolicyHub.Service/BusinessLogic/IPolicyHubBusinessLogic.cs index b25f4fd..0318b24 100644 --- a/src/hub/PolicyHub.Service/BusinessLogic/IPolicyHubBusinessLogic.cs +++ b/src/hub/PolicyHub.Service/BusinessLogic/IPolicyHubBusinessLogic.cs @@ -28,6 +28,6 @@ public interface IPolicyHubBusinessLogic : ITransient { IAsyncEnumerable GetAttributeKeys(); IAsyncEnumerable GetPolicyTypes(PolicyTypeId? type, UseCaseId? useCase); - Task GetPolicyContentAsync(UseCaseId? useCase, PolicyTypeId type, string credential, OperatorId operatorId, string? value); + Task GetPolicyContentWithFiltersAsync(UseCaseId? useCase, PolicyTypeId type, string credential, OperatorId operatorId, string? value); Task GetPolicyContentAsync(PolicyContentRequest requestData); } diff --git a/src/hub/PolicyHub.Service/BusinessLogic/PolicyHubBusinessLogic.cs b/src/hub/PolicyHub.Service/BusinessLogic/PolicyHubBusinessLogic.cs index 1bb3456..e07e3e1 100644 --- a/src/hub/PolicyHub.Service/BusinessLogic/PolicyHubBusinessLogic.cs +++ b/src/hub/PolicyHub.Service/BusinessLogic/PolicyHubBusinessLogic.cs @@ -43,7 +43,7 @@ public IAsyncEnumerable GetAttributeKeys() => public IAsyncEnumerable GetPolicyTypes(PolicyTypeId? type, UseCaseId? useCase) => _hubRepositories.GetInstance().GetPolicyTypes(type, useCase); - public async Task GetPolicyContentAsync(UseCaseId? useCase, PolicyTypeId type, string credential, OperatorId operatorId, string? value) + public async Task GetPolicyContentWithFiltersAsync(UseCaseId? useCase, PolicyTypeId type, string credential, OperatorId operatorId, string? value) { var (exists, leftOperand, attributes, rightOperandValue) = await _hubRepositories.GetInstance().GetPolicyContentAsync(useCase, type, credential).ConfigureAwait(false); if (!exists) diff --git a/src/hub/PolicyHub.Service/Controllers/PolicyHubController.cs b/src/hub/PolicyHub.Service/Controllers/PolicyHubController.cs index f03a886..122570a 100644 --- a/src/hub/PolicyHub.Service/Controllers/PolicyHubController.cs +++ b/src/hub/PolicyHub.Service/Controllers/PolicyHubController.cs @@ -34,18 +34,18 @@ public static class PolicyHubController { public static RouteGroupBuilder MapPolicyHubApi(this RouteGroupBuilder group) { - var policyHub = group.MapGroup("/policyHub"); + var policyHub = group.MapGroup("/policy-hub"); policyHub.MapGet("policy-attributes", (IPolicyHubBusinessLogic logic) => logic.GetAttributeKeys()) .WithSwaggerDescription("Gets the keys for the attributes", - "Example: GET: api/policyhub/policy-attributes") + "Example: GET: api/policy-hub/policy-attributes") // .RequireAuthorization() .WithDefaultResponses() .Produces(StatusCodes.Status200OK, typeof(string), Constants.JsonContentType); policyHub.MapGet("policy-types", (PolicyTypeId? type, UseCaseId? useCase, IPolicyHubBusinessLogic logic) => logic.GetPolicyTypes(type, useCase)) .WithSwaggerDescription("Gets the policy types", - "Example: GET: api/policyhub/policy-types", + "Example: GET: api/policy-hub/policy-types", "OPTIONAL: Type to filter the response", "OPTIONAL: UseCase to filter the response") // .RequireAuthorization() @@ -58,9 +58,9 @@ public static RouteGroupBuilder MapPolicyHubApi(this RouteGroupBuilder group) string credential, OperatorId operatorId, string? value, - IPolicyHubBusinessLogic logic) => logic.GetPolicyContentAsync(useCase, type, credential, operatorId, value)) + IPolicyHubBusinessLogic logic) => logic.GetPolicyContentWithFiltersAsync(useCase, type, credential, operatorId, value)) .WithSwaggerDescription("Gets the content for a specific policy type", - "Example: GET: api/policyhub/policy-content", + "Example: GET: api/policy-hub/policy-content", "OPTIONAL: The use case", "Type of the policy to get the content for", "The technical key of the policy", @@ -73,7 +73,7 @@ public static RouteGroupBuilder MapPolicyHubApi(this RouteGroupBuilder group) policyHub.MapPost("policy-content", ([FromBody] PolicyContentRequest requestData, IPolicyHubBusinessLogic logic) => logic.GetPolicyContentAsync(requestData)) .WithSwaggerDescription("Gets the content for a specific policy type", - "Example: POST: api/policyhub/policy-content", + "Example: POST: api/policy-hub/policy-content", "Request data with the configuration of the constraints") // .RequireAuthorization() .WithDefaultResponses() diff --git a/src/hub/PolicyHub.Service/Extensions/StartupServiceExtensions.cs b/src/hub/PolicyHub.Service/Extensions/StartupServiceExtensions.cs deleted file mode 100644 index 0310b59..0000000 --- a/src/hub/PolicyHub.Service/Extensions/StartupServiceExtensions.cs +++ /dev/null @@ -1,88 +0,0 @@ -// /******************************************************************************** -// * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation -// * -// * See the NOTICE file(s) distributed with this work for additional -// * information regarding copyright ownership. -// * -// * This program and the accompanying materials are made available under the -// * terms of the Apache License, Version 2.0 which is available at -// * https://www.apache.org/licenses/LICENSE-2.0. -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// * License for the specific language governing permissions and limitations -// * under the License. -// * -// * SPDX-License-Identifier: Apache-2.0 -// ********************************************************************************/ -// -// using Framework.Swagger; -// using Microsoft.AspNetCore.Authentication; -// using Microsoft.AspNetCore.Authentication.JwtBearer; -// using Microsoft.AspNetCore.Http.Json; -// using Org.Eclipse.TractusX.PolicyHub.DbAccess.DependencyInjection; -// using Org.Eclipse.TractusX.PolicyHub.Service.Authentication; -// using Org.Eclipse.TractusX.PolicyHub.Service.HealthCheck; -// using Org.Eclipse.TractusX.Portal.Backend.Framework.DependencyInjection; -// using System.IdentityModel.Tokens.Jwt; -// using System.Text.Json.Serialization; -// -// namespace Org.Eclipse.TractusX.PolicyHub.Service.Extensions; -// -// public static class StartupServiceExtensions -// { -// public static IServiceCollection AddDefaultServices(this IServiceCollection services, IConfigurationRoot configuration, string version) -// { -// services.AddCors(options => options.SetupCors(configuration)); -// -// services.AddDistributedMemoryCache(); -// services.AddSession(options => -// { -// options.Cookie.Name = ".Portal"; -// options.IdleTimeout = TimeSpan.FromMinutes(10); -// }); -// -// services.Configure(options => -// { -// options.SerializerOptions.Converters.Add(new JsonStringEnumConverter(allowIntegerValues: false)); -// }); -// -// services.AddControllers(); -// -// services.AddEndpointsApiExplorer(); -// services.AddSwaggerGen(c => SwaggerGenConfiguration.SetupSwaggerGen(c, version)); -// -// services.AddAuthentication(x => -// { -// x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; -// x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; -// }).AddJwtBearer(options => -// { -// configuration.Bind("JwtBearerOptions", options); -// if (!options.RequireHttpsMetadata) -// { -// options.BackchannelHttpHandler = new HttpClientHandler -// { -// ServerCertificateCustomValidationCallback = (_, _, _, _) => true -// }; -// } -// }); -// -// JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); -// -// services.AddTransient() -// .AddOptions() -// .Bind(configuration.GetSection("JwtBearerOptions")) -// .ValidateOnStart(); -// -// services.AddHealthChecks() -// .AddCheck("JwtBearerConfiguration", tags: new[] { "keycloak" }); -// -// services.AddHttpContextAccessor(); -// -// services.AddHubRepositories(configuration); -// services.AutoRegister(); -// return services; -// } -// } diff --git a/src/hub/PolicyHub.Service/Extensions/StartupServiceWebApplicationExtensions.cs b/src/hub/PolicyHub.Service/Extensions/StartupServiceWebApplicationExtensions.cs deleted file mode 100644 index 972ac34..0000000 --- a/src/hub/PolicyHub.Service/Extensions/StartupServiceWebApplicationExtensions.cs +++ /dev/null @@ -1,71 +0,0 @@ -// /******************************************************************************** -// * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation -// * -// * See the NOTICE file(s) distributed with this work for additional -// * information regarding copyright ownership. -// * -// * This program and the accompanying materials are made available under the -// * terms of the Apache License, Version 2.0 which is available at -// * https://www.apache.org/licenses/LICENSE-2.0. -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// * License for the specific language governing permissions and limitations -// * under the License. -// * -// * SPDX-License-Identifier: Apache-2.0 -// ********************************************************************************/ -// -// using Org.Eclipse.TractusX.PolicyHub.Service.HealthCheck; -// using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Web; -// using Serilog; -// -// namespace Org.Eclipse.TractusX.PolicyHub.Service.Extensions; -// -// public static class StartupServiceWebApplicationExtensions -// { -// public static WebApplication CreateApp(this WebApplication app, string apiPath, string version, IHostEnvironment environment) -// { -// app.UseSerilogRequestLogging(); -// -// if (environment.IsDevelopment()) -// { -// app.UseDeveloperExceptionPage(); -// } -// -// var assemblyName = typeof(TProgram).Assembly.FullName?.Split(',')[0]; -// -// if (app.Configuration.GetValue("SwaggerEnabled") != null && -// app.Configuration.GetValue("SwaggerEnabled")) -// { -// app.UseSwagger(c => -// c.RouteTemplate = $"/api/{apiPath}/swagger/{{documentName}}/swagger.{{json|yaml}}"); -// app.UseSwaggerUI(c => -// { -// c.SwaggerEndpoint($"/api/{apiPath}/swagger/{version}/swagger.json", -// $"{assemblyName} {version}"); -// c.RoutePrefix = $"api/{apiPath}/swagger"; -// }); -// } -// -// app.UseRouting(); -// -// app.UseSession(); -// -// app.UseCors(CorsExtensions.AllowSpecificOrigins); -// -// app.UseMiddleware(); -// app.UseAuthentication(); -// app.UseAuthorization(); -// -// app.MapControllers(); -// var healthCheckSettings = app.Configuration.GetSection("HealthChecks").Get>(); -// if (healthCheckSettings != null) -// { -// app.MapDefaultHealthChecks(healthCheckSettings); -// } -// -// return app; -// } -// } diff --git a/src/hub/PolicyHub.Service/Extensions/WebApplicationBuildRunner.cs b/src/hub/PolicyHub.Service/Extensions/WebApplicationBuildRunner.cs deleted file mode 100644 index 3c59b15..0000000 --- a/src/hub/PolicyHub.Service/Extensions/WebApplicationBuildRunner.cs +++ /dev/null @@ -1,72 +0,0 @@ -// /******************************************************************************** -// * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation -// * -// * See the NOTICE file(s) distributed with this work for additional -// * information regarding copyright ownership. -// * -// * This program and the accompanying materials are made available under the -// * terms of the Apache License, Version 2.0 which is available at -// * https://www.apache.org/licenses/LICENSE-2.0. -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// * License for the specific language governing permissions and limitations -// * under the License. -// * -// * SPDX-License-Identifier: Apache-2.0 -// ********************************************************************************/ -// -// using Flurl.Util; -// using Org.Eclipse.TractusX.PolicyHub.Service.HealthCheck; -// using Org.Eclipse.TractusX.Portal.Backend.Framework.Logging; -// using Serilog; -// -// namespace Org.Eclipse.TractusX.PolicyHub.Service.Extensions; -// -// public static class WebApplicationBuildRunner -// { -// public static void BuildAndRunWebApplication( -// string[] args, -// string path, -// string version, -// Action? configureBuilder, -// Action? configureApp) -// { -// LoggingExtensions.EnsureInitialized(); -// Log.Information("Starting the application"); -// try -// { -// var builder = WebApplication.CreateBuilder(args); -// builder.Host.AddLogging((configuration, config) => -// { -// configuration.Enrich.WithCorrelationIdHeader("X-Request-Id"); -// var healthCheckPaths = config.GetSection("HealthChecks").Get>()?.Select(x => x.Path); -// if (healthCheckPaths != null) -// { -// configuration -// .Filter.ByExcluding(le => -// { -// return le.Properties.TryGetValue("RequestPath", out var logProperty) && -// logProperty.ToKeyValuePairs().Any(x => healthCheckPaths.Contains(x.Value)); -// }); -// } -// }); -// builder.Services.AddDefaultServices(builder.Configuration, version); -// configureBuilder?.Invoke(builder); -// -// var app = builder.Build().CreateApp(path, version, builder.Environment); -// configureApp?.Invoke(app); -// app.Run(); -// } -// catch (Exception ex) when (!ex.GetType().Name.Equals("StopTheHostException", StringComparison.Ordinal)) -// { -// Log.Fatal("Unhandled exception {Exception}", ex); -// } -// finally -// { -// Log.Information("Server Shutting down"); -// Log.CloseAndFlush(); -// } -// } -// } diff --git a/src/hub/PolicyHub.Service/Program.cs b/src/hub/PolicyHub.Service/Program.cs index 313c360..ef8bc23 100644 --- a/src/hub/PolicyHub.Service/Program.cs +++ b/src/hub/PolicyHub.Service/Program.cs @@ -26,7 +26,7 @@ const string Version = "v2"; WebApplicationBuildRunner - .BuildAndRunWebApplication(args, "policyHub", Version, ".Hub", + .BuildAndRunWebApplication(args, "policy-hub", Version, ".Hub", builder => { builder.Services.AddEndpointsApiExplorer(); diff --git a/src/hub/PolicyHub.Service/Properties/launchSettings.json b/src/hub/PolicyHub.Service/Properties/launchSettings.json index d636d08..532c085 100644 --- a/src/hub/PolicyHub.Service/Properties/launchSettings.json +++ b/src/hub/PolicyHub.Service/Properties/launchSettings.json @@ -21,11 +21,11 @@ "PolicyHub.Service": { "commandName": "Project", "launchBrowser": false, - "launchUrl": "api/hub/swagger", + "launchUrl": "api/policy-hub/swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "Cors__AllowedOrigins__0": "http://localhost:3000", - "Cors__AllowedOrigins__1": "https://portal.example.org" + "Cors__AllowedOrigins__1": "https://policy-hub.example.org" }, "applicationUrl": "https://localhost:5001;http://localhost:5000" }, diff --git a/tests/database/PolicyHub.DbAccess.Tests/PolicyRepositoryTests.cs b/tests/database/PolicyHub.DbAccess.Tests/PolicyRepositoryTests.cs index 9a119a0..955f3b0 100644 --- a/tests/database/PolicyHub.DbAccess.Tests/PolicyRepositoryTests.cs +++ b/tests/database/PolicyHub.DbAccess.Tests/PolicyRepositoryTests.cs @@ -75,16 +75,17 @@ public async Task GetPolicyTypes_ReturnsExpectedResult() var result = await sut.GetPolicyTypes(null, null).ToListAsync().ConfigureAwait(false); // Assert - result.Should().NotBeEmpty().And.HaveCount(9).And.Satisfy( - x => x.TechnicalKey == "BusinessPartnerNumber" && x.Name == PolicyKindId.BusinessPartnerNumber, - x => x.TechnicalKey == "Membership" && x.Name == PolicyKindId.Membership, - x => x.TechnicalKey == "FrameworkAgreement.traceability" && x.Name == PolicyKindId.Framework, - x => x.TechnicalKey == "FrameworkAgreement.quality" && x.Name == PolicyKindId.Framework, - x => x.TechnicalKey == "FrameworkAgreement.pcf" && x.Name == PolicyKindId.Framework, - x => x.TechnicalKey == "FrameworkAgreement.behavioraltwin" && x.Name == PolicyKindId.Framework, - x => x.TechnicalKey == "purpose" && x.Name == PolicyKindId.Purpose, - x => x.TechnicalKey == "purpose" && x.Name == PolicyKindId.Purpose, - x => x.TechnicalKey == "companyRole.dismantler" && x.Name == PolicyKindId.Dismantler + result.Should().NotBeEmpty().And.HaveCount(10).And.Satisfy( + x => x.TechnicalKey == "BusinessPartnerNumber", + x => x.TechnicalKey == "Membership", + x => x.TechnicalKey == "FrameworkAgreement.traceability", + x => x.TechnicalKey == "FrameworkAgreement.quality", + x => x.TechnicalKey == "FrameworkAgreement.pcf", + x => x.TechnicalKey == "FrameworkAgreement.behavioraltwin", + x => x.TechnicalKey == "purpose.trace.v1.TraceBattery", + x => x.TechnicalKey == "purpose.trace.v1.aspects", + x => x.TechnicalKey == "companyRole.dismantler", + x => x.TechnicalKey == "purpose.trace.v1.qualityanalysis" ); } @@ -115,10 +116,9 @@ public async Task GetPolicyTypes_WithUseCase_ReturnsExpectedResult() var result = await sut.GetPolicyTypes(null, UseCaseId.Sustainability).ToListAsync().ConfigureAwait(false); // Assert - result.Should().NotBeEmpty().And.HaveCount(4).And.Satisfy( + result.Should().NotBeEmpty().And.HaveCount(3).And.Satisfy( x => x.TechnicalKey == "BusinessPartnerNumber" && x.Attribute.Count() == 1 && x.Type.Count() == 2 && x.UseCase.Count() == 5, x => x.TechnicalKey == "Membership" && x.Attribute.Count() == 1 && x.Type.Count() == 2 && x.UseCase.Count() == 5, - x => x.TechnicalKey == "purpose" && x.Attribute.Count() == 1 && x.Type.Count() == 1 && x.UseCase.Count() == 5, x => x.TechnicalKey == "companyRole.dismantler" && x.Attribute.Count() == 3 && x.Type.Count() == 2 && x.UseCase.Count() == 5 ); } @@ -129,7 +129,7 @@ public async Task GetPolicyTypes_WithUseCase_ReturnsExpectedResult() private async Task CreateSut() { - var context = await _dbTestDbFixture.GetPortalDbContext().ConfigureAwait(false); + var context = await _dbTestDbFixture.GetPolicyHubDbContext().ConfigureAwait(false); var sut = new PolicyRepository(context); return sut; } diff --git a/tests/database/PolicyHub.DbAccess.Tests/Setup/TestDbFixture.cs b/tests/database/PolicyHub.DbAccess.Tests/Setup/TestDbFixture.cs index 9ad53b7..0d9bdb0 100644 --- a/tests/database/PolicyHub.DbAccess.Tests/Setup/TestDbFixture.cs +++ b/tests/database/PolicyHub.DbAccess.Tests/Setup/TestDbFixture.cs @@ -39,14 +39,14 @@ public class TestDbFixture : IAsyncLifetime .Build(); /// - /// Foreach test a new portalDbContext will be created and filled with the custom seeding data. + /// Foreach test a new policyHubContext will be created and filled with the custom seeding data. /// /// /// In this method the migrations don't need to get executed since they are already on the testcontainer. /// Because of that the EnsureCreatedAsync is enough. /// - /// Returns the created PortalDbContext - public async Task GetPortalDbContext() + /// Returns the created PolicyHubContext + public async Task GetPolicyHubDbContext() { var optionsBuilder = new DbContextOptionsBuilder(); diff --git a/tests/database/PolicyHub.DbAccess.Tests/Usings.cs b/tests/database/PolicyHub.DbAccess.Tests/Usings.cs index 65016ae..5f8f40c 100644 --- a/tests/database/PolicyHub.DbAccess.Tests/Usings.cs +++ b/tests/database/PolicyHub.DbAccess.Tests/Usings.cs @@ -19,6 +19,5 @@ global using AutoFixture; global using AutoFixture.AutoFakeItEasy; -global using FakeItEasy; global using FluentAssertions; global using Xunit; diff --git a/tests/hub/PolicyHub.Service.Tests/BusinessLogic/PolicyHubBusinessLogicTests.cs b/tests/hub/PolicyHub.Service.Tests/BusinessLogic/PolicyHubBusinessLogicTests.cs index 7797508..6877145 100644 --- a/tests/hub/PolicyHub.Service.Tests/BusinessLogic/PolicyHubBusinessLogicTests.cs +++ b/tests/hub/PolicyHub.Service.Tests/BusinessLogic/PolicyHubBusinessLogicTests.cs @@ -23,7 +23,6 @@ using Org.Eclipse.TractusX.PolicyHub.Entities.Enums; using Org.Eclipse.TractusX.PolicyHub.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library; -using System.Text.Json; namespace Org.Eclipse.TractusX.PolicyHub.Service.Tests.BusinessLogic; @@ -118,7 +117,7 @@ public async Task GetPolicyContentAsync_WithNotExistingInDatabase_ThrowsNotFound const PolicyTypeId policyTypeId = PolicyTypeId.Access; A.CallTo(() => _policyRepository.GetPolicyContentAsync(null, policyTypeId, "membership")) .Returns(new ValueTuple), string?>(false, null!, default, null!)); - async Task Act() => await _sut.GetPolicyContentAsync(null, policyTypeId, "membership", OperatorId.Equals, null); + async Task Act() => await _sut.GetPolicyContentWithFiltersAsync(null, policyTypeId, "membership", OperatorId.Equals, null); // Act var ex = await Assert.ThrowsAsync(Act); diff --git a/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs b/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs index c1b9470..5f08075 100644 --- a/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs +++ b/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs @@ -2,18 +2,17 @@ using Org.Eclipse.TractusX.PolicyHub.Entities.Enums; using Org.Eclipse.TractusX.PolicyHub.Service.Models; using Org.Eclipse.TractusX.PolicyHub.Service.Tests.Setup; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling.Library; using System.Net; using System.Net.Http.Json; -using System.Reflection; using System.Text.Json; +using System.Text.Json.Serialization; namespace Org.Eclipse.TractusX.PolicyHub.Service.Tests.Controllers; public class PolicyHubControllerTests : IClassFixture { - private static readonly JsonSerializerOptions Options = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; - private const string BaseUrl = "/api/policyHub"; + private static readonly JsonSerializerOptions Options = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, Converters = { new JsonStringEnumConverter() } }; + private const string BaseUrl = "/api/policy-hub"; private readonly HttpClient _client; public PolicyHubControllerTests(IntegrationTestFactory factory) @@ -47,20 +46,21 @@ public async Task GetAttributes() public async Task GetPolicyTypes_WithoutFilter_ReturnsExpected() { // Act - var policies = await _client.GetFromJsonAsync>($"{BaseUrl}/policy-types").ConfigureAwait(false); + var policies = await _client.GetFromJsonAsync>($"{BaseUrl}/policy-types", Options).ConfigureAwait(false); // Assert policies.Should().NotBeNull() - .And.HaveCount(9).And.Satisfy( - x => x.TechnicalKey == "BusinessPartnerNumber" && x.Name == PolicyKindId.BusinessPartnerNumber, - x => x.TechnicalKey == "Membership" && x.Name == PolicyKindId.Membership, - x => x.TechnicalKey == "FrameworkAgreement.traceability" && x.Name == PolicyKindId.Framework, - x => x.TechnicalKey == "FrameworkAgreement.quality" && x.Name == PolicyKindId.Framework, - x => x.TechnicalKey == "FrameworkAgreement.pcf" && x.Name == PolicyKindId.Framework, - x => x.TechnicalKey == "FrameworkAgreement.behavioraltwin" && x.Name == PolicyKindId.Framework, - x => x.TechnicalKey == "purpose" && x.Name == PolicyKindId.Purpose, - x => x.TechnicalKey == "purpose" && x.Name == PolicyKindId.Purpose, - x => x.TechnicalKey == "companyRole.dismantler" && x.Name == PolicyKindId.Dismantler + .And.HaveCount(10).And.Satisfy( + x => x.TechnicalKey == "BusinessPartnerNumber", + x => x.TechnicalKey == "Membership", + x => x.TechnicalKey == "FrameworkAgreement.traceability", + x => x.TechnicalKey == "FrameworkAgreement.quality", + x => x.TechnicalKey == "FrameworkAgreement.pcf", + x => x.TechnicalKey == "FrameworkAgreement.behavioraltwin", + x => x.TechnicalKey == "purpose.trace.v1.TraceBattery", + x => x.TechnicalKey == "purpose.trace.v1.aspects", + x => x.TechnicalKey == "companyRole.dismantler", + x => x.TechnicalKey == "purpose.trace.v1.qualityanalysis" ); } @@ -68,14 +68,14 @@ public async Task GetPolicyTypes_WithoutFilter_ReturnsExpected() public async Task GetPolicyTypes_WithTypeFilter_ReturnsExpected() { // Act - var policies = await _client.GetFromJsonAsync>($"{BaseUrl}/policy-types?type={PolicyTypeId.Access}").ConfigureAwait(false); + var policies = await _client.GetFromJsonAsync>($"{BaseUrl}/policy-types?type={PolicyTypeId.Access.ToString()}", Options).ConfigureAwait(false); // Assert policies.Should().NotBeNull() .And.HaveCount(3).And.Satisfy( - x => x.TechnicalKey == "BusinessPartnerNumber" && x.Name == PolicyKindId.BusinessPartnerNumber, - x => x.TechnicalKey == "Membership" && x.Name == PolicyKindId.Membership, - x => x.TechnicalKey == "companyRole.dismantler" && x.Name == PolicyKindId.Dismantler + x => x.TechnicalKey == "BusinessPartnerNumber", + x => x.TechnicalKey == "Membership", + x => x.TechnicalKey == "companyRole.dismantler" ); } @@ -83,17 +83,18 @@ public async Task GetPolicyTypes_WithTypeFilter_ReturnsExpected() public async Task GetPolicyTypes_WithUseCaseFilter_ReturnsExpected() { // Act - var policies = await _client.GetFromJsonAsync>($"{BaseUrl}/policy-types?useCase={UseCaseId.Traceability}").ConfigureAwait(false); + var policies = await _client.GetFromJsonAsync>($"{BaseUrl}/policy-types?useCase={UseCaseId.Traceability.ToString()}", Options).ConfigureAwait(false); // Assert policies.Should().NotBeNull() - .And.HaveCount(6).And.Satisfy( - x => x.TechnicalKey == "BusinessPartnerNumber" && x.Name == PolicyKindId.BusinessPartnerNumber, - x => x.TechnicalKey == "Membership" && x.Name == PolicyKindId.Membership, - x => x.TechnicalKey == "FrameworkAgreement.traceability" && x.Name == PolicyKindId.Framework, - x => x.TechnicalKey == "purpose" && x.Name == PolicyKindId.Purpose, - x => x.TechnicalKey == "purpose" && x.Name == PolicyKindId.Purpose, - x => x.TechnicalKey == "companyRole.dismantler" && x.Name == PolicyKindId.Dismantler + .And.HaveCount(7).And.Satisfy( + x => x.TechnicalKey == "BusinessPartnerNumber", + x => x.TechnicalKey == "Membership", + x => x.TechnicalKey == "FrameworkAgreement.traceability", + x => x.TechnicalKey == "purpose.trace.v1.TraceBattery", + x => x.TechnicalKey == "purpose.trace.v1.aspects", + x => x.TechnicalKey == "companyRole.dismantler", + x => x.TechnicalKey == "purpose.trace.v1.qualityanalysis" ); } @@ -161,42 +162,14 @@ public async Task GetPolicyContent_UsageDismantlerIn_ReturnsExpected() public async Task GetPolicyContent_TraceabilityUsagePurposeEquals_ReturnsExpected() { // Act - var response = await _client.GetAsync($"{BaseUrl}/policy-content?useCase={UseCaseId.Traceability}&type={PolicyTypeId.Usage}&credential=purpose&operatorId={OperatorId.Equals}").ConfigureAwait(false); + var response = await _client.GetAsync($"{BaseUrl}/policy-content?useCase={UseCaseId.Traceability}&type={PolicyTypeId.Usage}&credential=purpose.trace.v1.TraceBattery&operatorId={OperatorId.Equals}").ConfigureAwait(false); // Assert response.Should().NotBeNull(); response.StatusCode.Should().Be(HttpStatusCode.OK); (await response.Content.ReadAsStringAsync().ConfigureAwait(false)) .Should() - .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"leftOperand\":\"purpose\",\"operator\":\"eq\",\"rightOperand\":\"ID Trace 3.1\"}}}}"); - } - - [Fact] - public async Task GetPolicyContent_QualityUsagePurposeEqualsWithoutValue_ReturnsExpected() - { - // Act - var response = await _client.GetAsync($"{BaseUrl}/policy-content?useCase={UseCaseId.Quality}&type={PolicyTypeId.Usage}&credential=purpose&operatorId={OperatorId.Equals}").ConfigureAwait(false); - - // Assert - response.Should().NotBeNull(); - response.StatusCode.Should().Be(HttpStatusCode.OK); - (await response.Content.ReadAsStringAsync().ConfigureAwait(false)) - .Should() - .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"leftOperand\":\"purpose\",\"operator\":\"eq\",\"rightOperand\":\"{dynamicValue}\"}}}}"); - } - - [Fact] - public async Task GetPolicyContent_QualityUsagePurposeEqualsWithValue_ReturnsExpected() - { - // Act - var response = await _client.GetAsync($"{BaseUrl}/policy-content?useCase={UseCaseId.Quality}&type={PolicyTypeId.Usage}&credential=purpose&operatorId={OperatorId.Equals}&value=Test").ConfigureAwait(false); - - // Assert - response.Should().NotBeNull(); - response.StatusCode.Should().Be(HttpStatusCode.OK); - (await response.Content.ReadAsStringAsync().ConfigureAwait(false)) - .Should() - .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"leftOperand\":\"purpose\",\"operator\":\"eq\",\"rightOperand\":\"Test\"}}}}"); + .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"leftOperand\":\"purpose.trace.v1.TraceBattery\",\"operator\":\"eq\",\"rightOperand\":\"ID Trace 3.1\"}}}}"); } #endregion diff --git a/tests/hub/PolicyHub.Service.Tests/Setup/IntegrationTestFactory.cs b/tests/hub/PolicyHub.Service.Tests/Setup/IntegrationTestFactory.cs index e365304..bb70853 100644 --- a/tests/hub/PolicyHub.Service.Tests/Setup/IntegrationTestFactory.cs +++ b/tests/hub/PolicyHub.Service.Tests/Setup/IntegrationTestFactory.cs @@ -33,6 +33,7 @@ using Org.Eclipse.TractusX.PolicyHub.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Framework.Logging; using Org.Eclipse.TractusX.Portal.Backend.Framework.Seeding; +using System.Text.Json.Serialization; using Testcontainers.PostgreSql; [assembly: CollectionBehavior(DisableTestParallelization = true)] @@ -58,12 +59,20 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) }); builder.ConfigureTestServices(services => { + services.ConfigureHttpJsonOptions(options => + { + options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()); + }); + services.Configure(options => + { + options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); + }); services.RemoveProdDbContext(); services.AddDbContext(options => { options.UseNpgsql(Container.GetConnectionString(), x => x.MigrationsAssembly(typeof(BatchInsertSeeder).Assembly.GetName().Name) - .MigrationsHistoryTable("__efmigrations_history_portal")); + .MigrationsHistoryTable("__efmigrations_history_hub")); }); services.AddSingleton(); });