diff --git a/mxd/bdrs.tf b/mxd/bdrs.tf new file mode 100644 index 00000000..3699d161 --- /dev/null +++ b/mxd/bdrs.tf @@ -0,0 +1,56 @@ +################################################################################# +# +# Copyright (c) 2024 SAP SE +# +# 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 +# +# SPDX-License-Identifier: Apache-2.0 +# +# Contributors: +# SAP SE - initial API and implementation +# +################################################################################# + +resource "helm_release" "bdrs-server" { + name = "bdrs-server" + force_update = true + dependency_update = true + reuse_values = true + cleanup_on_fail = true + replace = true + + repository = "https://eclipse-tractusx.github.io/charts/dev" + chart = "bdrs-server" + version = "0.0.4" + + values = [ + yamlencode({ + server : { + trustedIssuers : ["did:web:miw:${var.miw-bpn}"] + env : { + EDC_API_AUTH_KEY : "password" + EDC_DATASOURCE_DIDENTRY_USER : local.databases.bdrs.database-username + EDC_DATASOURCE_DIDENTRY_PASSWORD : local.databases.bdrs.database-password + } + } + postgresql : { + jdbcUrl : "jdbc:postgresql://${local.bdrs-postgres.database-url}/${local.databases.bdrs.database-name}" + } + }) + ] + + set { + name = "install.postgresql" + value = false + } +} + +locals { + bdrs-service = "bdrs-server" + bdrs-mgmt-port = 8081 + bdrs-directory-port = 8082 + bdrs-mgmt-url = "http://${local.bdrs-service}:${local.bdrs-mgmt-port}/api/management" + bdrs-directory-url = "http://${local.bdrs-service}:${local.bdrs-directory-port}/api/directory" +} diff --git a/mxd/ingress.tf b/mxd/ingress.tf index 290aae14..7fba45e3 100644 --- a/mxd/ingress.tf +++ b/mxd/ingress.tf @@ -52,6 +52,28 @@ resource "kubernetes_ingress_v1" "mxd-ingress" { } } } + path { + path = "/bdrs-mgmt(/|$)(.*)" + backend { + service { + name = local.bdrs-service + port { + number = local.bdrs-mgmt-port + } + } + } + } + path { + path = "/bdrs-dir(/|$)(.*)" + backend { + service { + name = local.bdrs-service + port { + number = local.bdrs-directory-port + } + } + } + } } } } diff --git a/mxd/postgres-init.tf b/mxd/postgres-init.tf index 2fddf9ea..817547e7 100644 --- a/mxd/postgres-init.tf +++ b/mxd/postgres-init.tf @@ -58,6 +58,7 @@ resource "kubernetes_config_map" "postgres-initdb-config" { locals { keycloak-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["keycloak"] miw-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["miw"] + bdrs-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["bdrs"] alice-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["alice"] bob-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["bob"] trudy-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["trudy"] @@ -76,6 +77,12 @@ locals { database-password = "miw" } + bdrs = { + database-name = "bdrs", + database-username = "bdrs" + database-password = "bdrs" + } + alice = { database-name = "alice", database-username = "alice" diff --git a/mxd/postman/mxd-management-apis.json b/mxd/postman/mxd-management-apis.json index 15eb6011..92e75ee4 100644 --- a/mxd/postman/mxd-management-apis.json +++ b/mxd/postman/mxd-management-apis.json @@ -1,10 +1,10 @@ { "info": { - "_postman_id": "2331eb24-a4fe-4841-b2c0-4333e3fd47e3", + "_postman_id": "3636c0ce-40f8-4a9e-a868-03841ed765f0", "name": "tractusx-edc-mgmt-api", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "252261", - "_collection_link": "https://winter-rocket-884715.postman.co/workspace/SAP~ff4cf631-05f4-48ab-a1e0-f716cf2efc25/collection/252261-2331eb24-a4fe-4841-b2c0-4333e3fd47e3?action=share&source=collection_link&creator=252261" + "_collection_link": "https://winter-rocket-884715.postman.co/workspace/SAP~ff4cf631-05f4-48ab-a1e0-f716cf2efc25/collection/252261-3636c0ce-40f8-4a9e-a868-03841ed765f0?action=share&source=collection_link&creator=252261" }, "item": [ { @@ -75,6 +75,48 @@ }, "response": [] }, + { + "name": "Get BPN Mapping", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "localhost/bdrs-mgmt/api/management/bpn-directory", + "host": [ + "localhost" + ], + "path": [ + "bdrs-mgmt", + "api", + "management", + "bpn-directory" + ] + } + }, + "response": [] + }, { "name": "Create Asset", "event": [ diff --git a/mxd/postman/mxd-seed.json b/mxd/postman/mxd-seed.json index bd108191..33f8b61d 100644 --- a/mxd/postman/mxd-seed.json +++ b/mxd/postman/mxd-seed.json @@ -1,10 +1,10 @@ { "info": { - "_postman_id": "d2bed995-c23f-43fa-a5ae-6aa49b24f0d9", + "_postman_id": "456f5db9-6973-4259-a8a9-381408e48c6a", "name": "MXD Management API Seed", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "252261", - "_collection_link": "https://winter-rocket-884715.postman.co/workspace/SAP~ff4cf631-05f4-48ab-a1e0-f716cf2efc25/collection/252261-d2bed995-c23f-43fa-a5ae-6aa49b24f0d9?action=share&source=collection_link&creator=252261" + "_collection_link": "https://winter-rocket-884715.postman.co/workspace/SAP~ff4cf631-05f4-48ab-a1e0-f716cf2efc25/collection/252261-456f5db9-6973-4259-a8a9-381408e48c6a?action=share&source=collection_link&creator=252261" }, "item": [ { @@ -487,6 +487,161 @@ } } ] + }, + { + "name": "SeedBDRS", + "item": [ + { + "name": "Create Alice BPN Mapping", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 204\", function () {", + " pm.response.to.have.status(204);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"bpn\": \"{{ALICE_BPN}}\",\n \"did\": \"{{ALICE_DID}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{BDRS_MGMT_URL}}/bpn-directory", + "host": [ + "{{BDRS_MGMT_URL}}" + ], + "path": [ + "bpn-directory" + ] + } + }, + "response": [] + }, + { + "name": "Create Bob BPN Mapping", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 204\", function () {", + " pm.response.to.have.status(204);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"bpn\": \"{{BOB_BPN}}\",\n \"did\": \"{{BOB_DID}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{BDRS_MGMT_URL}}/bpn-directory", + "host": [ + "{{BDRS_MGMT_URL}}" + ], + "path": [ + "bpn-directory" + ] + } + }, + "response": [] + }, + { + "name": "Create Trudy BPN Mapping", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 204\", function () {", + " pm.response.to.have.status(204);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"bpn\": \"{{TRUDY_BPN}}\",\n \"did\": \"{{TRUDY_DID}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{BDRS_MGMT_URL}}/bpn-directory", + "host": [ + "{{BDRS_MGMT_URL}}" + ], + "path": [ + "bpn-directory" + ] + } + }, + "response": [] + } + ] } ], "auth": { @@ -579,6 +734,26 @@ "value": "BPNL000000000003", "type": "string" }, + { + "key": "ALICE_DID", + "value": "did:web:miw%3A8000:BPNL000000000001", + "type": "string" + }, + { + "key": "BOB_DID", + "value": "did:web:miw%3A8000:BPNL000000000002", + "type": "string" + }, + { + "key": "TRUDY_DID", + "value": "did:web:miw%3A8000:BPNL000000000003", + "type": "string" + }, + { + "key": "BDRS_MGMT_URL", + "value": "localhost/bdrs-mgmt/api/management", + "type": "string" + }, { "key": "BUSINESS_PARTNER_GROUP", "value": "gold-partners", diff --git a/mxd/seed_data.tf b/mxd/seed_data.tf index ca42a35e..2e209f5c 100644 --- a/mxd/seed_data.tf +++ b/mxd/seed_data.tf @@ -92,6 +92,27 @@ resource "kubernetes_job" "seed_connectors_via_mgmt_api" { name = "seed-collection" } } + + container { + name = "newman-bdrs" + image = "postman/newman:ubuntu" + command = [ + "newman", "run", + "--folder", "SeedBDRS", + "--env-var", "BDRS_MGMT_URL=${local.bdrs-mgmt-url}", + "--env-var", "ALICE_DID=did:web:miw%3A${var.miw-api-port}:${var.alice-bpn}", + "--env-var", "BOB_DID=did:web:miw:${var.miw-api-port}:${var.bob-bpn}", + "--env-var", "TRUDY_DID=did:web:miw:${var.miw-api-port}:${var.trudy-bpn}", + "--env-var", "ALICE_BPN=${var.alice-bpn}", + "--env-var", "BOB_BPN=${var.bob-bpn}", + "--env-var", "TRUDY_BPN=${var.trudy-bpn}", + "/opt/collection/${local.newman_collection_name}" + ] + volume_mount { + mount_path = "/opt/collection" + name = "seed-collection" + } + } volume { name = "seed-collection" config_map {