diff --git a/charts/ssi-credential-issuer/README.md b/charts/ssi-credential-issuer/README.md index 6e2c8747..59ddc4ee 100644 --- a/charts/ssi-credential-issuer/README.md +++ b/charts/ssi-credential-issuer/README.md @@ -76,10 +76,11 @@ dependencies: | migrations.image.pullSecrets | list | `[]` | | | migrations.imagePullPolicy | string | `"IfNotPresent"` | | | migrations.resources | object | `{"limits":{"cpu":"45m","memory":"200M"},"requests":{"cpu":"15m","memory":"200M"}}` | We recommend to review the default resource limits as this should a conscious choice. | -| migrations.seeding.testDataEnvironments | string | `""` | | -| migrations.seeding.testDataPaths | string | `"Seeder/Data"` | | +| migrations.seeding.seedTestData | object | `{"useDefault":false,"useOwnConfigMap":{"configMap":"","filename":""}}` | Option to seed testdata | +| migrations.seeding.seedTestData.useDefault | bool | `false` | If set to true the data configured in the config map 'configmap-seeding-testdata.yaml' will be taken to insert the default test data | +| migrations.seeding.seedTestData.useOwnConfigMap.configMap | string | `""` | ConfigMap containing json files for the tables to seed, e.g. use_cases.json, verified_credential_external_type_detail_versions.test.json, etc. | +| migrations.seeding.seedTestData.useOwnConfigMap.filename | string | `""` | Filename identifying the test data files e.g. for companies.test.json the value would be "test" | | migrations.logging.default | string | `"Information"` | | -| migrations.processIdentity.identityId | string | `"ac1cf001-7fbc-1f2f-817f-bce058020006"` | | | processesworker.name | string | `"processesworker"` | | | processesworker.image.name | string | `"docker.io/tractusx/ssi-credential-issuer-processes-worker"` | | | processesworker.image.tag | string | `""` | | diff --git a/charts/ssi-credential-issuer/templates/configmap-seeding-testdata.yaml b/charts/ssi-credential-issuer/templates/configmap-seeding-testdata.yaml new file mode 100644 index 00000000..151389eb --- /dev/null +++ b/charts/ssi-credential-issuer/templates/configmap-seeding-testdata.yaml @@ -0,0 +1,68 @@ +{{- /* +* Copyright (c) 2024 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 +*/}} + +{{- if .Values.migrations.seeding.seedTestData.useDefault -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "issuer.fullname" . }}-default-testdata + namespace: {{ .Release.Namespace }} +data: + use_cases.defaulttest.json: |- + [ + { + "id": "1aacde78-35ec-4df3-ba1e-f988cddcbbd9", + "name": "None", + "shortname": "None" + } + ] + verified_credential_external_type_detail_versions.defaulttest.json: |- + [ + { + "id": "d0f05b79-792c-4cb8-9b8d-6e476ac2e926", + "verified_credential_external_type_id": 2, + "version": "0.0", + "template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_PCF.pdf", + "valid_from": "2023-01-01 00:00:00.000000 +00:00", + "expiry": "2023-12-31 00:00:00.000000 +00:00" + }, + { + "id": "2d17a933-f65f-49cd-84a9-cff299a79f85", + "verified_credential_external_type_id": 11, + "version": "1.0", + "template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/example.pdf", + "valid_from": "2024-10-16 00:00:00.000000 +00:00", + "expiry": "2025-10-16 00:00:00.000000 +00:00" + } + ] + verified_credential_type_assigned_external_types.defaulttest.json: |- + [ + { + "verified_credential_external_type_id": 11, + "verified_credential_type_id": 11 + } + ] + verified_credential_type_assigned_use_cases.defaulttest.json: |- + [ + { + "verified_credential_type_id": 11, + "use_case_id": "1aacde78-35ec-4df3-ba1e-f988cddcbbd9" + } + ] +{{- end -}} diff --git a/charts/ssi-credential-issuer/templates/job-issuer-migrations.yaml b/charts/ssi-credential-issuer/templates/job-issuer-migrations.yaml index 6d462739..d7750636 100644 --- a/charts/ssi-credential-issuer/templates/job-issuer-migrations.yaml +++ b/charts/ssi-credential-issuer/templates/job-issuer-migrations.yaml @@ -67,17 +67,60 @@ spec: - name: "CONNECTIONSTRINGS__ISSUERDB" value: "Server={{ .Values.externalDatabase.host }};Database={{ .Values.externalDatabase.database }};Port={{ .Values.externalDatabase.port }};User Id={{ .Values.externalDatabase.username }};Password=$(ISSUER_PASSWORD);Ssl Mode={{ .Values.dbConnection.sslMode }};" {{- end }} - - name: "SEEDING__TESTDATAENVIRONMENTS__0" - value: "{{ .Values.migrations.seeding.testDataEnvironments }}" - name: "SEEDING__DATAPATHS__0" - value: "{{ .Values.migrations.seeding.testDataPaths }}" + value: "Seeder/Data" + {{- if (.Values.migrations.seeding.seedTestData.useDefault) }} + - name: "SEEDING__DATAPATHS__1" + value: "Seeder/Data/import/default-test-data" + - name: "SEEDING__TESTDATAENVIRONMENTS__1" + value: "defaulttest" + {{- end }} + {{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }} + {{- if (.Values.migrations.seeding.seedTestData.useDefault) }} + - name: "SEEDING__DATAPATHS__2" + value: "Seeder/Data/import/custom-test-data" + - name: "SEEDING__TESTDATAENVIRONMENTS__2" + value: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.filename }}" + {{- else }} + - name: "SEEDING__DATAPATHS__1" + value: "Seeder/Data/import/custom-test-data" + - name: "SEEDING__TESTDATAENVIRONMENTS__1" + value: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.filename }}" + {{- end }} + {{- end }} - name: "SERILOG__MINIMUMLEVEL__Default" value: "{{ .Values.migrations.logging.default }}" - name: "PROCESSIDENTITY__IDENTITYID" - value: "{{ .Values.migrations.processIdentity.identityId }}" + value: "ac1cf001-7fbc-1f2f-817f-bce058020006" ports: - name: http containerPort: {{ .Values.portContainer }} protocol: TCP resources: {{- toYaml .Values.migrations.resources | nindent 10 }} + {{- if or (.Values.migrations.seeding.seedTestData.useDefault) (and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename)) }} + volumeMounts: + {{- if (.Values.migrations.seeding.seedTestData.useDefault) }} + - name: test-data-default + mountPath: /migrations/Seeder/Data/import/default-test-data + {{- end }} + {{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }} + - name: test-data-custom + mountPath: /migrations/Seeder/Data/import/custom-test-data + {{- end }} + {{- end }} + {{- if or (.Values.migrations.seeding.seedTestData.useDefault) (and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename)) }} + volumes: + {{- if (.Values.migrations.seeding.seedTestData.useDefault) }} + - name: test-data-default + configMap: + name: "{{ include "issuer.fullname" . }}-default-testdata" + optional: true + {{- end }} + {{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }} + - name: test-data-custom + configMap: + name: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap }}" + optional: true + {{- end }} + {{- end }} diff --git a/charts/ssi-credential-issuer/values.yaml b/charts/ssi-credential-issuer/values.yaml index 62c90f23..6e29bfe1 100644 --- a/charts/ssi-credential-issuer/values.yaml +++ b/charts/ssi-credential-issuer/values.yaml @@ -87,12 +87,17 @@ migrations: cpu: 45m memory: 200M seeding: - testDataEnvironments: "" - testDataPaths: "Seeder/Data" + # -- Option to seed testdata + seedTestData: + # -- If set to true the data configured in the config map 'configmap-seeding-testdata.yaml' will be taken to insert the default test data + useDefault: false + useOwnConfigMap: + # -- ConfigMap containing json files for the tables to seed, e.g. use_cases.json, verified_credential_external_type_detail_versions.test.json, etc. + configMap: "" + # -- Filename identifying the test data files e.g. for companies.test.json the value would be "test" + filename: "" logging: default: "Information" - processIdentity: - identityId: ac1cf001-7fbc-1f2f-817f-bce058020006 processesworker: name: "processesworker" diff --git a/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/use_cases.consortia.json b/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/use_cases.consortia.json deleted file mode 100644 index c62ba180..00000000 --- a/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/use_cases.consortia.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "id": "1aacde78-35ec-4df3-ba1e-f988cddcbbd9", - "name": "None", - "shortname": "None" - } -] \ No newline at end of file diff --git a/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_external_type_detail_versions.consortia.json b/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_external_type_detail_versions.consortia.json deleted file mode 100644 index c5700a2f..00000000 --- a/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_external_type_detail_versions.consortia.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "id": "d0f05b79-792c-4cb8-9b8d-6e476ac2e926", - "verified_credential_external_type_id": 2, - "version": "0.0", - "template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/231016_Catena-X_Use_Case_Framework_PCF.pdf", - "valid_from": "2023-01-01 00:00:00.000000 +00:00", - "expiry": "2023-12-31 00:00:00.000000 +00:00" - }, - { - "id": "2d17a933-f65f-49cd-84a9-cff299a79f85", - "verified_credential_external_type_id": 11, - "version": "1.0", - "template": "https://catena-x.net/fileadmin/user_upload/04_Einfuehren_und_umsetzen/Governance_Framework/example.pdf", - "valid_from": "2024-10-16 00:00:00.000000 +00:00", - "expiry": "2025-10-16 00:00:00.000000 +00:00" - } -] diff --git a/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_type_assigned_external_types.consortia.json b/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_type_assigned_external_types.consortia.json deleted file mode 100644 index 45799aaa..00000000 --- a/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_type_assigned_external_types.consortia.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "verified_credential_external_type_id": 11, - "verified_credential_type_id": 11 - } -] diff --git a/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_type_assigned_use_cases.consortia.json b/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_type_assigned_use_cases.consortia.json deleted file mode 100644 index 6eac641d..00000000 --- a/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_type_assigned_use_cases.consortia.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "verified_credential_type_id": 11, - "use_case_id": "1aacde78-35ec-4df3-ba1e-f988cddcbbd9" - } -] diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_detail_assigned_documents.test.json b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_detail_assigned_documents.unittest.json similarity index 100% rename from tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_detail_assigned_documents.test.json rename to tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_detail_assigned_documents.unittest.json diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_details.test.json b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_details.unittest.json similarity index 100% rename from tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_details.test.json rename to tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_details.unittest.json diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_process_datas.test.json b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_process_datas.unittest.json similarity index 100% rename from tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_process_datas.test.json rename to tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/company_ssi_process_datas.unittest.json diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/documents.test.json b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/documents.unittest.json similarity index 100% rename from tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/documents.test.json rename to tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/documents.unittest.json diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/process_steps.test.json b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/process_steps.unittest.json similarity index 100% rename from tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/process_steps.test.json rename to tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/process_steps.unittest.json diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/processes.test.json b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/processes.unittest.json similarity index 100% rename from tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/processes.test.json rename to tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/processes.unittest.json diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_external_type_detail_versions.test.json b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_external_type_detail_versions.unittest.json similarity index 100% rename from tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_external_type_detail_versions.test.json rename to tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_external_type_detail_versions.unittest.json diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_type_assigned_kinds.test.json b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_type_assigned_kinds.test.json deleted file mode 100644 index 190509de..00000000 --- a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_type_assigned_kinds.test.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "verified_credential_type_id": 11, - "verified_credential_type_kind_id": 1 - } -] diff --git a/src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_type_assigned_kinds.consortia.json b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_type_assigned_kinds.unittest.json similarity index 100% rename from src/database/SsiCredentialIssuer.Migrations/Seeder/Data/verified_credential_type_assigned_kinds.consortia.json rename to tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_type_assigned_kinds.unittest.json diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_type_assigned_use_cases.test.json b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_type_assigned_use_cases.unittest.json similarity index 100% rename from tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_type_assigned_use_cases.test.json rename to tests/database/SsiCredentialIssuer.DbAccess.Tests/Seeder/Data/verified_credential_type_assigned_use_cases.unittest.json diff --git a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Setup/TestDbFixture.cs b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Setup/TestDbFixture.cs index cbd762c9..5d3c7ff0 100644 --- a/tests/database/SsiCredentialIssuer.DbAccess.Tests/Setup/TestDbFixture.cs +++ b/tests/database/SsiCredentialIssuer.DbAccess.Tests/Setup/TestDbFixture.cs @@ -92,7 +92,7 @@ await _container.StartAsync() var seederOptions = Options.Create(new SeederSettings { - TestDataEnvironments = new[] { "test" }, + TestDataEnvironments = new[] { "unittest" }, DataPaths = new[] { "Seeder/Data" } }); var insertSeeder = new BatchInsertSeeder(context,