diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d16f2997..d1a179e5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,22 +1,23 @@ -################################################################################# -# Copyright (c) 2022,2023 T-Systems International GmbH -# Copyright (c) 2022,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 -################################################################################ +#******************************************************************************* +#* Copyright (c) 2022, 2023 T-Systems International GmbH +#* Copyright (c) 2022, 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 +#******************************************************************************** + name: build @@ -36,10 +37,11 @@ on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: - env: - IMAGE_NAMESPACE: "tractusx" - IMAGE_NAME: "managed-service-orchestrator" + REGISTRY: ghcr.io + IMAGE_NAME: catenax-ng/tx-managed-service-orchestrator/autosetup + # Allows you to run this workflow manually from the Actions tab + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -61,9 +63,7 @@ jobs: uses: docker/metadata-action@v4 with: images: | - ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }} - # Automatically prepare image tags; See action docs for more examples. - # semver patter will generate tags like these for example :1 :1.2 :1.2.3 + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch type=ref,event=pr @@ -73,31 +73,18 @@ jobs: flavor: | latest=true - - name: DockerHub login + - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' uses: docker/login-action@v2 with: - # Use existing DockerHub credentials present as secrets - username: ${{ secrets.DOCKER_HUB_USER }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@v3 with: context: . - # Build image for verification purposes on every trigger event. Only push if event is not a PR push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - # https://github.com/peter-evans/dockerhub-description - # Important step to push image description to DockerHub - - name: Update Docker Hub description - if: github.event_name != 'pull_request' - uses: peter-evans/dockerhub-description@v3 - with: - # readme-filepath defaults to toplevel README.md, Only necessary if you have a dedicated file with your 'Notice for docker images' - # readme-filepath: path/to/dedicated/notice-for-docker-image.md - username: ${{ secrets.DOCKER_HUB_USER }} - password: ${{ secrets.DOCKER_HUB_TOKEN }} - repository: ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/chart-release.yml b/.github/workflows/chart-release.yml index 0ee615db..d7582ab8 100644 --- a/.github/workflows/chart-release.yml +++ b/.github/workflows/chart-release.yml @@ -26,7 +26,7 @@ on: paths: - 'charts/**' branches: - - main + - closeRelease jobs: release: # depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions diff --git a/.github/workflows/helm-lint.yaml b/.github/workflows/helm-lint.yaml index d79f4fa1..438c3ab0 100644 --- a/.github/workflows/helm-lint.yaml +++ b/.github/workflows/helm-lint.yaml @@ -24,7 +24,7 @@ on: push: paths: - 'charts/**' - branches: [main] + branches: [closeRelease] pull_request: paths: - 'charts/**' @@ -39,7 +39,7 @@ on: upgrade_from: description: 'Managed service orchestrator service chart version to upgrade from' # version from 3.1 release - default: '1.5.2' + default: '1.5.6' jobs: lint-test: @@ -96,6 +96,6 @@ jobs: run: | helm repo add bitnami https://charts.bitnami.com/bitnami helm repo add tractusx-dev https://eclipse-tractusx.github.io/charts/dev - helm install orchestrator tractusx-dev/managed-service-orchestrator --version ${{ github.event.inputs.upgrade_from || '1.5.2' }} + helm install orchestrator tractusx-dev/managed-service-orchestrator --version ${{ github.event.inputs.upgrade_from || '1.5.6' }} helm upgrade orchestrator charts/orchestrator if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true' diff --git a/.github/workflows/kics.yml b/.github/workflows/kics.yml index a9110dda..51b2e796 100644 --- a/.github/workflows/kics.yml +++ b/.github/workflows/kics.yml @@ -22,7 +22,7 @@ name: "KICS" on: push: - branches: [main] + branches: [closeRelease] # pull_request: # The branches below must be a subset of the branches above # branches: [main, master] diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index bdb4117c..a8b717c4 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -21,6 +21,9 @@ name: "Trivy" on: + push: + branches: + - closeRelease schedule: - cron: "0 0 * * 0" workflow_dispatch: diff --git a/.github/workflows/veracode.yaml b/.github/workflows/veracode.yaml deleted file mode 100644 index 61611f98..00000000 --- a/.github/workflows/veracode.yaml +++ /dev/null @@ -1,59 +0,0 @@ -#******************************************************************************* -#* Copyright (c) 2022, 2023 T-Systems International GmbH -#* Copyright (c) 2022, 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 -#******************************************************************************** - -name: "Veracode upload and scan" - -on: - schedule: - # Once a day - - cron: "0 0 * * *" - workflow_dispatch: - # Trigger manually - - -jobs: - analyze: - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Set up JDK 18 - uses: actions/setup-java@v3 - with: - java-version: '18' - distribution: 'temurin' - - - name: Build - run: mvn -B package - - - name: Run Veracode Upload And Scan - uses: veracode/veracode-uploadandscan-action@0.2.1 - with: - appname: "DFT AutoSetup" - createprofile: false - filepath: "./target/*.jar" - vid: "${{ secrets.VERACODE_API_ID }}" - vkey: "${{ secrets.VERACODE_API_KEY }}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 6181a112..fd6c47e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,35 +5,53 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Changed - postgresql DB upgrade -## [1.5.4] - 2024-03-06 +## [1.5.7] - 2024-03-13 ### Fixed - Fixed CVE-2024-22234 and CVE-2024-22243 - Fixed Trivy security issue CVE-2024-1597 +- Fix helm repo name in `INSTALL.md` (#89) +- Fix link to temurin repository in "Notice for Docker images" (#90) +- Remove default connection test, that prevented helm test to succeed (#92) +- Fix Chart names in helm test step (#95) ### Changed - Update Spring Boot to version 3.2.3 - Update commons-text, commons-io, commons-compres, bcprov, bcpkix, snappy-java, jakarta.activation-api - -## [1.5.3] - 2024-02-19 -### Fixed - Fixed trivy security issues CVE-2023-34053, CVE-2023-46589, CVE-2023-6378 +## [1.5.6] - 2023-11-21 -## [1.5.2] - 2023-11-24 +### Changed +- Handle minio duplication +- Avoid managed service orchestrator failure in case DT asset creation failed +- Support portal autosetup changes -### Fixed +## [1.5.5] - 2023-11-02 -- Fix helm repo name in `INSTALL.md` (#89) -- Fix link to temurin repository in "Notice for Docker images" (#90) -- Remove default connection test, that prevented helm test to succeed (#92) -- Fix Chart names in helm test step (#95) +### Changed + - Handle Minio user duplication + +## [1.5.4] - 2023-11-01 +### Removed + - Removal of openssh dependency + +## [1.5.3] - 2023-10-30 -## [1.5.1] - 2023-11-17 +### Changed + - Refactor DT registry local use + +## [1.5.2] - 2023-10-27 + +### Added + - Minio support working version + - Email send refactor + - Refactor s3 policy template use -[App release 1.5.0](https://github.com/eclipse-tractusx/managed-service-orchestrator/releases/tag/v1.5.1) +## [1.5.1] - 2023-10-16 ### Changed - Update DT asset creation for oauth secret information diff --git a/DEPENDENCIES b/DEPENDENCIES index a0c53c73..63f0e69e 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,30 +1,3 @@ -maven/mavencentral/ch.qos.logback/logback-classic/1.4.14, EPL-1.0 OR LGPL-2.1-only, approved, #3435 -maven/mavencentral/ch.qos.logback/logback-core/1.4.14, EPL-1.0 OR LGPL-2.1-only, approved, #3373 -maven/mavencentral/com.carrotsearch.thirdparty/simple-xml-safe/2.7.1, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.15.4, Apache-2.0, approved, #7947 -maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.15.4, MIT AND Apache-2.0, approved, #7932 -maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.15.4, Apache-2.0, approved, #7934 -maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-toml/2.15.4, Apache-2.0, approved, #9160 -maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.4, Apache-2.0, approved, #8802 -maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.15.4, Apache-2.0, approved, #8808 -maven/mavencentral/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.15.4, Apache-2.0, approved, #7930 -maven/mavencentral/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.4, Apache-2.0, approved, #8803 -maven/mavencentral/com.fasterxml/classmate/1.6.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.github.stephenc.jcip/jcip-annotations/1.0-1, Apache-2.0, approved, CQ21949 -maven/mavencentral/com.google.code.findbugs/jsr305/3.0.2, Apache-2.0, approved, #20 -maven/mavencentral/com.google.code.gson/gson/2.10.1, Apache-2.0, approved, #6159 -maven/mavencentral/com.google.errorprone/error_prone_annotations/2.18.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.google.guava/failureaccess/1.0.1, Apache-2.0, approved, CQ22654 -maven/mavencentral/com.google.guava/guava/32.0.1-jre, Apache-2.0 AND CC0-1.0 AND CC-PDDC, approved, #8772 -maven/mavencentral/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava, Apache-2.0, approved, CQ22657 -maven/mavencentral/com.google.j2objc/j2objc-annotations/2.8, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.nimbusds/content-type/2.2, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.nimbusds/lang-tag/1.7, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.nimbusds/nimbus-jose-jwt/9.24.4, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.nimbusds/oauth2-oidc-sdk/9.43.3, Apache-2.0, approved, clearlydefined -maven/mavencentral/com.squareup.okhttp3/okhttp/4.12.0, Apache-2.0, approved, #11156 -maven/mavencentral/com.squareup.okio/okio-jvm/3.6.0, Apache-2.0, approved, #11158 -maven/mavencentral/com.squareup.okio/okio/3.6.0, Apache-2.0, approved, #11155 maven/mavencentral/com.sun.mail/javax.mail/1.6.2, CDDL-1.0 AND Apache-2.0, approved, CQ18739 maven/mavencentral/com.zaxxer/HikariCP/5.0.1, Apache-2.0, approved, clearlydefined maven/mavencentral/commons-codec/commons-codec/1.16.1, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #9157 @@ -32,20 +5,16 @@ maven/mavencentral/commons-fileupload/commons-fileupload/1.5, Apache-2.0, approv maven/mavencentral/commons-io/commons-io/2.15.1, Apache-2.0, approved, #11244 maven/mavencentral/io.github.openfeign.form/feign-form-spring/3.8.0, Apache-2.0, approved, clearlydefined maven/mavencentral/io.github.openfeign.form/feign-form/3.8.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.github.openfeign/feign-core/13.1, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.github.openfeign/feign-slf4j/13.1, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.micrometer/micrometer-commons/1.12.3, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #11679 -maven/mavencentral/io.micrometer/micrometer-observation/1.12.3, Apache-2.0, approved, #11680 +maven/mavencentral/io.github.openfeign/feign-core/12.3, Apache-2.0, approved, clearlydefined +maven/mavencentral/io.github.openfeign/feign-slf4j/12.3, Apache-2.0, approved, clearlydefined +maven/mavencentral/io.micrometer/micrometer-commons/1.11.0, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #9243 +maven/mavencentral/io.micrometer/micrometer-observation/1.11.0, Apache-2.0, approved, #9242 maven/mavencentral/io.minio/minio-admin/8.5.6, Apache-2.0, approved, clearlydefined maven/mavencentral/io.minio/minio/8.5.6, Apache-2.0, approved, #9097 -maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.19, Apache-2.0, approved, #5947 -maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.19, Apache-2.0, approved, #5929 -maven/mavencentral/io.swagger.core.v3/swagger-models-jakarta/2.2.19, Apache-2.0, approved, #5919 -maven/mavencentral/jakarta.activation/jakarta.activation-api/2.1.2, EPL-2.0 OR BSD-3-Clause OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jaf -maven/mavencentral/jakarta.annotation/jakarta.annotation-api/2.1.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.ca -maven/mavencentral/jakarta.persistence/jakarta.persistence-api/3.1.0, EPL-2.0 OR BSD-3-Clause AND (EPL-2.0 OR BSD-3-Clause AND BSD-3-Clause), approved, #7696 -maven/mavencentral/jakarta.transaction/jakarta.transaction-api/2.0.1, EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0, approved, #7697 -maven/mavencentral/jakarta.validation/jakarta.validation-api/3.0.2, Apache-2.0, approved, ee4j.validation +maven/mavencentral/io.smallrye/jandex/3.0.5, Apache-2.0, approved, clearlydefined +maven/mavencentral/io.swagger.core.v3/swagger-annotations-jakarta/2.2.7, Apache-2.0, approved, #5947 +maven/mavencentral/io.swagger.core.v3/swagger-core-jakarta/2.2.7, Apache-2.0, approved, #5929 +maven/mavencentral/io.swagger.core.v3/swagger-models-jakarta/2.2.7, Apache-2.0, approved, #5919 maven/mavencentral/jakarta.xml.bind/jakarta.xml.bind-api/4.0.1, BSD-3-Clause, approved, ee4j.jaxb maven/mavencentral/javax.activation/activation/1.1, CDDL-1.0, approved, CQ134 maven/mavencentral/net.minidev/accessors-smart/2.5.0, Apache-2.0, approved, clearlydefined @@ -64,9 +33,30 @@ maven/mavencentral/org.bouncycastle/bcpkix-jdk18on/1.77, MIT, approved, #11593 maven/mavencentral/org.bouncycastle/bcprov-jdk18on/1.77, MIT AND CC0-1.0, approved, #11595 maven/mavencentral/org.bouncycastle/bcutil-jdk18on/1.77, MIT, approved, #11596 maven/mavencentral/org.checkerframework/checker-qual/3.42.0, MIT, approved, clearlydefined -maven/mavencentral/org.eclipse.persistence/eclipselink/3.0.3, EPL-2.0 OR BSD-3-Clause, approved, ee4j.eclipselink -maven/mavencentral/org.flywaydb/flyway-core/9.22.3, Apache-2.0, approved, #10349 -maven/mavencentral/org.freemarker/freemarker/2.3.32, Apache-2.0, approved, #6764 +======= +maven/mavencentral/jakarta.xml.bind/jakarta.xml.bind-api/4.0.0, BSD-3-Clause, approved, ee4j.jaxb +maven/mavencentral/javax.activation/activation/1.1, CDDL-1.0, approved, CQ134 +maven/mavencentral/net.bytebuddy/byte-buddy-agent/1.14.4, Apache-2.0, approved, #7164 +maven/mavencentral/net.bytebuddy/byte-buddy/1.14.4, Apache-2.0 AND BSD-3-Clause, approved, #7163 +maven/mavencentral/net.minidev/accessors-smart/2.4.9, Apache-2.0, approved, #7515 +maven/mavencentral/net.minidev/json-smart/2.4.9, Apache-2.0, approved, #3288 +maven/mavencentral/org.antlr/antlr4-runtime/4.10.1, BSD-3-Clause AND LicenseRef-Public-domain AND MIT AND LicenseRef-Unicode-TOU, approved, #7065 +maven/mavencentral/org.apache.commons/commons-compress/1.24.0, Apache-2.0 AND BSD-3-Clause AND bzip2-1.0.6 AND LicenseRef-Public-Domain, approved, #10368 +maven/mavencentral/org.apache.commons/commons-lang3/3.12.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.apache.commons/commons-text/1.10.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.apache.logging.log4j/log4j-api/2.17.1, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.apache.logging.log4j/log4j-to-slf4j/2.17.1, Apache-2.0, approved, #2163 +maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-core/10.1.8, Apache-2.0 AND (EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0) AND (CDDL-1.0 OR GPL-2.0-only WITH Classpath-exception-2.0) AND W3C AND CC0-1.0, approved, #5949 +maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-el/10.1.8, Apache-2.0, approved, #6997 +maven/mavencentral/org.apache.tomcat.embed/tomcat-embed-websocket/10.1.8, Apache-2.0, approved, #7920 +maven/mavencentral/org.apiguardian/apiguardian-api/1.1.2, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.aspectj/aspectjweaver/1.9.19, EPL-1.0, approved, tools.aspectj +maven/mavencentral/org.assertj/assertj-core/3.24.2, Apache-2.0, approved, #6161 +maven/mavencentral/org.bouncycastle/bcpkix-jdk15on/1.70, MIT, approved, clearlydefined +maven/mavencentral/org.bouncycastle/bcprov-jdk15on/1.70, MIT, approved, #1712 +maven/mavencentral/org.bouncycastle/bcprov-jdk18on/1.74, MIT AND CC0-1.0, approved, #9091 +maven/mavencentral/org.bouncycastle/bcutil-jdk15on/1.70, MIT, approved, clearlydefined +maven/mavencentral/org.checkerframework/checker-qual/3.31.0, MIT, approved, clearlydefined maven/mavencentral/org.hibernate.orm/hibernate-core/6.4.4.Final, LGPL-2.1-or-later AND (EPL-2.0 OR BSD-3-Clause) AND MIT, approved, #12490 maven/mavencentral/org.hibernate.validator/hibernate-validator/8.0.1.Final, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jboss.logging/jboss-logging/3.5.3.Final, Apache-2.0, approved, #9471 @@ -75,8 +65,25 @@ maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.9.22, Apache-2.0, a maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.9.22, Apache-2.0, approved, clearlydefined maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib/1.9.22, Apache-2.0, approved, #11827 maven/mavencentral/org.jetbrains/annotations/13.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/org.mapstruct/mapstruct/1.4.2.Final, Apache-2.0, approved, #2483 -maven/mavencentral/org.ow2.asm/asm/9.3, BSD-3-Clause, approved, clearlydefined +maven/mavencentral/org.glassfish.jaxb/jaxb-core/4.0.2, BSD-3-Clause, approved, ee4j.jaxb +maven/mavencentral/org.glassfish.jaxb/jaxb-runtime/4.0.2, BSD-3-Clause, approved, ee4j.jaxb +maven/mavencentral/org.glassfish.jaxb/txw2/4.0.2, BSD-3-Clause, approved, ee4j.jaxb +maven/mavencentral/org.hamcrest/hamcrest/2.2, BSD-3-Clause, approved, clearlydefined +maven/mavencentral/org.hibernate.common/hibernate-commons-annotations/6.0.6.Final, LGPL-2.1-only, approved, #6962 +maven/mavencentral/org.hibernate.orm/hibernate-core/6.2.2.Final, LGPL-2.1-only AND Apache-2.0 AND MIT AND CC-PDDC AND (EPL-2.0 OR BSD-3-Clause), approved, #9121 +maven/mavencentral/org.hibernate.validator/hibernate-validator/8.0.0.Final, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.jboss.logging/jboss-logging/3.5.0.Final, Apache-2.0, approved, #9471 +maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-common/1.8.21, Apache-2.0, approved, #8910 +maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.8.21, Apache-2.0, approved, #8807 +maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.8.21, Apache-2.0, approved, #8919 +maven/mavencentral/org.jetbrains.kotlin/kotlin-stdlib/1.8.21, Apache-2.0, approved, #8865 +maven/mavencentral/org.jetbrains/annotations/13.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.junit.jupiter/junit-jupiter-api/5.9.3, EPL-2.0, approved, #3133 +maven/mavencentral/org.junit.jupiter/junit-jupiter-engine/5.9.3, EPL-2.0, approved, #3125 +maven/mavencentral/org.junit.jupiter/junit-jupiter-params/5.9.3, EPL-2.0, approved, #3134 +maven/mavencentral/org.junit.jupiter/junit-jupiter/5.9.3, EPL-2.0, approved, #6972 +maven/mavencentral/org.junit.platform/junit-platform-commons/1.9.3, EPL-2.0, approved, #3130 +maven/mavencentral/org.junit.platform/junit-platform-engine/1.9.3, EPL-2.0, approved, #3128 maven/mavencentral/org.postgresql/postgresql/42.7.2, BSD-2-Clause AND Apache-2.0, approved, #11681 maven/mavencentral/org.projectlombok/lombok/1.18.30, MIT AND LicenseRef-Public-Domain, approved, CQ23907 maven/mavencentral/org.slf4j/jul-to-slf4j/2.0.12, MIT, approved, #7698 @@ -133,3 +140,67 @@ maven/mavencentral/org.springframework/spring-webmvc/6.1.4, Apache-2.0, approved maven/mavencentral/org.webjars/swagger-ui/5.10.3, Apache-2.0, approved, #12068 maven/mavencentral/org.xerial.snappy/snappy-java/1.1.10.5, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #9098 maven/mavencentral/org.yaml/snakeyaml/2.2, Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause OR EPL-1.0 OR GPL-2.0-or-later OR LGPL-2.1-or-later), approved, #10232 +maven/mavencentral/org.postgresql/postgresql/42.6.0, BSD-2-Clause AND Apache-2.0, approved, #9159 +maven/mavencentral/org.projectlombok/lombok/1.18.26, MIT AND LicenseRef-Public-Domain, approved, CQ23907 +maven/mavencentral/org.skyscreamer/jsonassert/1.5.1, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.slf4j/jul-to-slf4j/2.0.7, MIT, approved, #7698 +maven/mavencentral/org.slf4j/slf4j-api/2.0.7, MIT, approved, #5915 +maven/mavencentral/org.springdoc/springdoc-openapi-starter-common/2.0.2, Apache-2.0, approved, #5920 +maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-api/2.0.2, Apache-2.0, approved, #5950 +maven/mavencentral/org.springdoc/springdoc-openapi-starter-webmvc-ui/2.0.2, Apache-2.0, approved, #5923 +maven/mavencentral/org.springframework.boot/spring-boot-autoconfigure/3.1.0, Apache-2.0, approved, #9341 +maven/mavencentral/org.springframework.boot/spring-boot-configuration-processor/3.1.0, Apache-2.0, approved, #11406 +maven/mavencentral/org.springframework.boot/spring-boot-devtools/3.1.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.springframework.boot/spring-boot-starter-aop/3.1.0, Apache-2.0, approved, #9338 +maven/mavencentral/org.springframework.boot/spring-boot-starter-data-jpa/3.1.0, Apache-2.0, approved, #9733 +maven/mavencentral/org.springframework.boot/spring-boot-starter-freemarker/3.1.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.springframework.boot/spring-boot-starter-jdbc/3.1.0, Apache-2.0, approved, #9737 +maven/mavencentral/org.springframework.boot/spring-boot-starter-json/3.1.0, Apache-2.0, approved, #9336 +maven/mavencentral/org.springframework.boot/spring-boot-starter-logging/3.1.0, Apache-2.0, approved, #9343 +maven/mavencentral/org.springframework.boot/spring-boot-starter-oauth2-client/3.1.0, Apache-2.0, approved, #8806 +maven/mavencentral/org.springframework.boot/spring-boot-starter-oauth2-resource-server/3.1.0, Apache-2.0, approved, #8804 +maven/mavencentral/org.springframework.boot/spring-boot-starter-security/3.1.0, Apache-2.0, approved, #9337 +maven/mavencentral/org.springframework.boot/spring-boot-starter-test/3.1.0, Apache-2.0, approved, #9353 +maven/mavencentral/org.springframework.boot/spring-boot-starter-tomcat/3.1.0, Apache-2.0, approved, #9351 +maven/mavencentral/org.springframework.boot/spring-boot-starter-validation/3.1.0, Apache-2.0, approved, #9335 +maven/mavencentral/org.springframework.boot/spring-boot-starter-web/3.1.0, Apache-2.0, approved, #9347 +maven/mavencentral/org.springframework.boot/spring-boot-starter/3.1.0, Apache-2.0, approved, #9349 +maven/mavencentral/org.springframework.boot/spring-boot-test-autoconfigure/3.1.0, Apache-2.0, approved, #9339 +maven/mavencentral/org.springframework.boot/spring-boot-test/3.1.0, Apache-2.0, approved, #9346 +maven/mavencentral/org.springframework.boot/spring-boot/3.1.0, Apache-2.0, approved, #9352 +maven/mavencentral/org.springframework.cloud/spring-cloud-commons/4.0.3, Apache-2.0, approved, #7292 +maven/mavencentral/org.springframework.cloud/spring-cloud-context/4.0.3, Apache-2.0, approved, #7306 +maven/mavencentral/org.springframework.cloud/spring-cloud-openfeign-core/4.0.3, Apache-2.0, approved, #7305 +maven/mavencentral/org.springframework.cloud/spring-cloud-starter-openfeign/4.0.3, Apache-2.0, approved, #7302 +maven/mavencentral/org.springframework.cloud/spring-cloud-starter/4.0.3, Apache-2.0, approved, #7299 +maven/mavencentral/org.springframework.data/spring-data-commons/3.1.0, Apache-2.0, approved, #8805 +maven/mavencentral/org.springframework.data/spring-data-jpa/3.1.0, Apache-2.0, approved, #9120 +maven/mavencentral/org.springframework.retry/spring-retry/2.0.1, Apache-2.0, approved, clearlydefined +maven/mavencentral/org.springframework.security/spring-security-config/6.1.2, Apache-2.0, approved, #9736 +maven/mavencentral/org.springframework.security/spring-security-core/6.1.2, Apache-2.0, approved, #9801 +maven/mavencentral/org.springframework.security/spring-security-crypto/6.1.0, Apache-2.0 AND ISC, approved, #9735 +maven/mavencentral/org.springframework.security/spring-security-oauth2-client/6.1.0, Apache-2.0, approved, #9740 +maven/mavencentral/org.springframework.security/spring-security-oauth2-core/6.1.0, Apache-2.0, approved, #9741 +maven/mavencentral/org.springframework.security/spring-security-oauth2-jose/6.1.0, Apache-2.0, approved, #9345 +maven/mavencentral/org.springframework.security/spring-security-oauth2-resource-server/6.1.0, Apache-2.0, approved, #8798 +maven/mavencentral/org.springframework.security/spring-security-rsa/1.0.11.RELEASE, Apache-2.0, approved, CQ20647 +maven/mavencentral/org.springframework.security/spring-security-web/6.1.0, Apache-2.0, approved, #9800 +maven/mavencentral/org.springframework/spring-aop/6.0.9, Apache-2.0, approved, #5940 +maven/mavencentral/org.springframework/spring-aspects/6.0.9, Apache-2.0, approved, #5930 +maven/mavencentral/org.springframework/spring-beans/6.0.9, Apache-2.0, approved, #5937 +maven/mavencentral/org.springframework/spring-context-support/6.0.9, Apache-2.0, approved, #6960 +maven/mavencentral/org.springframework/spring-context/6.0.9, Apache-2.0, approved, #5936 +maven/mavencentral/org.springframework/spring-core/6.0.9, Apache-2.0 AND BSD-3-Clause, approved, #5948 +maven/mavencentral/org.springframework/spring-expression/6.0.9, Apache-2.0, approved, #3284 +maven/mavencentral/org.springframework/spring-jcl/6.0.9, Apache-2.0, approved, #3283 +maven/mavencentral/org.springframework/spring-jdbc/6.0.9, Apache-2.0, approved, #5924 +maven/mavencentral/org.springframework/spring-orm/6.0.9, Apache-2.0, approved, #5925 +maven/mavencentral/org.springframework/spring-test/6.0.9, Apache-2.0, approved, #7003 +maven/mavencentral/org.springframework/spring-tx/6.0.9, Apache-2.0, approved, #5926 +maven/mavencentral/org.springframework/spring-web/6.0.9, Apache-2.0, approved, #5942 +maven/mavencentral/org.springframework/spring-webmvc/6.0.9, Apache-2.0, approved, #5944 +maven/mavencentral/org.webjars/swagger-ui/4.15.5, Apache-2.0 AND MIT, approved, #5921 +maven/mavencentral/org.webjars/webjars-locator-core/0.52, MIT, approved, clearlydefined +maven/mavencentral/org.xerial.snappy/snappy-java/1.1.10.1, Apache-2.0 AND (Apache-2.0 AND BSD-3-Clause), approved, #9098 +maven/mavencentral/org.xmlunit/xmlunit-core/2.9.1, Apache-2.0, approved, #6272 +maven/mavencentral/org.yaml/snakeyaml/2.0, Apache-2.0 AND (Apache-2.0 OR BSD-3-Clause OR EPL-1.0 OR GPL-2.0-or-later OR LGPL-2.1-or-later), approved, #7275 diff --git a/Dockerfile b/Dockerfile index 7be15d1f..badbd0b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,7 @@ COPY ./src ./src # build for release RUN mvn clean install -Dmaven.test.skip=true -FROM eclipse-temurin:17.0.8.1_1-jdk +FROM eclipse-temurin:17.0.10_7-jdk ENV USER=autosetupuser ENV UID=1000 diff --git a/README.md b/README.md index a72f4897..ebcf3ca6 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ This service will help service provider to set up DFT/SDE with EDC and EDC as se ### Software Version ```shell -Application version: 1.5.4 -Helm release version: 1.5.7 +Application version: 1.5.7 +Helm release version: 1.5.9 ``` # Container images diff --git a/charts/orchestrator/Chart.yaml b/charts/orchestrator/Chart.yaml index e841a319..f77d52a4 100644 --- a/charts/orchestrator/Chart.yaml +++ b/charts/orchestrator/Chart.yaml @@ -38,13 +38,13 @@ sources: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.5.7 +version: 1.5.9 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.5.4" +appVersion: "1.5.7" dependencies: - condition: postgresql.enabled diff --git a/charts/orchestrator/README.md b/charts/orchestrator/README.md index 4e3787ca..8f563679 100644 --- a/charts/orchestrator/README.md +++ b/charts/orchestrator/README.md @@ -1,6 +1,6 @@ # managed-service-orchestrator -![Version: 1.5.7](https://img.shields.io/badge/Version-1.5.7-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.5.4](https://img.shields.io/badge/AppVersion-1.5.4-informational?style=flat-square) +![Version: 1.5.8](https://img.shields.io/badge/Version-1.5.8-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.5.7](https://img.shields.io/badge/AppVersion-1.5.7-informational?style=flat-square) This service will help service provider to set up DFT/SDE with EDC and EDC as service in service provider environment. @@ -24,7 +24,7 @@ This service will help service provider to set up DFT/SDE with EDC and EDC as se | affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].weight | int | `100` | | | autoscaling.enabled | bool | `false` | | | image.pullPolicy | string | `"Always"` | Set the Image Pull Policy | -| image.repository | string | `"tractusx/managed-service-orchestrator"` | Image to use for deploying an application | +| image.repository | string | `"ghcr.io/catenax-ng/tx-managed-service-orchestrator/autosetup"` | Image to use for deploying an application | | image.tag | string | `""` | Image tage is defined in chart appVersion | | imagePullSecrets | list | `[]` | | | ingress.annotations | object | `{}` | Annotations to add to the ingress | @@ -40,82 +40,14 @@ This service will help service provider to set up DFT/SDE with EDC and EDC as se | podAnnotations | object | `{}` | | | podSecurityContext.fsGroup | int | `2000` | | | portContainer | int | `9999` | | -| postgresql.auth.database | string | `"testdb"` | | +| postgresql.auth.database | string | `""` | | | postgresql.auth.existingSecret | string | `""` | | -| postgresql.auth.password | string | `""` | | -| postgresql.auth.port | int | `5432` | | -| postgresql.auth.postgresPassword | string | `""` | | -| postgresql.auth.username | string | `"testuser"` | | -| postgresql.enabled | bool | `true` | | -| postgresql.fullnameOverride | string | `"postgresql"` | | +| postgresql.auth.secretKeys.adminPasswordKey | string | `""` | | +| postgresql.auth.secretKeys.userPasswordKey | string | `""` | | +| postgresql.auth.username | string | `""` | | +| postgresql.enabled | bool | `true` | Enable the dependency postgres database | +| postgresql.metrics.containerSecurityContext.enabled | bool | `false` | | | probe.endpoint | string | `"/api/healthz"` | | -| properties.connectorTestServiceUrl | string | `"default"` | | -| properties.connectorregisterUrl | string | `"default"` | | -| properties.connectorregisterkeycloakclientId | string | `"default"` | | -| properties.connectorregisterkeycloakclientSecret | string | `"default"` | | -| properties.connectorregisterkeycloaktokenURI | string | `"default"` | | -| properties.dapsJksUrl | string | `"default"` | | -| properties.dapsTokenUrl | string | `"default"` | | -| properties.dapsUrl | string | `"default"` | | -| properties.dnsname | string | `"default"` | | -| properties.dnsnameProtocol | string | `"default"` | | -| properties.edc_miwUrl | string | `"default"` | | -| properties.edc_ssi_authorityId | string | `"default"` | | -| properties.emailpassword | string | `"default"` | | -| properties.emailuser | string | `"default"` | | -| properties.keycloakAuthserverUrl | string | `"default"` | | -| properties.keycloakBearerOnly | string | `"true"` | | -| properties.keycloakClientid | string | `"default"` | | -| properties.keycloakRealm | string | `"default"` | | -| properties.keycloakResource | string | `"default"` | | -| properties.keycloakSslRequired | string | `"external"` | | -| properties.keycloakUseResourceRoleMappings | string | `"true"` | | -| properties.kubeappsToken | string | `"default"` | | -| properties.kubeappsUrl | string | `"default"` | | -| properties.mail_from | string | `"default"` | | -| properties.mail_to | string | `"default"` | | -| properties.manual_connector_registration | string | `"false"` | | -| properties.manualupdate | string | `"true"` | | -| properties.password | string | `"default"` | | -| properties.portalclientid | string | `"default"` | | -| properties.portalclientsecret | string | `"default"` | | -| properties.portalemail | string | `"default"` | | -| properties.portaltokenurl | string | `"default"` | | -| properties.portalurl | string | `"default"` | | -| properties.postgres-password | string | `"default"` | | -| properties.resourceServerIssuer | string | `"default"` | | -| properties.sde_bpndiscovery_hostname | string | `"default"` | | -| properties.sde_connector_discovery_clientId | string | `"default"` | | -| properties.sde_connector_discovery_clientSecret | string | `"default"` | | -| properties.sde_connector_discovery_token_url | string | `"default"` | | -| properties.sde_digital_twins_authentication_url | string | `"default"` | | -| properties.sde_digital_twins_hostname | string | `"default"` | | -| properties.sde_discovery_authentication_url | string | `"default"` | | -| properties.sde_discovery_clientId | string | `"default"` | | -| properties.sde_discovery_clientSecret | string | `"default"` | | -| properties.sde_discovery_grantType | string | `"default"` | | -| properties.sde_dtregistry_url_prefix | string | `"default"` | | -| properties.sde_dtregistryidp_client_id | string | `"default"` | | -| properties.sde_dtregistrytenant_id | string | `"default"` | | -| properties.sde_keycloak_auth | string | `"default"` | | -| properties.sde_keycloak_realm | string | `"default"` | | -| properties.sde_keycloak_tokenUrl | string | `"default"` | | -| properties.sde_partner_pool_clientId | string | `"default"` | | -| properties.sde_partner_pool_clientSecret | string | `"default"` | | -| properties.sde_partner_pool_hostname | string | `"default"` | | -| properties.sde_portal_backend_authentication_url | string | `"default"` | | -| properties.sde_portal_backend_clientId | string | `"default"` | | -| properties.sde_portal_backend_clientSecret | string | `"default"` | | -| properties.sde_portal_backend_hostname | string | `"default"` | | -| properties.sde_resource_server_issuer | string | `"default"` | | -| properties.smtp_auth | string | `"true"` | | -| properties.smtp_host | string | `"default"` | | -| properties.smtp_port | string | `"default"` | | -| properties.smtp_tls_enable | string | `"true"` | | -| properties.targetCluster | string | `"default"` | | -| properties.targetNamesapce | string | `"default"` | | -| properties.vaultToken | string | `"default"` | | -| properties.vaultUrl | string | `"default"` | | | readinessProbe.failureThreshold | int | `3` | | | readinessProbe.initialDelaySeconds | int | `60` | | | readinessProbe.periodSeconds | int | `10` | | @@ -126,7 +58,7 @@ This service will help service provider to set up DFT/SDE with EDC and EDC as se | resources.limits.memory | string | `"2Gi"` | set a maximum amount of allows memory utilization by specifying a limit on the container. | | resources.requests.cpu | string | `"400m"` | sets the minimum amount of CPU required for the container | | resources.requests.memory | string | `"2Gi"` | set a minimum amount of allows memory utilization by specifying a limit on the container. | -| secretRef | string | `"managed-service-orchestrator"` | | +| secretRef | string | `""` | | | securityContext.allowPrivilegeEscalation | bool | `false` | Controls whether a process can gain more privilege | | securityContext.runAsNonRoot | bool | `true` | | | securityContext.runAsUser | int | `1000` | | diff --git a/charts/orchestrator/templates/deployment.yaml b/charts/orchestrator/templates/deployment.yaml index 1b2e8bf3..a24d7b0d 100644 --- a/charts/orchestrator/templates/deployment.yaml +++ b/charts/orchestrator/templates/deployment.yaml @@ -67,39 +67,6 @@ spec: value: "3" - name: RETRY_BACKOFFDELAY value: "500" - - name: KEYCLOAKBEARERONLY - value: "{{ .Values.properties.keycloakBearerOnly }}" - - name: KEYCLOAKUSERESOURCEROLEMAPPINGS - value: "{{ .Values.properties.keycloakUseResourceRoleMappings }}" - - name: KEYCLOAKSSLREQUIRED - value: "{{ .Values.properties.keycloakSslRequired }}" - - name: MANUAL-CONNECTOR-REGISTRATION - value: "{{ .Values.properties.manual_connector_registration }}" - - name: MANUALUPDATE - value: "{{ .Values.properties.manualupdate }}" - - name: SMTP_AUTH - value: "{{ .Values.properties.smtp_auth }}" - - name: SMTP_TLS_ENABLE - value: "{{ .Values.properties.smtp_tls_enable }}" - - name: SPRING_DATASOURCE_USERNAME - value: {{ .Values.postgresql.auth.username | required ".Values.postgresql.auth.username is required" | quote }} - {{- if .Values.postgresql.fullnameOverride }} - - name: SPRING_DATASOURCE_URL - value: "jdbc:postgresql://{{ .Values.postgresql.fullnameOverride }}:{{ .Values.postgresql.auth.port }}/{{ .Values.postgresql.auth.database }}" - - name: SPRING_DATASOURCE_PASSWORD - valueFrom: - secretKeyRef: - name: {{ .Values.postgresql.fullnameOverride }} - key: "password" - {{- else }} - - name: SPRING_DATASOURCE_URL - value: "jdbc:postgresql://{{ include "managed-service-orchestrator.fullname" . }}-postgresql:{{ .Values.postgresql.auth.port }}/{{ .Values.postgresql.auth.database }}" - - name: SPRING_DATASOURCE_PASSWORD - valueFrom: - secretKeyRef: - name: {{ include "managed-service-orchestrator.fullname" . }}-postgresql - key: "password" - {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} @@ -114,4 +81,4 @@ spec: {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} \ No newline at end of file diff --git a/charts/orchestrator/templates/secret.yaml b/charts/orchestrator/templates/secret.yaml deleted file mode 100644 index 03e1594f..00000000 --- a/charts/orchestrator/templates/secret.yaml +++ /dev/null @@ -1,85 +0,0 @@ -#****************************************************************************** -# Copyright (c) 2022, 2023 T-Systems International GmbH -# Copyright (c) 2022, 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 -#******************************************************************************* - -apiVersion: v1 -kind: Secret -type: Opaque -metadata: - name: {{ .Values.secretRef }} -stringData: - connectorTestServiceUrl: {{ .Values.properties.connectorTestServiceUrl }} - connectorregisterUrl: {{ .Values.properties.connectorregisterUrl }} - connectorregisterkeycloakclientId: {{ .Values.properties.connectorregisterkeycloakclientId }} - connectorregisterkeycloakclientSecret: {{ .Values.properties.connectorregisterkeycloakclientSecret }} - connectorregisterkeycloaktokenURI: {{ .Values.properties.connectorregisterkeycloaktokenURI }} - dapsJksUrl: {{ .Values.properties.dapsJksUrl }} - dapsTokenUrl: {{ .Values.properties.dapsTokenUrl }} - dapsUrl: {{ .Values.properties.dapsUrl }} - dnsname: {{ .Values.properties.dnsname }} - dnsnameProtocol: {{ .Values.properties.dnsnameProtocol }} - edc_miwUrl: {{ .Values.properties.edc_miwUrl }} - edc_ssi_authorityId: {{ .Values.properties.edc_ssi_authorityId }} - emailpassword: {{ .Values.properties.emailpassword }} - emailuser: {{ .Values.properties.emailuser }} - keycloakAuthserverUrl: {{ .Values.properties.keycloakAuthserverUrl }} - keycloakClientid: {{ .Values.properties.keycloakClientid }} - keycloakRealm: {{ .Values.properties.keycloakRealm }} - keycloakResource: {{ .Values.properties.keycloakResource }} - kubeappsToken: {{ .Values.properties.kubeappsToken }} - kubeappsUrl: {{ .Values.properties.kubeappsUrl }} - mail_from: {{ .Values.properties.mail_from }} - mail_to: {{ .Values.properties.mail_to }} - password: {{ .Values.properties.password }} - portalclientid: {{ .Values.properties.portalclientid }} - portalclientsecret: {{ .Values.properties.portalclientsecret }} - portalemail: {{ .Values.properties.portalemail }} - portaltokenurl: {{ .Values.properties.portaltokenurl }} - portalurl: {{ .Values.properties.portalurl }} - resourceServerIssuer: {{ .Values.properties.resourceServerIssuer }} - sde_bpndiscovery-hostname: {{ .Values.properties.sde_bpndiscovery_hostname }} - sde_connector-discovery-clientId: {{ .Values.properties.sde_connector_discovery_clientId }} - sde_connector-discovery-clientSecret: {{ .Values.properties.sde_connector_discovery_clientSecret }} - sde_connector-discovery-token-url: {{ .Values.properties.sde_connector_discovery_token_url }} - sde_digital-twins-authentication-url: {{ .Values.properties.sde_digital_twins_authentication_url }} - sde_digital-twins-hostname: {{ .Values.properties.sde_digital_twins_hostname }} - sde_discovery-authentication-url: {{ .Values.properties.sde_discovery_authentication_url }} - sde_discovery-clientId: {{ .Values.properties.sde_discovery_clientId }} - sde_discovery-clientSecret: {{ .Values.properties.sde_discovery_clientSecret }} - sde_discovery-grantType: {{ .Values.properties.sde_discovery_grantType }} - sde_dtregistry-url-prefix: {{ .Values.properties.sde_dtregistry_url_prefix }} - sde_dtregistryidp-client-id: {{ .Values.properties.sde_dtregistryidp_client_id }} - sde_dtregistrytenant-id: {{ .Values.properties.sde_dtregistrytenant_id }} - sde_keycloak-auth: {{ .Values.properties.sde_keycloak_auth }} - sde_keycloak-realm: {{ .Values.properties.sde_keycloak_realm }} - sde_keycloak-tokenUrl: {{ .Values.properties.sde_keycloak_tokenUrl }} - sde_partner-pool-clientId: {{ .Values.properties.sde_partner_pool_clientId }} - sde_partner-pool-clientSecret: {{ .Values.properties.sde_partner_pool_clientSecret }} - sde_partner-pool-hostname: {{ .Values.properties.sde_partner_pool_hostname }} - sde_portal-backend-authentication-url: {{ .Values.properties.sde_portal_backend_authentication_url }} - sde_portal-backend-clientId: {{ .Values.properties.sde_portal_backend_clientId }} - sde_portal-backend-clientSecret: {{ .Values.properties.sde_portal_backend_clientSecret }} - sde_portal-backend-hostname: {{ .Values.properties.sde_portal_backend_hostname }} - sde_resource-server-issuer: {{ .Values.properties.sde_resource_server_issuer }} - smtp_host: {{ .Values.properties.smtp_host }} - smtp_port: {{ .Values.properties.smtp_port }} - targetCluster: {{ .Values.properties.targetCluster }} - targetNamesapce: {{ .Values.properties.targetNamesapce }} - vaultToken: {{ .Values.properties.vaultToken }} - vaultUrl: {{ .Values.properties.vaultUrl }} diff --git a/charts/orchestrator/values.yaml b/charts/orchestrator/values.yaml index 9b004337..68e7af00 100644 --- a/charts/orchestrator/values.yaml +++ b/charts/orchestrator/values.yaml @@ -23,7 +23,7 @@ replicaCount: 1 image: # -- Image to use for deploying an application - repository: tractusx/managed-service-orchestrator + repository: ghcr.io/catenax-ng/tx-managed-service-orchestrator/autosetup # -- Set the Image Pull Policy pullPolicy: Always # -- Image tage is defined in chart appVersion @@ -113,84 +113,18 @@ readinessProbe: successThreshold: 1 timeoutSeconds: 1 -secretRef: "managed-service-orchestrator" +secretRef: "" postgresql: + # -- Enable the dependency postgres database enabled: true - fullnameOverride: "postgresql" + metrics: + containerSecurityContext: + enabled: false auth: - username: "testuser" - password: "" - postgresPassword: "" - database: "testdb" - port: 5432 + username: "" + database: "" existingSecret: "" - -properties: - connectorTestServiceUrl: default - connectorregisterUrl: default - connectorregisterkeycloakclientId: default - connectorregisterkeycloakclientSecret: default - connectorregisterkeycloaktokenURI: default - dapsJksUrl: default - dapsTokenUrl: default - dapsUrl: default - dnsname: default - dnsnameProtocol: default - edc_miwUrl: default - edc_ssi_authorityId: default - emailpassword: default - emailuser: default - keycloakAuthserverUrl: default - keycloakBearerOnly: "true" - keycloakClientid: default - keycloakRealm: default - keycloakResource: default - keycloakSslRequired: external - keycloakUseResourceRoleMappings: "true" - kubeappsToken: default - kubeappsUrl: default - mail_from: default - mail_to: default - manual_connector_registration: "false" - manualupdate: "true" - password: default - portalclientid: default - portalclientsecret: default - portalemail: default - portaltokenurl: default - portalurl: default - postgres-password: default - resourceServerIssuer: default - sde_bpndiscovery_hostname: default - sde_connector_discovery_clientId: default - sde_connector_discovery_clientSecret: default - sde_connector_discovery_token_url: default - sde_digital_twins_authentication_url: default - sde_digital_twins_hostname: default - sde_discovery_authentication_url: default - sde_discovery_clientId: default - sde_discovery_clientSecret: default - sde_discovery_grantType: default - sde_dtregistry_url_prefix: default - sde_dtregistryidp_client_id: default - sde_dtregistrytenant_id: default - sde_keycloak_auth: default - sde_keycloak_realm: default - sde_keycloak_tokenUrl: default - sde_partner_pool_clientId: default - sde_partner_pool_clientSecret: default - sde_partner_pool_hostname: default - sde_portal_backend_authentication_url: default - sde_portal_backend_clientId: default - sde_portal_backend_clientSecret: default - sde_portal_backend_hostname: default - sde_resource_server_issuer: default - smtp_auth: "true" - smtp_host: default - smtp_port: default - smtp_tls_enable: "true" - targetCluster: default - targetNamesapce: default - vaultToken: default - vaultUrl: default + secretKeys: + adminPasswordKey: "" + userPasswordKey: "" diff --git a/pom.xml b/pom.xml index 00be39af..88439ef4 100644 --- a/pom.xml +++ b/pom.xml @@ -32,7 +32,7 @@ org.eclipse.tractusx managed-service-orchestrator - 1.5.4 + 1.5.7 managed-service-orchestrator managed-service-orchestrator @@ -184,6 +184,7 @@ io.minio minio + 8.5.6 io.minio @@ -194,7 +195,6 @@ bcpkix-jdk18on - diff --git a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java b/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java index 24a2808d..a237082f 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/apiproxy/EDCProxyService.java @@ -20,7 +20,6 @@ package org.eclipse.tractusx.autosetup.apiproxy; -import java.io.InputStream; import java.net.URI; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -29,13 +28,10 @@ import java.util.Map; import java.util.UUID; -import org.apache.commons.text.StringSubstitutor; -import org.eclipse.tractusx.autosetup.exception.ServiceException; import org.eclipse.tractusx.autosetup.model.Customer; +import org.eclipse.tractusx.autosetup.utility.ValueReplacerUtility; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.MappingJsonFactory; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -50,6 +46,7 @@ public class EDCProxyService { private static final String DATE_FORMATTER = "dd/MM/yyyy HH:mm:ss"; private final EDCApiProxy eDCApiProxy; + private final ValueReplacerUtility valueReplacerUtility; private Map requestHeader(Map inputData) { Map header = new HashMap<>(); @@ -60,7 +57,7 @@ private Map requestHeader(Map inputData) { @SneakyThrows public List getAssets(Customer customerDetails, Map inputData) { String dataURL = inputData.get(CONTROL_PLANE_DATA_ENDPOINT); - String readValueAsTree = getSchemaFromFile("/edc-request-template/asset-request-filter.json"); + String readValueAsTree = valueReplacerUtility.getRequestFile("/request-template/asset-request-filter.json"); ObjectNode requestBody = (ObjectNode) new ObjectMapper().readTree(readValueAsTree); return eDCApiProxy.getAssets(new URI(dataURL), requestHeader(inputData), requestBody); } @@ -75,8 +72,7 @@ public String createAsset(Customer customerDetails, Map inputDat String date = localdate.format(DateTimeFormatter.ofPattern(DATE_FORMATTER)); inputData.put("createdDate", date); inputData.put("updateDate", date); - String readValueAsTree = getSchemaFromFile("/edc-request-template/asset.json"); - String jsonString = valueReplacer(readValueAsTree, inputData); + String jsonString = valueReplacerUtility.valueReplacer("/request-template/asset.json", inputData); ObjectNode json = (ObjectNode) new ObjectMapper().readTree(jsonString); eDCApiProxy.createAsset(new URI(dataURL), requestHeader(inputData), json); @@ -88,8 +84,7 @@ public String createPolicy(Customer customerDetails, Map inputDa String uId = UUID.randomUUID().toString(); inputData.put("policyId", uId); String dataURL = inputData.get(CONTROL_PLANE_DATA_ENDPOINT); - String readValueAsTree = getSchemaFromFile("/edc-request-template/policy.json"); - String jsonString = valueReplacer(readValueAsTree, inputData); + String jsonString = valueReplacerUtility.valueReplacer("/request-template/policy.json", inputData); ObjectNode json = (ObjectNode) new ObjectMapper().readTree(jsonString); eDCApiProxy.createPolicy(new URI(dataURL), requestHeader(inputData), json); return uId; @@ -99,42 +94,12 @@ public String createPolicy(Customer customerDetails, Map inputDa public String createContractDefination(Customer customerDetails, Map inputData) { String uId = UUID.randomUUID().toString(); inputData.put("contractPolicyId", uId); - String readValueAsTree = getSchemaFromFile("/edc-request-template/contract-defination.json"); - String jsonString = valueReplacer(readValueAsTree, inputData); + String jsonString = valueReplacerUtility.valueReplacer("/request-template/contract-defination.json", inputData); String dataURL = inputData.get(CONTROL_PLANE_DATA_ENDPOINT); ObjectNode json = (ObjectNode) new ObjectMapper().readTree(jsonString); eDCApiProxy.createContractDefination(new URI(dataURL), requestHeader(inputData), json); return uId; } - @SneakyThrows - private String getSchemaFromFile(String schemaFile) { - JsonParser createParser = null; - String schema = null; - try { - MappingJsonFactory jf = new MappingJsonFactory(); - InputStream jsonFile = this.getClass().getResourceAsStream(schemaFile); - - if (jsonFile == null) { - // this is how we load file within editor (eg eclipse) - jsonFile = this.getClass().getClassLoader().getResourceAsStream(schemaFile); - } - createParser = jf.createParser(jsonFile); - schema = createParser.readValueAsTree().toString(); - if (schema == null) { - throw new ServiceException("The schema for EDC asset creation is null " + schemaFile); - } - - return schema; - } finally { - if (createParser != null) - createParser.close(); - } - } - - private String valueReplacer(String requestTemplate, Map inputData) { - StringSubstitutor stringSubstitutor1 = new StringSubstitutor(inputData); - return stringSubstitutor1.replace(requestTemplate); - } } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/config/EmailConfiguration.java b/src/main/java/org/eclipse/tractusx/autosetup/config/EmailConfiguration.java index ce5b62a1..7c3f527c 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/config/EmailConfiguration.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/config/EmailConfiguration.java @@ -20,36 +20,22 @@ package org.eclipse.tractusx.autosetup.config; import java.util.Properties; + import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.internet.MimeMessage; -import org.springframework.beans.factory.annotation.Value; + +import org.eclipse.tractusx.autosetup.constant.EmailConfigurationProperty; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import lombok.RequiredArgsConstructor; + @Configuration +@RequiredArgsConstructor public class EmailConfiguration { - @Value("${mail.smtp.host}") - private String host; - - @Value("${mail.smtp.port}") - private String port; - - @Value("${mail.from.address}") - private String fromAddress; - - @Value("${mail.smtp.starttls.enable}") - private Boolean startTlsEnable; - - @Value("${mail.smtp.username}") - private String username; - - @Value("${mail.smtp.password}") - private String password; - - @Value("${mail.smtp.auth}") - private Boolean auth; + private final EmailConfigurationProperty emailConfigurationProperty; @Bean public MimeMessage mimeMessage() { @@ -57,7 +43,7 @@ public MimeMessage mimeMessage() { Session session = Session.getInstance(properties(), new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); + return new PasswordAuthentication(emailConfigurationProperty.getUsername(), emailConfigurationProperty.getPassword()); } }); return new MimeMessage(session); @@ -66,11 +52,11 @@ protected PasswordAuthentication getPasswordAuthentication() { @Bean public Properties properties() { Properties props = new Properties(); - props.put("mail.smtp.user", username); - props.put("mail.smtp.host", host); - props.put("mail.smtp.port", port); - props.put("mail.smtp.starttls.enable", startTlsEnable); - props.put("mail.smtp.auth", auth); + props.put("mail.smtp.user", emailConfigurationProperty.getUsername()); + props.put("mail.smtp.host", emailConfigurationProperty.getHost()); + props.put("mail.smtp.port", emailConfigurationProperty.getPort()); + props.put("mail.smtp.starttls.enable", emailConfigurationProperty.getStartTlsEnable()); + props.put("mail.smtp.auth", emailConfigurationProperty.getAuth()); return props; } } \ No newline at end of file diff --git a/src/main/java/org/eclipse/tractusx/autosetup/constant/EmailConfigurationProperty.java b/src/main/java/org/eclipse/tractusx/autosetup/constant/EmailConfigurationProperty.java new file mode 100644 index 00000000..2e8f24eb --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/constant/EmailConfigurationProperty.java @@ -0,0 +1,56 @@ +/******************************************************************************** +* Copyright (c) 2023 T-Systems International GmbH +* Copyright (c) 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 +********************************************************************************/ + +package org.eclipse.tractusx.autosetup.constant; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +import lombok.Data; + +@Configuration +@Data +public class EmailConfigurationProperty { + + @Value("${mail.smtp.host}") + private String host; + + @Value("${mail.smtp.port}") + private String port; + + @Value("${mail.from.address}") + private String fromAddress; + + @Value("${mail.smtp.starttls.enable}") + private Boolean startTlsEnable; + + @Value("${mail.smtp.username}") + private String username; + + @Value("${mail.smtp.password}") + private String password; + + @Value("${mail.smtp.auth}") + private Boolean auth; + + @Value("${mail.replyto.address}") + private String replytoAddress; + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java index bb77fe0c..0767be6e 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/exception/GlobalDefaultExceptionHandler.java @@ -35,6 +35,11 @@ import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import feign.FeignException; import lombok.extern.slf4j.Slf4j; @ControllerAdvice @@ -62,6 +67,29 @@ public ResponseEntity handlePSQLException(Exception ex, WebRequest reque public ResponseEntity handleValidationException(ValidationException ex, WebRequest request) { return new ResponseEntity<>(ex.getMessage(), HttpStatus.BAD_REQUEST); } + + @ExceptionHandler(FeignException.class) + public ResponseEntity> handleFeignException(FeignException ex, WebRequest request) { + log.error("FeignException: " + ex.getMessage()); + log.error("FeignException RequestBody: " + ex.request()); + log.error("FeignException ResponseBody: " + ex.contentUTF8()); + ObjectMapper objmap = new ObjectMapper(); + Map errorResponse = new HashMap<>(); + errorResponse.put("msg", "Error in remote service execution"); + try { + @SuppressWarnings("unchecked") + Map map = objmap.readValue(ex.contentUTF8(), Map.class); + Object object = map.get("errors"); + if (object != null) + errorResponse = prepareErrorResponse(object.toString()); + } catch (JsonMappingException e) { + log.error("FeignException JsonMappingException " + e.getMessage()); + } catch (JsonProcessingException e) { + log.error("FeignException JsonProcessingException " + e.getMessage()); + } + + return new ResponseEntity<>(errorResponse, HttpStatus.valueOf(ex.status())); + } @Override protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex, @@ -83,5 +111,11 @@ protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotV return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST); } + + private Map prepareErrorResponse(String errormsg) { + Map errorResponse = new HashMap<>(); + errorResponse.put("msg", errormsg); + return errorResponse; + } } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/AutomaticStorageMediaSetupManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/AutomaticStorageMediaSetupManager.java new file mode 100644 index 00000000..2fcbe7f8 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/AutomaticStorageMediaSetupManager.java @@ -0,0 +1,173 @@ +/******************************************************************************** + * Copyright (c) 2022, 2023 T-Systems International GmbH + * Copyright (c) 2022, 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 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.manager; + +import java.util.Map; +import java.util.UUID; + +import org.eclipse.tractusx.autosetup.constant.AppActions; +import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum; +import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerDetails; +import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; +import org.eclipse.tractusx.autosetup.exception.ServiceException; +import org.eclipse.tractusx.autosetup.minio.MinioHandler; +import org.eclipse.tractusx.autosetup.model.Customer; +import org.eclipse.tractusx.autosetup.model.SelectedTools; +import org.eclipse.tractusx.autosetup.utility.PasswordGenerator; +import org.eclipse.tractusx.autosetup.utility.ValueReplacerUtility; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.retry.annotation.Backoff; +import org.springframework.retry.annotation.Retryable; +import org.springframework.retry.support.RetrySynchronizationManager; +import org.springframework.stereotype.Service; + +import io.minio.admin.UserInfo; +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; + +@Service +@Slf4j +@RequiredArgsConstructor +public class AutomaticStorageMediaSetupManager { + + private final AutoSetupTriggerManager autoSetupTriggerManager; + private final MinioHandler minioHandler; + private final ValueReplacerUtility valueReplacerUtility; + + @Value("${automatic.storage.media.minio.endpoint:default}") + private String endpoint; + + @SneakyThrows + @Retryable(retryFor = { + ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) + public Map createStorageMedia(Customer customerDetails, SelectedTools tool, + Map inputData, AppActions action, AutoSetupTriggerEntry triger) { + + AutoSetupTriggerDetails autoSetupTriggerDetails = AutoSetupTriggerDetails.builder() + .id(UUID.randomUUID().toString()).step("STORAGE_MEDIA").build(); + try { + String tenantNameNamespace = triger.getAutosetupTenantName(); + minioHandler.makeBucket(tenantNameNamespace); + + checkAndCreatePolicy(tenantNameNamespace); + + String accessKey= checkAndCreateUserGetSecret(inputData, tenantNameNamespace, customerDetails); + + minioHandler.assignPolicyToUser(accessKey, tenantNameNamespace); + log.info(accessKey + " assigned '"+tenantNameNamespace+"' policy"); + + autoSetupTriggerDetails.setStatus(TriggerStatusEnum.SUCCESS.name()); + inputData.put("storage.media.bucket", tenantNameNamespace); + inputData.put("storage.media.endpoint", endpoint); + + + } catch (Exception ex) { + + log.error("StorageMediaManager failed retry attempt: : {}", + RetrySynchronizationManager.getContext().getRetryCount() + 1); + autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); + autoSetupTriggerDetails.setRemark(ex.getMessage()); + throw new ServiceException("StorageMediaManager Oops! We have an exception - " + ex.getMessage()); + + } finally { + autoSetupTriggerManager.saveTriggerDetails(autoSetupTriggerDetails, triger); + } + + return inputData; + } + + @SneakyThrows + private String checkAndCreateUserGetSecret(Map inputData, String tenantNameNamespace, + Customer customerDetails) { + UserInfo userInfo = null; + String email= customerDetails.getEmail(); + + try { + userInfo = minioHandler.getUserInfo(email); + } catch (Exception e) { + log.info("Exception to get minio user " + e.getMessage()); + } + + if (userInfo == null) { + String generateRandomPassword = PasswordGenerator.generateRandomPassword(50); + minioHandler.addUser(email, generateRandomPassword, tenantNameNamespace); + log.info(email + " user does not exist so created user"); + inputData.put("storage.media.accessKey", email); + inputData.put("storage.media.secretKey", generateRandomPassword); + return email; + } else { + String generateAccessKey = PasswordGenerator.generateRandomPassword(20); + String generateRandomPassword = PasswordGenerator.generateRandomPassword(50); + inputData.put("storage.media.accessKey", generateAccessKey); + inputData.put("storage.media.secretKey", generateRandomPassword); + minioHandler.addUser(generateAccessKey, generateRandomPassword, tenantNameNamespace); + log.info(email + " user already exist with email so creating new access key"); + return generateAccessKey; + } + + } + + @SneakyThrows + private void checkAndCreatePolicy(String tenantNameNamespace) { + // deleting policy before creation if exist + deletePolicy(tenantNameNamespace); + + minioHandler.addCannedPolicy(tenantNameNamespace, valueReplacerUtility + .valueReplacer("/request-template/s3-policy-template.json", Map.of("bucket", tenantNameNamespace))); + log.info(tenantNameNamespace + " bucket policy created successfully"); + } + + + public void deleteStorageMedia(String tenantName, String userEmail) { + deleteBucket(tenantName); + deleteUser(userEmail); + deletePolicy(tenantName); + } + + private void deleteBucket(String tenantName) { + try { + minioHandler.removeBucket(tenantName); + log.info(tenantName + " bucket deleted"); + } catch (Exception e) { + log.error("Delete Bucket Exception " + e.getMessage()); + } + } + + private void deleteUser(String userEmail) { + try { + minioHandler.removeUser(userEmail); + log.info(userEmail + " user deleted"); + } catch (Exception e) { + log.error("Delete User Exception " + e.getMessage()); + } + } + + private void deletePolicy(String tenantName) { + try { + minioHandler.removeCannedPolicy(tenantName); + log.info(tenantName + " bucket policy deleted"); + } catch (Exception e) { + log.error("Delete Bucket Policy Exception " + e.getMessage()); + } + } + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java index 311ce45c..c63e1ca7 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManager.java @@ -36,6 +36,8 @@ import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.model.SelectedTools; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; +import org.eclipse.tractusx.autosetup.utility.JsonObjectProcessingUtility; +import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.eclipse.tractusx.autosetup.utility.LogUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.retry.annotation.Backoff; @@ -45,6 +47,8 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import com.fasterxml.jackson.databind.JsonNode; + import feign.FeignException; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; @@ -55,6 +59,8 @@ @RequiredArgsConstructor public class ConnectorRegistrationManager { + private static final String SUBSCRIPTION_ID = "subscriptionId"; + private static final String ACTIVE = "ACTIVE"; @Value("${connectorregister.url}") @@ -71,6 +77,7 @@ public class ConnectorRegistrationManager { private final AutoSetupTriggerManager autoSetupTriggerManager; private final PortalIntegrationProxy portalIntegrationProxy; + private final KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; @Retryable(retryFor = { ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) @@ -89,16 +96,27 @@ public Map registerConnector(Customer customerDetails, SelectedT + "-CONNECTOR-REGISTER package creating"); file = getTestFile(inputData.get("selfsigncertificate")); + String subscriptionIdVal = inputData.get(SUBSCRIPTION_ID); MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("name", customerDetails.getOrganizationName()); + String tenantNameNamespace = triger.getAutosetupTenantName(); + body.add("name", tenantNameNamespace); body.add("connectorUrl", inputData.get("controlPlaneEndpoint")); body.add("location", customerDetails.getCountry()); - body.add("subscriptionId", inputData.get("subscriptionId")); + body.add(SUBSCRIPTION_ID, subscriptionIdVal); Map header = new HashMap<>(); - header.put("Authorization", "Bearer " + getKeycloakToken()); + header.put("Authorization", + "Bearer " + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); - String connectorId = portalIntegrationProxy.manageConnector(connectorRegistrationUrl, header, body); + String connectorId = checkSubcriptionHaveConnectorRegister(header, subscriptionIdVal); + + if (StringUtils.isNotBlank(connectorId)) { + Map updateBody = new HashMap<>(); + updateBody.put("connectorUrl", inputData.get("controlPlaneEndpoint")); + portalIntegrationProxy.updateRegisterConnectorUrl(connectorRegistrationUrl, header, updateBody); + } else { + connectorId = portalIntegrationProxy.manageConnector(connectorRegistrationUrl, header, body); + } log.info(LogUtil.encode(tenantName) + "-" + LogUtil.encode(packageName) + "-CONNECTOR-REGISTER package created"); @@ -147,6 +165,37 @@ public Map registerConnector(Customer customerDetails, SelectedT } + @SneakyThrows + private String checkSubcriptionHaveConnectorRegister(Map header, String subscriptionId) { + + try { + JsonNode subcriptionWithConnectors = portalIntegrationProxy + .getSubcriptionWithConnectors(connectorRegistrationUrl, header, true); + + if (subcriptionWithConnectors != null && subcriptionWithConnectors.isArray()) { + for (JsonNode jsonNode : subcriptionWithConnectors) { + + String remoteSubscriptionId = JsonObjectProcessingUtility.getValueFromJsonNode(jsonNode, + SUBSCRIPTION_ID); + + if (subscriptionId.equalsIgnoreCase(remoteSubscriptionId)) { + + JsonNode connectorIds = JsonObjectProcessingUtility.getArrayNodeFromJsonNode(jsonNode, + "connectorIds"); + + if (connectorIds != null && connectorIds.isArray() && connectorIds.size() > 0) + return connectorIds.get(0).asText(); + } + } + } + + } catch (Exception e) { + log.error("Error in checkSubcriptionHaveConnectorRegister or not " + e.getMessage()); + } + + return null; + } + @Retryable(retryFor = { ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) public Map deleteConnector(SelectedTools tool, Map inputData, @@ -164,11 +213,12 @@ public Map deleteConnector(SelectedTools tool, Map header = new HashMap<>(); - header.put("Authorization", "Bearer " + getKeycloakToken()); + header.put("Authorization", + "Bearer " + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); autoSetupTriggerDetails.setStatus(TriggerStatusEnum.SUCCESS.name()); portalIntegrationProxy.deleteConnector(connectorRegistrationUrl, header, connectorId); - + log.info(LogUtil.encode(orgName) + "-" + LogUtil.encode(packageName) + "-CONNECTOR-DELETE deleted"); } else @@ -191,21 +241,6 @@ public Map deleteConnector(SelectedTools tool, Map body = new LinkedMultiValueMap<>(); - body.add("grant_type", "client_credentials"); - body.add("client_id", clientId); - body.add("client_secret", clientSecret); - var resultBody = portalIntegrationProxy.readAuthToken(tokenURI, body); - - if (resultBody != null) { - return resultBody.getAccessToken(); - } - return null; - - } - public static Path getTestFile(String str) throws IOException { Path testFile = Files.createTempFile("test-file1", ".crt"); Files.write(testFile, str.getBytes()); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java index 8087824a..2d023e4b 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/DTRegistryManager.java @@ -39,6 +39,7 @@ import org.eclipse.tractusx.autosetup.model.SelectedTools; import org.eclipse.tractusx.autosetup.utility.LogUtil; import org.eclipse.tractusx.autosetup.utility.WaitingTimeUtility; +import org.springframework.beans.factory.annotation.Value; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.Retryable; import org.springframework.retry.support.RetrySynchronizationManager; @@ -59,6 +60,9 @@ public class DTRegistryManager { private final EDCProxyService eDCProxyService; + @Value("${managed.dt-registry.local:true}") + private boolean managedDTRegistryLocal; + @Retryable(retryFor = { ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) public Map managePackage(Customer customerDetails, AppActions action, SelectedTools tool, @@ -74,9 +78,18 @@ public Map managePackage(Customer customerDetails, AppActions ac String dturi = sDEConfigurationProperty.getDtregistryApiUri(); dturi = StringUtils.isAllEmpty(dturi) ? "/api/v3.0" : dturi; - String dtregistryUrl = dnsNameURLProtocol + "://" + dnsName + "/" - + sDEConfigurationProperty.getDtregistryUrlPrefix() + dturi; + if (managedDTRegistryLocal) { + String appName = DT_REGISTRY.name().replace("_", ""); + String localDTUrl = "http://cx-" + packageName + "-" + appName.toLowerCase() + "-registry-svc:8080"; + inputData.put("dtregistryUrl", localDTUrl); + inputData.put("dtregistryUrlWithURI", localDTUrl + dturi); + } else { + String dtregistryUrl = dnsNameURLProtocol + "://" + dnsName + "/"+ sDEConfigurationProperty.getDtregistryUrlPrefix(); + inputData.put("dtregistryUrl", dtregistryUrl); + inputData.put("dtregistryUrlWithURI", dtregistryUrl + dturi); + } + inputData.put("dtNeedExternalAccess", String.valueOf(!managedDTRegistryLocal)); inputData.put("rgdatabase", "registry"); inputData.put("rgdbpass", "admin@123"); inputData.put("rgusername", "catenax"); @@ -84,8 +97,7 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("idpIssuerUri", sDEConfigurationProperty.getResourceServerIssuer()); inputData.put("tenantId", sDEConfigurationProperty.getDtregistrytenantId()); inputData.put("dtregistryUrlPrefix", sDEConfigurationProperty.getDtregistryUrlPrefix()); - - inputData.put("dtregistryUrl", dtregistryUrl); + inputData.put("dtregistryURI", dturi); if (AppActions.CREATE.equals(action)) appManagement.createPackage(DT_REGISTRY, packageName, inputData); @@ -224,4 +236,4 @@ private void createContractDefination(Customer customerDetails, SelectedTools to } } -} +} \ No newline at end of file diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java index 8ab56aeb..a9016be9 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/PortalIntegrationManager.java @@ -23,8 +23,10 @@ import java.net.URI; import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.UUID; +import org.apache.commons.lang3.StringUtils; import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerDetails; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; @@ -36,14 +38,16 @@ import org.eclipse.tractusx.autosetup.portal.model.ServiceInstanceResultResponse; import org.eclipse.tractusx.autosetup.portal.model.TechnicalUserInfo; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; +import org.eclipse.tractusx.autosetup.utility.JsonObjectProcessingUtility; +import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.eclipse.tractusx.autosetup.utility.LogUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.Retryable; import org.springframework.retry.support.RetrySynchronizationManager; import org.springframework.stereotype.Service; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; + +import com.fasterxml.jackson.databind.JsonNode; import feign.FeignException; import lombok.RequiredArgsConstructor; @@ -58,6 +62,8 @@ public class PortalIntegrationManager { private final PortalIntegrationProxy portalIntegrationProxy; private final AutoSetupTriggerManager autoSetupTriggerManager; + + private final KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; @Value("${portal.url}") private URI portalUrl; @@ -89,22 +95,24 @@ public Map postServiceInstanceResultAndGetTenantSpecs(Customer c String dnsName = inputData.get("dnsName"); String dnsNameURLProtocol = inputData.get("dnsNameURLProtocol"); String subscriptionId = inputData.get("subscriptionId"); + String offerId = inputData.get("serviceId"); String applicationURL = dnsNameURLProtocol + "://" + dnsName; inputData.put("applicationURL", applicationURL); Map header = new HashMap<>(); - header.put("Authorization", "Bearer " + getKeycloakToken()); + header.put("Authorization", "Bearer " + keyCloakTokenProxyUtitlity.getKeycloakToken(clientId, clientSecret, tokenURI)); ServiceInstanceResultRequest serviceInstanceResultRequest = ServiceInstanceResultRequest.builder() .requestId(subscriptionId).offerUrl(applicationURL).build(); - if ("app".equalsIgnoreCase(tool.getType())) - serviceInstanceResultResponse = portalIntegrationProxy.postAppInstanceResultAndGetTenantSpecs(portalUrl, - header, serviceInstanceResultRequest); - else - serviceInstanceResultResponse = portalIntegrationProxy - .postServiceInstanceResultAndGetTenantSpecs(portalUrl, header, serviceInstanceResultRequest); + if ("app".equalsIgnoreCase(tool.getType())) { + serviceInstanceResultResponse = processAppGetResponse(subscriptionId, offerId, header, + serviceInstanceResultRequest); + } else { + serviceInstanceResultResponse = processServiceGetResponse(subscriptionId, offerId, header, + serviceInstanceResultRequest); + } if (serviceInstanceResultResponse != null) { @@ -112,12 +120,19 @@ public Map postServiceInstanceResultAndGetTenantSpecs(Customer c if (technicalUserInfo != null) { inputData.put("keycloakAuthenticationClientId", technicalUserInfo.getTechnicalClientId()); inputData.put("keycloakAuthenticationClientSecret", technicalUserInfo.getTechnicalUserSecret()); + } else { + log.warn("technicalUserInfo not recieved from portal"); } ClientInfo clientInfo = serviceInstanceResultResponse.getClientInfo(); if (clientInfo != null) { inputData.put("keycloakResourceClient", clientInfo.getClientId()); + }else { + log.warn("clientInfo not recieved from portal"); } + + autoSetupTriggerDetails.setRemark(serviceInstanceResultResponse.toJsonString()); + log.info(LogUtil.encode(tenantName) + "-" + LogUtil.encode(packageName) + "-PostServiceInstanceResultAndGetTenantSpecs created"); } else { @@ -157,19 +172,88 @@ public Map postServiceInstanceResultAndGetTenantSpecs(Customer c } @SneakyThrows - private String getKeycloakToken() { + private ServiceInstanceResultResponse processAppGetResponse(String subscriptionId, String offerId, + Map header, ServiceInstanceResultRequest serviceInstanceResultRequest) { + ServiceInstanceResultResponse serviceInstanceResultResponse = null; + try { + JsonNode appInstanceResultAndGetTenantSpecs = portalIntegrationProxy + .getAppInstanceResultAndGetTenantSpecs(portalUrl, header, offerId, subscriptionId); + + String appid = JsonObjectProcessingUtility.getValueFromJsonNode(appInstanceResultAndGetTenantSpecs, "appInstanceId"); + String offerSubscriptionStatus = JsonObjectProcessingUtility.getValueFromJsonNode(appInstanceResultAndGetTenantSpecs, + "offerSubscriptionStatus"); + if ((StringUtils.isNotBlank(offerSubscriptionStatus) || "ACTIVE".equalsIgnoreCase(offerSubscriptionStatus)) + && StringUtils.isNotBlank(appid)) { + serviceInstanceResultResponse = ServiceInstanceResultResponse.builder().build(); + serviceInstanceResultResponse.setClientInfo(ClientInfo.builder().clientId(appid).build()); + Optional.ofNullable(formatJsonData(subscriptionId, header, serviceInstanceResultRequest)) + .ifPresent(serviceInstanceResultResponse::setTechnicalUserInfo); + } + } catch (Exception e) { + log.error("ProcessAppGetResponse Error in processing portal call " + e.getMessage()); + } - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("grant_type", "client_credentials"); - body.add("client_id", clientId); - body.add("client_secret", clientSecret); - var resultBody = portalIntegrationProxy.readAuthToken(tokenURI, body); + if (serviceInstanceResultResponse == null) { + serviceInstanceResultResponse = portalIntegrationProxy.postAppInstanceResultAndGetTenantSpecs(portalUrl, + header, serviceInstanceResultRequest); + log.info("Portal Technical created successfully"); + } else { + log.info("Credential already created in portal side we read from it again"); + } + + return serviceInstanceResultResponse; + } - if (resultBody != null) { - return resultBody.getAccessToken(); + @SneakyThrows + private ServiceInstanceResultResponse processServiceGetResponse(String subscriptionId, String offerId, + Map header, ServiceInstanceResultRequest serviceInstanceResultRequest) { + ServiceInstanceResultResponse serviceInstanceResultResponse = null; + try { + JsonNode serviceInstanceResultAndGetTenantSpecs = portalIntegrationProxy + .getServiceInstanceResultAndGetTenantSpecs(portalUrl, header, offerId, subscriptionId); + + String offerSubscriptionStatus = JsonObjectProcessingUtility.getValueFromJsonNode(serviceInstanceResultAndGetTenantSpecs, + "offerSubscriptionStatus"); + String appid = JsonObjectProcessingUtility.getValueFromJsonNode(serviceInstanceResultAndGetTenantSpecs, "appInstanceId"); + + if ((StringUtils.isNotBlank(offerSubscriptionStatus) || "ACTIVE".equalsIgnoreCase(offerSubscriptionStatus)) + && StringUtils.isNotBlank(appid)) { + serviceInstanceResultResponse = ServiceInstanceResultResponse.builder().build(); + serviceInstanceResultResponse.setClientInfo(ClientInfo.builder().clientId(appid).build()); + serviceInstanceResultResponse + .setTechnicalUserInfo(formatJsonData(subscriptionId, header, serviceInstanceResultRequest)); + } + } catch (Exception e) { + log.error("ProcessServiceGetResponse Error in processing portal call" + e.getMessage()); + } + + if (serviceInstanceResultResponse == null) { + + serviceInstanceResultResponse = portalIntegrationProxy.postServiceInstanceResultAndGetTenantSpecs(portalUrl, + header, serviceInstanceResultRequest); + log.info("PostServiceInstanceResultAndGetTenantSpecs created successfully"); + } else { + log.info("Credential already created in portal side just read from it again"); + } + + return serviceInstanceResultResponse; + } + + @SneakyThrows + private TechnicalUserInfo formatJsonData(String subscriptionId, Map header, + ServiceInstanceResultRequest serviceInstanceResultRequest) { + try { + JsonNode technicalUserDetails = portalIntegrationProxy.getTechnicalUserDetails(portalUrl, header, + subscriptionId); + + return TechnicalUserInfo.builder().technicalClientId(JsonObjectProcessingUtility.getValueFromJsonNode(technicalUserDetails, "clientId")) + .technicalUserSecret(JsonObjectProcessingUtility.getValueFromJsonNode(technicalUserDetails, "secret")).build(); + } catch (Exception e) { + log.error("Error in read existing TechnicalUserInfo from portal " + e.getMessage()); } return null; } + } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java index 1560bf73..1ebf22d6 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/SDEManager.java @@ -26,6 +26,7 @@ import java.util.UUID; import org.eclipse.tractusx.autosetup.constant.AppActions; +import org.eclipse.tractusx.autosetup.constant.EmailConfigurationProperty; import org.eclipse.tractusx.autosetup.constant.SDEConfigurationProperty; import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerDetails; @@ -53,11 +54,12 @@ public class SDEManager { @Value("${managed.dt-registry:true}") private boolean managedDtRegistry; - + @Value("${manual.update:false}") private boolean manualUpdate; private final SDEConfigurationProperty sDEConfigurationProperty; + private final EmailConfigurationProperty emailConfigurationProperty; @Retryable(retryFor = { ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "#{${retry.backOffDelay}}")) @@ -85,7 +87,7 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("sde.digital-twins.authentication.url", sDEConfigurationProperty.getDigitalTwinsAuthenticationUrl()); - + if (!manualUpdate) { inputData.put("digital-twins.authentication.clientId", inputData.get("keycloakAuthenticationClientId")); inputData.put("digital-twins.authentication.clientSecret", @@ -94,7 +96,7 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("sdebackendkeycloakclientid", inputData.get("keycloakResourceClient")); inputData.put("sdefrontendkeycloakclientid", inputData.get("keycloakResourceClient")); } - + if (managedDtRegistry) { inputData.put("sde.digital-twins.hostname", inputData.get("dtregistryUrl")); } else { @@ -105,7 +107,7 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("sde.keycloak.auth", sDEConfigurationProperty.getKeycloakAuth()); inputData.put("sde.keycloak.realm", sDEConfigurationProperty.getKeycloakRealm()); inputData.put("sde.keycloak.tokenUrl", sDEConfigurationProperty.getKeycloakTokenUrl()); - + inputData.put("sde.partner.pool.hostname", sDEConfigurationProperty.getPartnerPoolHostname()); inputData.put("sde.partner.pool.authentication.url", sDEConfigurationProperty.getPartnerPoolAuthenticationUrl()); @@ -123,6 +125,21 @@ public Map managePackage(Customer customerDetails, AppActions ac inputData.put("sde.discovery.clientId", sDEConfigurationProperty.getDiscoveryClientId()); inputData.put("sde.discovery.clientSecret", sDEConfigurationProperty.getDiscoveryClientSecret()); + inputData.put("sftpHost", "defaulthost"); + inputData.put("sftpPort", "22"); + inputData.put("sftpUsername", "defaultuser"); + inputData.put("sftpPassword", "defaultpass"); + inputData.put("sftpKey", ""); + + inputData.put("emailUsername", emailConfigurationProperty.getUsername()); + inputData.put("emailPassword", emailConfigurationProperty.getPassword()); + inputData.put("emailHost", emailConfigurationProperty.getHost()); + inputData.put("emailPort", emailConfigurationProperty.getPort()); + inputData.put("emailTo", customerDetails.getEmail()); + inputData.put("emailCC", emailConfigurationProperty.getReplytoAddress()); + inputData.put("emailFrom", customerDetails.getOrganizationName() +" SDE notification"); + inputData.put("emailReply", emailConfigurationProperty.getReplytoAddress()); + String packageName = tool.getLabel(); if (AppActions.CREATE.equals(action)) diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/VaultManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/VaultManager.java index ecda05b4..96b05d5e 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/manager/VaultManager.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/VaultManager.java @@ -58,7 +58,6 @@ public class VaultManager { public static final String CERTIFICATE_PRIVATE_KEY = "certificate-private-key"; private final VaultAppManageProxy vaultManagerProxy; private final AutoSetupTriggerManager autoSetupTriggerManager; - private final OpenSSLClientManager openSSLClientManager; @Value("${vault.url}") private String valutURL; @@ -94,15 +93,13 @@ public Map uploadKeyandValues(Customer customerDetails, Selected tenantVaultSecret = new HashMap<>(); tenantVaultSecret.put(CONTENT, inputData.get("selfsigncertificateprivatekey")); uploadSecrete(tenantNameNamespace, CERTIFICATE_PRIVATE_KEY, tenantVaultSecret); - + tenantVaultSecret = new HashMap<>(); tenantVaultSecret.put(CONTENT, inputData.get("keycloakAuthenticationClientSecret")); uploadSecrete(tenantNameNamespace, CLIENT_SECRET, tenantVaultSecret); - String encryptionkeysalias = openSSLClientManager.executeCommand("openssl rand -base64 16"); tenantVaultSecret = new HashMap<>(); - encryptionkeysalias = encryptionkeysalias.replace("\n", ""); - tenantVaultSecret.put(CONTENT, encryptionkeysalias); + tenantVaultSecret.put(CONTENT, "c3RhbmRhcmRfZW5jX2tleQo="); uploadSecrete(tenantNameNamespace, ENCRYPTIONKEYS, tenantVaultSecret); inputData.put(DAPS_CERT, DAPS_CERT); @@ -164,9 +161,8 @@ public void deleteAllSecret(SelectedTools tool, Map inputData, A deleteSecret(tenantNameNamespace, CERTIFICATE_PRIVATE_KEY); deleteSecret(tenantNameNamespace, ENCRYPTIONKEYS); deleteSecret(tenantNameNamespace, CLIENT_SECRET); - - log.info(LogUtil.encode(orgName) + "-" + LogUtil.encode(packageName) + "-Vault deleted"); + log.info(LogUtil.encode(orgName) + "-" + LogUtil.encode(packageName) + "-Vault deleted"); } catch (Exception ex) { log.error("VaultManager failed retry attempt: : {}", @@ -174,7 +170,8 @@ public void deleteAllSecret(SelectedTools tool, Map inputData, A autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); autoSetupTriggerDetails.setRemark(ex.getMessage()); - throw new ServiceException("VaultManager Oops! We have an exception - " + ex.getMessage()); + throw new ServiceException("VaultManager Oops! We have an exception - " + ex.getMessage() + ", Cause: " + + LogUtil.getCause(ex)); } finally { autoSetupTriggerManager.saveTriggerDetails(autoSetupTriggerDetails, triger); @@ -183,7 +180,7 @@ public void deleteAllSecret(SelectedTools tool, Map inputData, A public void deleteSecret(String tenantName, String secretePath) throws URISyntaxException { - String valutURLwithpath = valutURL + V1_SECRET_DATA + tenantName+ "/data/" + secretePath; + String valutURLwithpath = valutURL + V1_SECRET_DATA + tenantName + "/data/" + secretePath; URI url = new URI(valutURLwithpath); vaultManagerProxy.deleteKeyandValue(url); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/minio/MinioHandler.java b/src/main/java/org/eclipse/tractusx/autosetup/minio/MinioHandler.java new file mode 100644 index 00000000..f86a214f --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/minio/MinioHandler.java @@ -0,0 +1,110 @@ +/******************************************************************************** + * Copyright (c) 2023 T-Systems International GmbH + * Copyright (c) 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 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.minio; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import io.minio.BucketExistsArgs; +import io.minio.MakeBucketArgs; +import io.minio.MinioClient; +import io.minio.RemoveBucketArgs; +import io.minio.admin.MinioAdminClient; +import io.minio.admin.UserInfo; +import io.minio.messages.Bucket; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; + +@Component +@Slf4j +public class MinioHandler { + + private final MinioClient minioClient; + + private final MinioAdminClient minioAdminClient; + + public MinioHandler(@Value("${automatic.storage.media.minio.endpoint:default}") String endpoint, + @Value("${automatic.storage.media.minio.accessKey:default}") String accessKey, + @Value("${automatic.storage.media.minio.secretKey:default}") String secretKey) { + minioAdminClient = MinioAdminClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build(); + minioClient = MinioClient.builder().endpoint(endpoint).credentials(accessKey, secretKey).build(); + } + + @SneakyThrows + public boolean makeBucket(String nameOfBucket) { + boolean flag = bucketExists(nameOfBucket); + if (!flag) { + minioClient.makeBucket(MakeBucketArgs.builder().bucket(nameOfBucket).build()); + log.info(nameOfBucket + " bucket created successfully"); + } else { + log.info(nameOfBucket + " bucket already exist"); + } + return flag; + } + + @SneakyThrows + public List listBucket() { + return minioClient.listBuckets(); + } + + @SneakyThrows + public void removeBucket(String nameOfBucket) { + minioClient.removeBucket(RemoveBucketArgs.builder().bucket(nameOfBucket).build()); + } + + @SneakyThrows + public void addCannedPolicy(String policyName, String policy) { + minioAdminClient.addCannedPolicy(policyName, policy); + } + + @SneakyThrows + public void removeCannedPolicy(String policyName) { + minioAdminClient.removeCannedPolicy(policyName); + } + + @SneakyThrows + public void assignPolicyToUser(String userAccessKey, String policyName) { + minioAdminClient.setPolicy(userAccessKey, false, policyName); + } + + @SneakyThrows + public UserInfo getUserInfo(String userAccessKey) { + return minioAdminClient.getUserInfo(userAccessKey); + } + + @SneakyThrows + public void addUser(String userAccessKey, String userSecretKey, String policyName) { + minioAdminClient.addUser(userAccessKey, UserInfo.Status.ENABLED, userSecretKey, policyName, null); + } + + @SneakyThrows + public void removeUser(String userAccessKey) { + minioAdminClient.deleteUser(userAccessKey); + } + + @SneakyThrows + public boolean bucketExists(String bucketName) { + return minioClient.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build()); + } + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java b/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java index a9818e2e..d2481f50 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/portal/proxy/PortalIntegrationProxy.java @@ -29,10 +29,15 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; + +import com.fasterxml.jackson.databind.JsonNode; @FeignClient(name = "PortalIntegrationProxy", url = "placeholder") public interface PortalIntegrationProxy { @@ -45,17 +50,35 @@ public ServiceInstanceResultResponse postAppInstanceResultAndGetTenantSpecs(URI @RequestHeader Map header, @RequestBody ServiceInstanceResultRequest serviceInstanceResultRequest); - + @GetMapping("/api/apps/{appId}/subscription/{subscriptionId}/provider") + public JsonNode getAppInstanceResultAndGetTenantSpecs(URI url, @RequestHeader Map header, + @PathVariable("appId") String appId, @PathVariable("subscriptionId") String subscriptionId); + @PostMapping("/api/Services/autoSetup") public ServiceInstanceResultResponse postServiceInstanceResultAndGetTenantSpecs(URI url, @RequestHeader Map header, @RequestBody ServiceInstanceResultRequest serviceInstanceResultRequest); - + @GetMapping("/api/Services/{serviceId}/subscription/{subscriptionId}/provider") + public JsonNode getServiceInstanceResultAndGetTenantSpecs(URI url, @RequestHeader Map header, + @PathVariable("serviceId") String serviceId, @PathVariable("subscriptionId") String subscriptionId); + + @GetMapping("/api/administration/serviceaccount/owncompany/serviceaccounts/{offerSubscriptionId}") + public JsonNode getTechnicalUserDetails(URI url, @RequestHeader Map header, + @PathVariable("offerSubscriptionId") String offerSubscriptionId); + @PostMapping("/api/administration/connectors/managed") public String manageConnector(URI url, @RequestHeader Map header, @RequestBody MultiValueMap body); + @GetMapping("/api/administration/connectors/offerSubscriptions") + public JsonNode getSubcriptionWithConnectors(URI url, @RequestHeader Map header, + @RequestParam("connectorIdSet") boolean connectorIdSet); + + @PutMapping("/api/administration/connectors/{offerSubscriptionId}/connectorUrl") + public String updateRegisterConnectorUrl(URI url, @RequestHeader Map header, + @RequestBody Map body); + @DeleteMapping("/api/administration/connectors/{connectorId}") public void deleteConnector(URI url, @RequestHeader Map header, @PathVariable String connectorId); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java b/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java index ba855748..1f0755b9 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorService.java @@ -29,10 +29,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; import org.eclipse.tractusx.autosetup.constant.AppActions; import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum; @@ -67,6 +67,8 @@ @RequiredArgsConstructor public class AutoSetupOrchitestratorService { + private static final String SUCCESS_HTML_TEMPLATE = "success.html"; + private static final String CONTENT = "content"; private static final String CCEMAIL = "ccemail"; private static final String TEST_SERVICE_URL = "testServiceURL"; private static final String CONNECTOR_TEST_RESULT = "connectorTestResult"; @@ -102,16 +104,19 @@ public class AutoSetupOrchitestratorService { private String targetCluster; @Value("${portal.email.address}") - private String portalEmail; - + private String technicalEmail; + @Value("${mail.replyto.address}") private String mailReplytoAddress; - + @Value("${manual.update}") private boolean manualUpdate; @Value("${managed.dt-registry:true}") private boolean managedDtRegistry; + + @Value("${managed.dt-registry.local:true}") + private boolean managedDTRegistryLocal; public String getAllInstallPackages() { return kubeAppManageProxy.getAllInstallPackages(); @@ -287,7 +292,6 @@ private void proceessTrigger(AutoSetupRequest autoSetupRequest, AppActions actio try { Customer customer = autoSetupRequest.getCustomer(); - trigger.setTriggerType(action.name()); for (AppServiceCatalogAndCustomerMapping appCatalogDetails : appCatalogListDetails) { @@ -328,17 +332,17 @@ private void proceessTrigger(AutoSetupRequest autoSetupRequest, AppActions actio log.error("Error in package creation " + e.getMessage()); trigger.setStatus(TriggerStatusEnum.FAILED.name()); trigger.setRemark(e.getMessage()); - generateNotification(autoSetupRequest.getCustomer(), "Error in autosetup execution - "+trigger.getTriggerId()); - } + generateNotification(autoSetupRequest.getCustomer(), + "Error in autosetup execution - " + trigger.getTriggerId(), "", SUCCESS_HTML_TEMPLATE); + } finally { + LocalDateTime now = LocalDateTime.now(); + trigger.setModifiedTimestamp(now.toString()); + trigger.setInputConfiguration(autoSetupTriggerMapper.fromMaptoStr(List.of(inputConfiguration))); - LocalDateTime now = LocalDateTime.now(); - trigger.setModifiedTimestamp(now.toString()); - trigger.setInputConfiguration(autoSetupTriggerMapper.fromMaptoStr(List.of(inputConfiguration))); - - autoSetupTriggerManager.saveTriggerUpdate(trigger); + autoSetupTriggerManager.saveTriggerUpdate(trigger); + } } - private void executeEDCTractus(AutoSetupRequest autoSetupRequest, AppActions action, AutoSetupTriggerEntry trigger, Map inputConfiguration, SelectedTools selectedTool) { @@ -354,33 +358,38 @@ private void executeEDCTractus(AutoSetupRequest autoSetupRequest, AppActions act private void edcDeployemnt(AutoSetupRequest autoSetupRequest, AutoSetupTriggerEntry trigger, Map edcOutput) { - String json = autoSetupTriggerMapper.fromMaptoStr(extractEDCResultMap(edcOutput)); + + List> extractResultMap = extractEDCResultMap(edcOutput); + String json = autoSetupTriggerMapper.fromMaptoStr(extractResultMap); trigger.setAutosetupResult(json); trigger.setStatus(TriggerStatusEnum.SUCCESS.name()); Customer customer = autoSetupRequest.getCustomer(); + + String connectivityTestStr = edcOutput.get(CONNECTOR_TEST_RESULT); + + boolean isTestConnectivityTestSuccess = connectivityTestStr != null + && connectivityTestStr.contains("consumer and provider"); + + String generateEmailTable = generateEmailTable(extractResultMap); // Send an email Map emailContent = new HashMap<>(); emailContent.put(ORGNAME, customer.getOrganizationName()); - emailContent.putAll(edcOutput); - - - String connectivityTestStr= edcOutput.get(CONNECTOR_TEST_RESULT); - - boolean isTestConnectivityTestSuccess = connectivityTestStr!=null && connectivityTestStr.contains("consumer and provider"); - + emailContent.put(CCEMAIL, technicalEmail); + emailContent.put(TEST_SERVICE_URL, findValueInMap(edcOutput, TEST_SERVICE_URL)); + emailContent.put(CONNECTOR_TEST_RESULT, CONNECTOR_TEST_RESULT); + emailContent.put(CONTENT, generateEmailTable); + if (isTestConnectivityTestSuccess) { emailContent.put(TOEMAIL, customer.getEmail()); - emailContent.put(CCEMAIL, portalEmail); emailManager.sendEmail(emailContent, "EDC Application Activited Successfully", "edc_success_activate.html"); - log.info(EMAIL_SENT_SUCCESSFULLY); - }else { - generateNotification(customer, "EDC Application Deployed Successfully"); + } else { + emailContent.put(TOEMAIL, technicalEmail); + emailManager.sendEmail(emailContent, "EDC Application Deployed Successfully", SUCCESS_HTML_TEMPLATE); } - - + log.info(EMAIL_SENT_SUCCESSFULLY); } private void executeSDEWithEDCTractus(AutoSetupRequest autoSetupRequest, AppActions action, @@ -409,7 +418,10 @@ private void dtDeployment(Customer customer, AppActions action, AutoSetupTrigger dtAppWorkFlow.getWorkFlow(customer, selectedTool, action, inputConfiguration, trigger); - String json = autoSetupTriggerMapper.fromMaptoStr(extractDTResultMap(inputConfiguration)); + List> extractDTResultMap = extractDTResultMap(inputConfiguration); + String generateEmailTable = generateEmailTable(extractDTResultMap); + + String json = autoSetupTriggerMapper.fromMaptoStr(extractDTResultMap); trigger.setAutosetupResult(json); trigger.setStatus(TriggerStatusEnum.SUCCESS.name()); @@ -417,9 +429,9 @@ private void dtDeployment(Customer customer, AppActions action, AutoSetupTrigger // Send an email Map emailContent = new HashMap<>(); emailContent.put(ORGNAME, customer.getOrganizationName()); - emailContent.putAll(inputConfiguration); emailContent.put(TOEMAIL, customer.getEmail()); - emailContent.put(CCEMAIL, portalEmail); + emailContent.put(CCEMAIL, technicalEmail); + emailContent.put(CONTENT, generateEmailTable); emailManager.sendEmail(emailContent, "DT registry Application Activited Successfully", "dt_success_template.html"); @@ -442,53 +454,51 @@ private void sdeDeployment(AutoSetupRequest autoSetupRequest, AppActions action, Map map = sdeWorkFlow.getWorkFlow(autoSetupRequest.getCustomer(), selectedTool, action, inputConfiguration, trigger); + List> extractResultMap = extractResultMap(map); + String generateEmailTable = generateEmailTable(extractResultMap); + + String json = autoSetupTriggerMapper.fromMaptoStr(extractResultMap); + trigger.setAutosetupResult(json); + + String connectivityTestStr = inputConfiguration.get(CONNECTOR_TEST_RESULT); + boolean isTestConnectivityTestSuccess = connectivityTestStr != null + && connectivityTestStr.contains("consumer and provider"); + Map emailContent = new HashMap<>(); - emailContent.put(SDE_FRONTEND_URL, map.get(SDE_FRONTEND_URL)); - emailContent.put(SDE_BACKEND_URL, map.get(SDE_BACKEND_URL)); - emailContent.put(CONNECTOR_TEST_RESULT, map.get(CONNECTOR_TEST_RESULT)); - emailContent.put(TEST_SERVICE_URL, map.get(TEST_SERVICE_URL)); - emailContent.putAll(map); - - String connectivityTestStr= inputConfiguration.get(CONNECTOR_TEST_RESULT); - boolean isTestConnectivityTestSuccess = connectivityTestStr!=null && connectivityTestStr.contains("consumer and provider"); + emailContent.put(ORGNAME, customer.getOrganizationName()); + emailContent.put(CCEMAIL, technicalEmail); + emailContent.put(CONTENT, generateEmailTable); if (manualUpdate || !isTestConnectivityTestSuccess) { - - generateNotification(customer, "SDE Application Deployed Successfully"); + emailContent.put(TOEMAIL, technicalEmail); + emailManager.sendEmail(emailContent, "SDE Application Deployed Successfully", SUCCESS_HTML_TEMPLATE); trigger.setStatus(TriggerStatusEnum.MANUAL_UPDATE_PENDING.name()); - } else { - trigger.setStatus(TriggerStatusEnum.SUCCESS.name()); - // Send an email - emailContent.put(ORGNAME, customer.getOrganizationName()); emailContent.put(TOEMAIL, customer.getEmail()); - emailContent.put(CCEMAIL, portalEmail); + emailContent.put(TEST_SERVICE_URL, findValueInMap(map, TEST_SERVICE_URL)); + emailContent.put(CONNECTOR_TEST_RESULT, CONNECTOR_TEST_RESULT); emailManager.sendEmail(emailContent, "SDE Application Activited Successfully", "success_activate.html"); - log.info(EMAIL_SENT_SUCCESSFULLY); // End of email sending code - } - - String json = autoSetupTriggerMapper.fromMaptoStr(extractResultMap(map)); - - trigger.setAutosetupResult(json); + log.info(EMAIL_SENT_SUCCESSFULLY); } - + @SneakyThrows - private void generateNotification(Customer customer, String emailSubject) { - + private void generateNotification(Customer customer, String emailSubject, String content, String template) { + Map emailContent = new HashMap<>(); emailContent.put(ORGNAME, customer.getOrganizationName()); emailContent.put(TOEMAIL, mailReplytoAddress); - emailContent.put(CCEMAIL, portalEmail); - emailManager.sendEmail(emailContent, emailSubject, "success.html"); + emailContent.put(CCEMAIL, technicalEmail); + emailContent.put(CONTENT, content); + + emailManager.sendEmail(emailContent, emailSubject, template); log.info(EMAIL_SENT_SUCCESSFULLY); } - private void processDeleteTrigger(AutoSetupTriggerEntry trigger, Map inputConfiguration) { if (trigger != null && trigger.getAutosetupRequest() != null) { @@ -536,7 +546,8 @@ private void executeInstallTool(AutoSetupTriggerEntry trigger, Map> extractResultMap(Map outputMap List> processResult = new ArrayList<>(); - Map dft = new ConcurrentHashMap<>(); + Map dft = new LinkedHashMap<>(); dft.put("name", "SDE"); dft.put(SDE_FRONTEND_URL, outputMap.get(SDE_FRONTEND_URL)); dft.put(SDE_BACKEND_URL, outputMap.get(SDE_BACKEND_URL)); + dft.put("storage.media.bucket", findValueInMap(outputMap, "storage.media.bucket")); + dft.put("storage.media.endpoint", findValueInMap(outputMap, "storage.media.endpoint")); + dft.put("storage.media.accessKey", findValueInMap(outputMap, "storage.media.accessKey")); + dft.put("storage.media.secretKey", findValueInMap(outputMap, "storage.media.secretKey")); + processResult.add(dft); processResult.addAll(extractDependantAppResult(outputMap)); @@ -586,8 +602,11 @@ private List> extractDependantAppResult(Map List> processResult = new ArrayList<>(); - Map dt = extractDTResultMap(outputMap).get(0); - processResult.add(dt); + //commentting this beause of dt is get localy managed + if (managedDTRegistryLocal) { + Map dt = extractDTResultMap(outputMap).get(0); + processResult.add(dt); + } Map edc = extractEDCResultMap(outputMap).get(0); processResult.add(edc); @@ -599,7 +618,7 @@ private List> extractEDCResultMap(Map output List> processResult = new ArrayList<>(); - Map edc = new ConcurrentHashMap<>(); + Map edc = new LinkedHashMap<>(); edc.put("name", "EDC"); edc.put("controlPlaneEndpoint", outputMap.get("controlPlaneEndpoint")); edc.put("controlPlaneDataEndpoint", outputMap.get("controlPlaneDataEndpoint")); @@ -623,15 +642,29 @@ private List> extractDTResultMap(Map outputM List> processResult = new ArrayList<>(); - Map dt = new ConcurrentHashMap<>(); + Map dt = new LinkedHashMap<>(); dt.put("name", "DT"); - dt.put("dtregistryUrl", outputMap.get("dtregistryUrl")); + dt.put("dtregistryUrlWithURI", outputMap.get("dtregistryUrlWithURI")); dt.put("idpClientId", outputMap.get("idpClientId")); processResult.add(dt); return processResult; } + public String generateEmailTable(List> content) { + StringBuilder sb = new StringBuilder(); + sb.append(""); + content.forEach(element -> { + sb.append(""); + element.entrySet().forEach(entry -> { + if (!"name".equals(entry.getKey())) + sb.append(""); + }); + }); + sb.append("
" + element.get("name") + "
" + entry.getKey() + "" + entry.getValue() + "
"); + return sb.toString(); + } + public boolean checkNamespaceisExist(String targetNamespace) { String namespacesResult = kubeAppManageProxy.checkNamespace(targetCluster, targetNamespace); diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java b/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java index 4e2d3a0d..f3d6ded3 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/DTAppWorkFlow.java @@ -34,9 +34,11 @@ import org.springframework.stereotype.Component; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Component @RequiredArgsConstructor +@Slf4j public class DTAppWorkFlow { private final DTRegistryManager dtregistryManager; @@ -52,8 +54,13 @@ public Map getWorkFlow(Customer customerDetails, SelectedTools t dtregistryManager.managePackage(customerDetails, workflowAction, tool, inputConfiguration, triger)); if (!manualUpdate) { - dtregistryManager.dtRegistryRegistrationInEDC(customerDetails, tool, - inputConfiguration, triger); + try { + dtregistryManager.dtRegistryRegistrationInEDC(customerDetails, tool, inputConfiguration, triger); + } catch (Exception e) { + String errorMsg = "Unable to complete asset creation in managed DT registry, autosetup process not aborting " + + e.getMessage(); + log.error(errorMsg); + } } return inputConfiguration; diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java b/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java index 15a0223b..b3ed7f1b 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/SDEAppWorkFlow.java @@ -27,9 +27,12 @@ import org.eclipse.tractusx.autosetup.constant.AppActions; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; import org.eclipse.tractusx.autosetup.manager.AppDeleteManager; +import org.eclipse.tractusx.autosetup.manager.AutomaticStorageMediaSetupManager; import org.eclipse.tractusx.autosetup.manager.SDEManager; +import org.eclipse.tractusx.autosetup.model.AutoSetupRequest; import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.model.SelectedTools; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import lombok.RequiredArgsConstructor; @@ -39,12 +42,20 @@ public class SDEAppWorkFlow { private final SDEManager sdeManager; + private final AutomaticStorageMediaSetupManager automaticStorageMediaSetupManager; private final AppDeleteManager appDeleteManager; + @Value("${automatic.storage.media:true}") + private boolean manualStorageMedia; + public Map getWorkFlow(Customer customerDetails, SelectedTools tool, AppActions workflowAction, Map inputConfiguration, AutoSetupTriggerEntry triger) { + if (manualStorageMedia) + automaticStorageMediaSetupManager.createStorageMedia(customerDetails, tool, inputConfiguration, + workflowAction, triger); + inputConfiguration .putAll(sdeManager.managePackage(customerDetails, workflowAction, tool, inputConfiguration, triger)); @@ -52,9 +63,14 @@ public Map getWorkFlow(Customer customerDetails, SelectedTools t } public void deletePackageWorkFlow(SelectedTools tool, Map inputConfiguration, - AutoSetupTriggerEntry triger) { + AutoSetupTriggerEntry triger, AutoSetupRequest orgRequest) { appDeleteManager.deletePackage(SDE, tool, inputConfiguration, triger); + if (manualStorageMedia) { + String tenantId = inputConfiguration.get("targetNamespace"); + automaticStorageMediaSetupManager.deleteStorageMedia(tenantId, orgRequest.getCustomer().getEmail()); + } + } } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java new file mode 100644 index 00000000..d58db5f4 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/JsonObjectProcessingUtility.java @@ -0,0 +1,50 @@ +/******************************************************************************** + * Copyright (c) 2023 T-Systems International GmbH + * Copyright (c) 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 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.utility; + +import com.fasterxml.jackson.databind.JsonNode; + +import lombok.SneakyThrows; + + +public class JsonObjectProcessingUtility { + + private JsonObjectProcessingUtility() {} + + @SneakyThrows + public static String getValueFromJsonNode(JsonNode jsonNode, String propertyId) { + if (jsonNode != null && jsonNode.get(propertyId) != null) + return jsonNode.get(propertyId).asText(); + else + return ""; + } + + + @SneakyThrows + public static JsonNode getArrayNodeFromJsonNode(JsonNode jsonnode, String propertyId) { + if (jsonnode != null && jsonnode.get(propertyId) != null) + return jsonnode.get(propertyId); + else + return null; + } + + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java new file mode 100644 index 00000000..c0855967 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/KeyCloakTokenProxyUtitlity.java @@ -0,0 +1,55 @@ +/******************************************************************************** + * Copyright (c) 2023 T-Systems International GmbH + * Copyright (c) 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 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.utility; + +import java.net.URI; + +import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; +import org.springframework.stereotype.Service; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; + +@Service +@RequiredArgsConstructor +public class KeyCloakTokenProxyUtitlity { + + private final PortalIntegrationProxy portalIntegrationProxy; + + @SneakyThrows + public String getKeycloakToken(String clientId, String clientSecret, URI tokenURI) { + + MultiValueMap body = new LinkedMultiValueMap<>(); + body.add("grant_type", "client_credentials"); + body.add("client_id", clientId); + body.add("client_secret", clientSecret); + var resultBody = portalIntegrationProxy.readAuthToken(tokenURI, body); + + if (resultBody != null) { + return resultBody.getAccessToken(); + } + return null; + + } + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/LogUtil.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/LogUtil.java index 02ba15a9..bb89ceb8 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/utility/LogUtil.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/LogUtil.java @@ -30,6 +30,14 @@ private LogUtil() { public static String encode(String message) { return StringEscapeUtils.unescapeHtml4(StringEscapeUtils.escapeJava(message)); } + + public static String getCause(Exception ex) { + Throwable cause=ex.getCause(); + if(cause!=null) { + return cause.toString(); + } + return ""; + } } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/utility/ValueReplacerUtility.java b/src/main/java/org/eclipse/tractusx/autosetup/utility/ValueReplacerUtility.java new file mode 100644 index 00000000..9b1a3b20 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/utility/ValueReplacerUtility.java @@ -0,0 +1,69 @@ +/******************************************************************************** + * Copyright (c) 2023 T-Systems International GmbH + * Copyright (c) 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 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.utility; + +import java.io.InputStream; +import java.util.Map; + +import org.apache.commons.text.StringSubstitutor; +import org.eclipse.tractusx.autosetup.exception.ServiceException; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.MappingJsonFactory; + +import lombok.SneakyThrows; + +@Component +public class ValueReplacerUtility { + + @SneakyThrows + public String getRequestFile(String schemaFile) { + JsonParser createParser = null; + String schema = null; + try { + MappingJsonFactory jf = new MappingJsonFactory(); + InputStream jsonFile = this.getClass().getResourceAsStream(schemaFile); + + if (jsonFile == null) { + // this is how we load file within editor (eg eclipse) + jsonFile = this.getClass().getClassLoader().getResourceAsStream(schemaFile); + } + createParser = jf.createParser(jsonFile); + schema = createParser.readValueAsTree().toString(); + if (schema == null) { + throw new ServiceException("The schema for EDC asset creation is null " + schemaFile); + } + + return schema; + } finally { + if (createParser != null) + createParser.close(); + } + } + + @SneakyThrows + public String valueReplacer(String requestTemplatePath, Map inputData) { + StringSubstitutor stringSubstitutor1 = new StringSubstitutor(inputData); + return stringSubstitutor1.replace(getRequestFile(requestTemplatePath)); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8719d698..ebbc164c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -129,4 +129,11 @@ edc.ssi.authorityId=${edc_ssi_authorityId} #Flag to make optional use of managed DT regitry, if value not set default value is true -managed.dt-registry=true \ No newline at end of file +managed.dt-registry=true +managed.dt-registry.local=true + +#automatic storage Media for minio +automatic.storage.media=true +automatic.storage.media.minio.endpoint=${minio_endpoint} +automatic.storage.media.minio.accessKey=${minio_accessKey} +automatic.storage.media.minio.secretKey=${minio_secretKey} \ No newline at end of file diff --git a/src/main/resources/flyway/V9__update_app_version.sql b/src/main/resources/flyway/V9__update_app_version.sql new file mode 100644 index 00000000..8b90c774 --- /dev/null +++ b/src/main/resources/flyway/V9__update_app_version.sql @@ -0,0 +1,316 @@ +/******************************************************************************** + * Copyright (c) 2023 T-Systems International GmbH + * Copyright (c) 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 + ********************************************************************************/ + +update app_tbl set expected_input_data='{ + "sdepostgresql":{ + "enabled":true, + "primary":{ + "persistence":{ + "size":"1Gi" + } + }, + "persistence":{ + "size":"1Gi" + }, + "auth":{ + "postgresPassword":"$\{postgresPassword\}", + "password":"$\{postgresPassword\}", + "username":"$\{username\}", + "database":"$\{database\}" + } + }, + "backend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdebackend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties": "server.port=8080 + + spring.main.allow-bean-definition-overriding=true + + spring.servlet.multipart.enabled=true + + spring.servlet.multipart.file-size-threshold=2KB + + spring.servlet.multipart.max-file-size=200MB + + spring.servlet.multipart.max-request-size=215MB + + server.servlet.context-path=/backend/api + + spring.flyway.baseline-on-migrate=true + + spring.flyway.locations=classpath:/flyway + + file.upload-dir=./temp/ + + logging.level.org.apache.http=info + + logging.level.root=info + + spring.datasource.driver-class-name=org.postgresql.Driver + + spring.jpa.open-in-view=false + + digital-twins.hostname=$\{dtregistryUrl\} + + digital-twins.api=$\{dtregistryURI\} + + digital-twins.authentication.url=$\{sde.digital-twins.authentication.url\} + + digital-twins.authentication.clientId=$\{digital-twins.authentication.clientId\} + + digital-twins.authentication.clientSecret=$\{digital-twins.authentication.clientSecret\} + + digital-twins.authentication.grantType=client_credentials + + dft.hostname=$\{sdeBackEndUrl\} + + dft.apiKeyHeader=$\{sdeBackEndApiKeyHeader\} + + dft.apiKey=$\{sdeBackEndApiKey\} + + manufacturerId=$\{manufacturerId\} + + edc.hostname=$\{controlPlaneEndpoint\} + + edc.managementpath=/data + + edc.managementpath.apiversion=/v2 + + edc.dsp.endpointpath=/api/v1/dsp + + edc.dataplane.endpointpath=/api/public + + edc.apiKeyHeader=$\{edcApiKey\} + + edc.apiKey=$\{edcApiKeyValue\} + + edc.consumer.hostname=$\{controlPlaneEndpoint\} + + edc.consumer.apikeyheader=$\{edcApiKey\} + + edc.consumer.apikey=$\{edcApiKeyValue\} + + edc.consumer.managementpath=/data + + edc.consumer.managementpath.apiversion=/v2 + + edc.consumer.protocol.path=/api/v1/dsp + + keycloak.clientid=$\{sdebackendkeycloakclientid\} + + spring.security.oauth2.resourceserver.jwt.issuer-uri=$\{sde.resourceServerIssuer\} + + springdoc.api-docs.path=/api-docs + + springdoc.swagger-ui.oauth.client-id=$\{sdebackendkeycloakclientid\} + + partner.pool.hostname=$\{sde.partner.pool.hostname\} + + partner.pool.authentication.url=$\{sde.partner.pool.authentication.url\} + + partner.pool.clientId=$\{sde.partner.pool.clientId\} + + partner.pool.clientSecret=$\{sde.partner.pool.clientSecret\} + + partner.pool.grantType=client_credentials + + portal.backend.hostname=$\{sde.portal.backend.hostname\} + + portal.backend.authentication.url=$\{sde.portal.backend.authentication.url\} + + portal.backend.clientId=$\{sde.portal.backend.clientId\} + + portal.backend.clientSecret=$\{sde.portal.backend.clientSecret\} + + portal.backend.grantType=client_credentials + + bpndiscovery.hostname=$\{sde.bpndiscovery.hostname\} + + discovery.authentication.url=$\{sde.discovery.authentication.url\} + + discovery.clientId=$\{sde.discovery.clientId\} + + discovery.clientSecret=$\{sde.discovery.clientSecret\} + + discovery.grantType=client_credentials + + mail.smtp.username=$\{emailUsername\} + + mail.smtp.password=$\{emailPassword\} + + mail.smtp.host=$\{emailHost\} + + mail.smtp.port=$\{emailPort\} + + mail.to.address=$\{emailTo\} + + mail.cc.address=$\{emailCC\} + + mail.from.address=$\{emailFrom\} + + mail.replyto.address=$\{emailReply\} + + mail.smtp.starttls.enable=true + + mail.smtp.auth=true + + sftp.host=$\{sftpHost\} + + sftp.port=$\{sftpPort\} + + sftp.username=$\{sftpUsername\} + + sftp.password=$\{sftpPassword\} + + sftp.accessKey=$\{sftpKey\} + + sftp.location.tobeprocessed=/ToBeProcessed + + sftp.location.inprogress=/InProgress + + sftp.location.success=/Success + + sftp.location.partialsucess=/PartialSuccess + + sftp.location.failed=/Failed + + retriever.name=minio + + minio.endpoint=$\{storage.media.endpoint\} + + minio.access-key=$\{storage.media.accessKey\} + + minio.secret-key=$\{storage.media.secretKey\} + + minio.bucket-name=$\{storage.media.bucket\} + + minio.location.tobeprocessed= + + minio.location.inprogress=/InProgress + + minio.location.success=/Success + + minio.location.partialsucess=/PartialSuccess + + minio.location.failed=/Failed" + } + }, + "frontend": { + "ingresses":[ + { + "enabled":true, + "hostname":"$\{dnsName\}", + "annotations":{ + "kubernetes.io/tls-acme": "true" + }, + "className":"nginx", + "endpoints":[ + "default" + ], + "tls":{ + "enabled":true, + "secretName":"sdefrontend" + }, + "certManager":{ + "clusterIssuer":"letsencrypt-prod" + } + } + ], + "configuration":{ + "properties":"REACT_APP_API_URL=$\{sdeBackEndUrl\} + + REACT_APP_KEYCLOAK_URL=$\{sde.keycloak.auth\} + + REACT_APP_KEYCLOAK_REALM=$\{sde.keycloak.realm\} + + REACT_APP_CLIENT_ID=$\{sdefrontendkeycloakclientid\} + + REACT_APP_DEFAULT_COMPANY_BPN=$\{bpnNumber\} + + REACT_APP_FILESIZE=268435456" + } + } +}', package_identifier='tx-sde-charts/sde' ,package_version='1.0.1' where app_name='SDE'; + + +update app_tbl set expected_input_data= '{ + "enablePostgres": true, + "enableKeycloak": false, + "postgresql": { + "auth": { + "password":"$\{rgdbpass\}", + "postgresPassword":"$\{rgdbpass\}", + "username":"$\{rgusername\}", + "database":"$\{rgdatabase\}" + }, + "primary": + { + "persistence":{ + "size" :"1Gi" + } + }, + "persistence": { + "size" :"1Gi" + } + }, + "registry": { + "host": "$\{dnsName\}", + "idpClientId" : "$\{idpClientId\}", + "idpIssuerUri": "$\{idpIssuerUri\}", + "tenantId" : "$\{bpnNumber\}", + "authentication": $\{dtNeedExternalAccess\}, + "ingress": { + "enabled": $\{dtNeedExternalAccess\}, + "hostname": "$\{dnsName\}", + "annotations": { + "cert-manager.io/cluster-issuer": letsencrypt-prod, + "nginx.ingress.kubernetes.io/cors-allow-credentials": "true", + "nginx.ingress.kubernetes.io/enable-cors": "true", + "nginx.ingress.kubernetes.io/rewrite-target": /$2, + "nginx.ingress.kubernetes.io/use-regex": "true", + "nginx.ingress.kubernetes.io/x-forwarded-prefix": /$\{dtregistryUrlPrefix\} + }, + "urlPrefix": /$\{dtregistryUrlPrefix\}, + "className": "nginx", + "tls": $\{dtNeedExternalAccess\} + } + } +}', package_version='0.3.27' where app_name='DT_REGISTRY'; + +update app_tbl set expected_input_data= replace(replace(expected_input_data,'\{','{'),'\}','}'), required_yaml_configuration=replace(replace(required_yaml_configuration,'\{','{'),'\}','}'); \ No newline at end of file diff --git a/src/main/resources/edc-request-template/asset-request-filter.json b/src/main/resources/request-template/asset-request-filter.json similarity index 100% rename from src/main/resources/edc-request-template/asset-request-filter.json rename to src/main/resources/request-template/asset-request-filter.json diff --git a/src/main/resources/edc-request-template/asset.json b/src/main/resources/request-template/asset.json similarity index 96% rename from src/main/resources/edc-request-template/asset.json rename to src/main/resources/request-template/asset.json index 04b39933..10ac8a60 100644 --- a/src/main/resources/edc-request-template/asset.json +++ b/src/main/resources/request-template/asset.json @@ -26,7 +26,7 @@ }, "edc:dataAddress": { "edc:type": "HttpData", - "edc:baseUrl": "${dtregistryUrl}", + "edc:baseUrl": "${dtregistryUrlWithURI}", "oauth2:tokenUrl": "${idpIssuerUri}", "oauth2:clientId": "${keycloakAuthenticationClientId}", "oauth2:clientSecretKey": "client-secret", diff --git a/src/main/resources/edc-request-template/contract-defination.json b/src/main/resources/request-template/contract-defination.json similarity index 100% rename from src/main/resources/edc-request-template/contract-defination.json rename to src/main/resources/request-template/contract-defination.json diff --git a/src/main/resources/edc-request-template/policy.json b/src/main/resources/request-template/policy.json similarity index 100% rename from src/main/resources/edc-request-template/policy.json rename to src/main/resources/request-template/policy.json diff --git a/src/main/resources/request-template/s3-policy-template.json b/src/main/resources/request-template/s3-policy-template.json new file mode 100644 index 00000000..b972fbfc --- /dev/null +++ b/src/main/resources/request-template/s3-policy-template.json @@ -0,0 +1,31 @@ +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Deny", + "Action": [ + "s3:CreateBucket", + "s3:DeleteBucket", + "s3:ForceDeleteBucket" + ], + "Resource": [ + "arn:aws:s3:::${bucket}/*", + "arn:aws:s3:::${bucket}*" + ] + }, + { + "Effect": "Allow", + "Action": [ + "s3:Put*", + "s3:DeleteObject", + "s3:DeleteObject*", + "s3:Get*", + "s3:List*" + ], + "Resource": [ + "arn:aws:s3:::${bucket}*", + "arn:aws:s3:::${bucket}/*" + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/templates/dt_success_template.html b/src/main/resources/templates/dt_success_template.html index 1867ce9e..7aec4aed 100644 --- a/src/main/resources/templates/dt_success_template.html +++ b/src/main/resources/templates/dt_success_template.html @@ -36,8 +36,7 @@

The DT registry tool successfully activated for your use.

Please find your DT registry details below:

-

DT registry URL : ${dtregistryUrl}

-

App Id : ${idpClientId}

+ ${content}

Kind Regards
Catina-X

diff --git a/src/main/resources/templates/edc_success_activate.html b/src/main/resources/templates/edc_success_activate.html index ac3c8404..0fef4055 100644 --- a/src/main/resources/templates/edc_success_activate.html +++ b/src/main/resources/templates/edc_success_activate.html @@ -34,15 +34,9 @@

Hello ${orgname},

The EDC tool successfully activated for your use.

- -

Please find your connector details below:

-

Control Plane URL : ${controlPlaneEndpoint}

-

Control Plane Data URL : ${controlPlaneDataEndpoint}

-

EDC ApiKey : ${edcApiKey}

-

EDC ApiKeyValue : ${edcApiKeyValue}

-

Data Plane URL : ${dataPlanePublicEndpoint}

+ ${content}

Your connector status through connector test service: ${connectorTestResult}, check status again here

- +

Kind Regards
Catina-X

diff --git a/src/main/resources/templates/success.html b/src/main/resources/templates/success.html index 93eb24c1..ba2ccf92 100644 --- a/src/main/resources/templates/success.html +++ b/src/main/resources/templates/success.html @@ -31,9 +31,9 @@

Hello Team,

-

The Subcribe application deployed successfully for ${orgname}.

+

The subcribe application deployed successfully for ${orgname}.

please perform manually verification to activate application for customer use.

- + ${content}

Kind Regards
Catina-X

diff --git a/src/main/resources/templates/success_activate.html b/src/main/resources/templates/success_activate.html index 3d3b56b6..dc3651cf 100644 --- a/src/main/resources/templates/success_activate.html +++ b/src/main/resources/templates/success_activate.html @@ -32,17 +32,7 @@

Hello ${orgname},

The SDE successfully activated for your use.

-

Please click here to start using it.

- -

DT Registry Details

-

DT registry URL : ${dtregistryUrl}

-

App Id : ${idpClientId}

- -

EDC Connector Details

-

Control Plane URL : ${controlPlaneEndpoint}

-

Control Plane Data URL : ${controlPlaneDataEndpoint}

-

EDC ApiKey : ${edcApiKey}

-

EDC ApiKeyValue : ${edcApiKeyValue}

+ ${content}

Your connector status through connector test service: ${connectorTestResult}, check status again here

Note: You need to use your own organization login credential to login SDE tool.

diff --git a/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java b/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java index 64ebd112..1c7a9562 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/manager/ConnectorRegistrationManagerTest.java @@ -32,10 +32,12 @@ import org.apache.commons.codec.Resources; import org.eclipse.tractusx.autosetup.constant.ToolType; +import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.model.SelectedTools; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; import org.eclipse.tractusx.autosetup.utility.Certutil; +import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.mockito.InjectMocks; @@ -61,6 +63,12 @@ class ConnectorRegistrationManagerTest { @InjectMocks private ConnectorRegistrationManager connectorRegistrationManager; + + @InjectMocks + private AutoSetupTriggerEntry triger; + + @Mock + private KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; @Test void createClient() throws IOException { @@ -85,7 +93,7 @@ void createClient() throws IOException { when(portalIntegrationProxy.manageConnector((URI)any(), any(), any())).thenReturn("CONNECTOR123"); mockInputMap.put("selfsigncertificate", Certutil.getAsString(cert)); - mockInputMap = connectorRegistrationManager.registerConnector(customer, selectedTools, mockInputMap, null); + mockInputMap = connectorRegistrationManager.registerConnector(customer, selectedTools, mockInputMap, triger); assertEquals(3, mockInputMap.size()); assertEquals("ACTIVE", mockInputMap.get("connectorstatus")); } catch (CertificateException e) { diff --git a/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java b/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java index d0a4c8a5..e5bdabe2 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/manager/SDEManagerTest.java @@ -25,8 +25,10 @@ import java.util.Map; import org.eclipse.tractusx.autosetup.constant.AppActions; +import org.eclipse.tractusx.autosetup.constant.EmailConfigurationProperty; import org.eclipse.tractusx.autosetup.constant.SDEConfigurationProperty; import org.eclipse.tractusx.autosetup.constant.ToolType; +import org.eclipse.tractusx.autosetup.model.Customer; import org.eclipse.tractusx.autosetup.model.SelectedTools; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -53,17 +55,27 @@ class SDEManagerTest { @Mock private SDEConfigurationProperty sDEConfigurationProperty; - + + @Mock + private EmailConfigurationProperty emailConfigurationProperty; + @Test void managePackage() { + Customer customerDetails = Customer.builder() + .organizationName("Test") + .contactNumber("Test") + .city("DE") + .email("test@test.com") + .build(); + SelectedTools selectedTools = SelectedTools.builder().tool(ToolType.SDE_WITH_EDC_TRACTUS).label("SDE").build(); Map mockInputMap = new HashMap<>(); mockInputMap.put("dnsName", "test"); mockInputMap.put("dnsNameURLProtocol", "https"); - Map resultMap = sdeManager.managePackage(null, AppActions.CREATE, selectedTools, + Map resultMap = sdeManager.managePackage(customerDetails, AppActions.CREATE, selectedTools, mockInputMap, null); - assertEquals(30, resultMap.size()); + assertEquals(43, resultMap.size()); assertEquals("test", mockInputMap.get("dnsName")); } } \ No newline at end of file diff --git a/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java b/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java index f5116bc5..7af7b98a 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/service/AutoSetupOrchitestratorServiceTest.java @@ -25,6 +25,7 @@ import org.eclipse.tractusx.autosetup.mapper.AutoSetupRequestMapper; import org.eclipse.tractusx.autosetup.model.AutoSetupRequest; import org.eclipse.tractusx.autosetup.portal.proxy.PortalIntegrationProxy; +import org.eclipse.tractusx.autosetup.utility.KeyCloakTokenProxyUtitlity; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.springframework.beans.factory.annotation.Autowired; @@ -49,13 +50,15 @@ class AutoSetupOrchitestratorServiceTest { @MockBean private PortalIntegrationProxy portalIntegrationProxy; - @MockBean private AutoSetupRequestMapper customerDetailsMapper; @MockBean private KubeAppManageProxy kubeAppManageProxy; - + + @MockBean + private KeyCloakTokenProxyUtitlity keyCloakTokenProxyUtitlity; + @Test void createPackage() { diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties index f759536d..3bee9b07 100644 --- a/src/test/resources/application-test.properties +++ b/src/test/resources/application-test.properties @@ -88,7 +88,8 @@ mail.smtp.starttls.enable=true mail.smtp.auth=true manual.update=true -manual-connector-registration=true +manual.connector.registration=true +automatic.storage.media=true #Dyanamic property for SDE becuase enviroment wise those will get change like INT, Beta sde.resource-server-issuer=test @@ -122,3 +123,7 @@ sde.discovery-grantType=test edc.miwUrl=test edc.ssi.authorityId=test +automatic.storage.media.minio.endpoint=test +automatic.storage.media.minio.accessKey=test +automatic.storage.media.minio.secretKey=test +