From 3ceed4c8ad21ebda8444c8ba2b780106edfed234 Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Mon, 10 Jun 2024 09:52:21 +0200 Subject: [PATCH 01/10] feat: initial commit --- .../DataInjectionCommandLineRunner.java | 1 + .../edc/logic/util/EdcRequestBodyBuilder.java | 6 - .../backend/common/util/VariablesService.java | 27 +- .../domain/model/ErpAdapterRequest.java | 2 + .../service/ErpAdapterRequestClient.java | 56 +++ .../service/ErpAdapterRequestService.java | 25 ++ .../service/ItemStockErpAdapterService.java | 4 + .../src/main/resources/application.properties | 3 + .../src/test/resources/application.properties | 3 + charts/puris/README.md | 355 +++++++++--------- .../puris/templates/backend-deployment.yaml | 7 + charts/puris/values.yaml | 4 + .../config/customer/puris-backend.properties | 4 + .../config/supplier/puris-backend.properties | 4 + 14 files changed, 315 insertions(+), 186 deletions(-) create mode 100644 backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/DataInjectionCommandLineRunner.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/DataInjectionCommandLineRunner.java index b84e8c3d..52fcd7d4 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/DataInjectionCommandLineRunner.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/DataInjectionCommandLineRunner.java @@ -257,6 +257,7 @@ private void setupCustomerRole() throws JsonProcessingException { .directionCharacteristic(DirectionCharacteristic.INBOUND) .requestType("ItemStock") .sammVersion("2.0") + .responseCode(201) .build(); mockRequest = erpAdapterRequestService.create(mockRequest); log.info("Created mocked ErpAdapterRequest: \n{}", mockRequest); diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/util/EdcRequestBodyBuilder.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/util/EdcRequestBodyBuilder.java index f38f0e14..08fa0fce 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/util/EdcRequestBodyBuilder.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/util/EdcRequestBodyBuilder.java @@ -334,12 +334,6 @@ public JsonNode buildProxyPullRequestBody(Partner partner, String contractID, St dataDestination.put("type", "HttpProxy"); body.set("dataDestination", dataDestination); - // This private property is not evaluated in EDC 0.7.0 anymore due to data plane signalling - // EDRs are taken manually - var privateProperties = MAPPER.createObjectNode(); - privateProperties.put("receiverHttpEndpoint", variablesService.getEdrEndpoint()); - body.set("privateProperties", privateProperties); - log.debug("Built Proxy Pull Request:\n{}", body.toPrettyString()); return body; } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java index ff2b0a9c..c5f3c7b8 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java @@ -50,11 +50,32 @@ public class VariablesService { */ private String demoRole; - @Value("${puris.baseurl}" + "catena/edrendpoint") + @Value("${puris.erpadapter.url}") /** - * The edrEndpoint to be used during consumer pull asset transfers. + * The URL of the ERP adapter */ - private String edrEndpoint; + private String erpAdapterUrl; + + /** + * The URL under which we expect responses from + * the ERP adapter + */ + @Value("${puris.baseurl}" + "catena/erp-adapter") + private String erpResponseUrl; + + /** + * The auth-key used when accessing the ERP adapter's + * request interface + */ + @Value("${puris.erpadapter.authkey}") + private String erpAdapterAuthKey; + + /** + * The auth-secret used when accessing the ERP adapter's + * request interface + */ + @Value("${puris.erpadapter.authsecret}") + private String erpAdapterAuthSecret; @Value("${puris.baseurl}" + "catena/item-stock/request") /** diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/domain/model/ErpAdapterRequest.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/domain/model/ErpAdapterRequest.java index b1341ea5..4bc6b705 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/domain/model/ErpAdapterRequest.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/domain/model/ErpAdapterRequest.java @@ -59,6 +59,8 @@ public class ErpAdapterRequest { @NotNull private Date requestDate; + private Integer responseCode; + private Date responseReceivedDate; @Pattern(regexp = PatternStore.NON_EMPTY_NON_VERTICAL_WHITESPACE_STRING) diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java new file mode 100644 index 00000000..d83a7ed4 --- /dev/null +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java @@ -0,0 +1,56 @@ +package org.eclipse.tractusx.puris.backend.erpadapter.logic.service; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import lombok.extern.slf4j.Slf4j; +import okhttp3.*; +import org.eclipse.tractusx.puris.backend.common.util.VariablesService; +import org.eclipse.tractusx.puris.backend.erpadapter.domain.model.ErpAdapterRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.IOException; + +@Service +@Slf4j +public class ErpAdapterRequestClient { + + private final OkHttpClient client = new OkHttpClient(); + + private final ObjectMapper mapper = new ObjectMapper(); + + @Autowired + private VariablesService variablesService; + + public Integer sendRequest(ErpAdapterRequest erpAdapterRequest){ + HttpUrl.Builder urlBuilder = HttpUrl.parse(variablesService.getErpAdapterUrl()).newBuilder(); + urlBuilder.addQueryParameter("bpnl", erpAdapterRequest.getPartnerBpnl()); + urlBuilder.addQueryParameter("request-type", erpAdapterRequest.getRequestType()); + urlBuilder.addQueryParameter("request-id", erpAdapterRequest.getId().toString()); + urlBuilder.addQueryParameter("samm-version", erpAdapterRequest.getSammVersion()); + urlBuilder.addQueryParameter("request-timestamp", erpAdapterRequest.getRequestDate().toString()); + + ObjectNode requestBody = mapper.createObjectNode(); + + requestBody.put("material", erpAdapterRequest.getOwnMaterialNumber()); + requestBody.put("direction", erpAdapterRequest.getDirectionCharacteristic().toString()); + requestBody.put("response-url", variablesService.getErpResponseUrl()); + + RequestBody body = RequestBody.create(requestBody.toString(), MediaType.parse("application/json")); + + Request request = new Request.Builder() + .post(body) + .url(urlBuilder.build()) + .header(variablesService.getErpAdapterAuthKey(), variablesService.getErpAdapterAuthSecret()) + .header("Content-Type", "application/json") + .build(); + try { + var response = client.newCall(request).execute(); + return response.code(); + } catch (IOException e) { + log.error("Error while sending ErpAdapterRequest", e); + return null; + } + + } +} diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java index 60088da3..1d355dce 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java @@ -20,6 +20,7 @@ package org.eclipse.tractusx.puris.backend.erpadapter.logic.service; +import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.puris.backend.erpadapter.domain.model.ErpAdapterRequest; import org.eclipse.tractusx.puris.backend.erpadapter.domain.repository.ErpAdapterRequestRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -28,18 +29,41 @@ import java.util.UUID; @Service +@Slf4j public class ErpAdapterRequestService { @Autowired private ErpAdapterRequestRepository repository; + @Autowired + private ErpAdapterRequestClient erpAdapterRequestClient; + public ErpAdapterRequest create(ErpAdapterRequest erpAdapterRequest) { if (erpAdapterRequest.getId() != null && repository.existsById(erpAdapterRequest.getId())) { + log.error("ErpAdapterRequest with id {} already exists", erpAdapterRequest.getId()); return null; } return repository.save(erpAdapterRequest); } + public void createAndSend(ErpAdapterRequest erpAdapterRequest) { + erpAdapterRequest = create(erpAdapterRequest); + if (erpAdapterRequest != null) { + Integer responseCode = erpAdapterRequestClient.sendRequest(erpAdapterRequest); + if (responseCode != null) { + if (responseCode >= 200 && responseCode < 400) { + log.info("Successfully sent request to ERP Adapter"); + } else { + log.warn("Received status code {} from ERP Adapter ", responseCode); + } + erpAdapterRequest.setResponseCode(responseCode); + update(erpAdapterRequest); + } else { + log.error("Failed to send request to ERP Adapter"); + } + } + } + public ErpAdapterRequest get(UUID id) { // TODO: Remove when mock is removed return repository.findById(id).orElse(repository.findAll().getFirst()); @@ -50,6 +74,7 @@ public ErpAdapterRequest update(ErpAdapterRequest erpAdapterRequest) { if (repository.existsById(erpAdapterRequest.getId())) { return repository.save(erpAdapterRequest); } + log.error("ErpAdapterRequest with id {} did not exist, could not update entity", erpAdapterRequest.getId()); return null; } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ItemStockErpAdapterService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ItemStockErpAdapterService.java index c8bebeba..4de30753 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ItemStockErpAdapterService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ItemStockErpAdapterService.java @@ -90,6 +90,10 @@ public int receiveItemStockUpdate(ErpAdapterController.Dto dto) { // log.error("Received duplicate response for messageId {}", request.getId()); // return 409; // } + if (request.getResponseCode() == null || request.getResponseCode() < 200 || request.getResponseCode() >= 400) { + log.error("Unexpected response, erp adapter had not confirmed request"); + return 404; + } if (!request.getPartnerBpnl().equals(dto.partnerBpnl())) { log.error("BPNL mismatch! request BPNL: {}, message BPNL: {}", request.getPartnerBpnl(), dto.partnerBpnl()); diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 4df72211..8d7976f2 100755 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -21,6 +21,9 @@ puris.dtr.idp.edc-client.id=${PURIS_DTR_IDP_EDC-CLIENT_ID:FOSS-DTR-CLIENT} puris.dtr.idp.edc-client.secret.alias=${PURIS_DTR_IDP_EDC-CLIENT_SECRET_ALIAS} puris.dtr.idp.puris-client.id=${PURIS_DTR_IDP_PURIS-CLIENT_ID:FOSS-DTR-CLIENT} puris.dtr.idp.puris-client.secret=${PURIS_DTR_IDP_PURIS-CLIENT_SECRET} +puris.erpadapter.url=${PURIS_ERPADAPTER_URL:http://my-erpadapter:8080} +puris.erpadapter.authkey=${PURIS_ERPADAPTER_AUTHKEY:x-api-key} +puris.erpadapter.authsecret=${PURIS_ERPADAPTER_AUTHSECRET:erp-password} # Flag that decides whether the auto-generation feature of the puris backend is enabled. # Since all Material entities are required to have a CatenaX-Id, you must enter any pre-existing CatenaX-Id # via the materials-API of the backend, when you are inserting a new Material entity to the backend's diff --git a/backend/src/test/resources/application.properties b/backend/src/test/resources/application.properties index ef0263e9..747f5b56 100755 --- a/backend/src/test/resources/application.properties +++ b/backend/src/test/resources/application.properties @@ -19,6 +19,9 @@ puris.dtr.idp.edc-client.id=${PURIS_DTR_IDP_EDC-CLIENT_ID:FOSS-DTR-CLIENT} puris.dtr.idp.edc-client.secret.alias=${PURIS_DTR_IDP_EDC-CLIENT_SECRET_ALIAS:test-alias} puris.dtr.idp.puris-client.id=${PURIS_DTR_IDP_PURIS-CLIENT_ID:FOSS-DTR-CLIENT} puris.dtr.idp.puris-client.secret=${PURIS_DTR_IDP_PURIS-CLIENT_SECRET:test} + +puris.erpadapter.url=${PURIS_ERPADAPTER_URL:http://my-erpadapter:8080} + puris.generatematerialcatenaxid=${PURIS_GENERATEMATERIALCATENAXID:true} # DB Configuration diff --git a/charts/puris/README.md b/charts/puris/README.md index 91802d70..6080739d 100644 --- a/charts/puris/README.md +++ b/charts/puris/README.md @@ -7,7 +7,6 @@ A helm chart for Kubernetes deployment of PURIS **Homepage:** ## Prerequisites - - Kubernetes 1.19+ - Helm 3.2.0+ @@ -19,7 +18,6 @@ To install the chart with the release name `puris`: $ helm repo add tractusx-dev https://eclipse-tractusx.github.io/charts/dev $ helm install puris tractusx-dev/policy-hub ``` - To install the helm chart into your cluster with your values: ```shell @@ -30,9 +28,9 @@ To use the helm chart as a dependency: ```yaml dependencies: - - name: puris - repository: https://eclipse-tractusx.github.io/charts/dev - version: YOUR_VERSION + - name: puris + repository: https://eclipse-tractusx.github.io/charts/dev + version: YOUR_VERSION ``` ## Source Code @@ -41,182 +39,185 @@ dependencies: ## Requirements -| Repository | Name | Version | -|------------------------------------|------------|---------| +| Repository | Name | Version | +|------------|------|---------| | https://charts.bitnami.com/bitnami | postgresql | 12.12.x | ## Values -| Key | Type | Default | Description | -|-------------------------------------------------------------------------------------------------------------------------------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| backend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution | list | `[{"podAffinityTerm":{"labelSelector":{"matchExpressions":[{"key":"app.kubernetes.io/name","operator":"DoesNotExist"}]},"topologyKey":"kubernetes.io/hostname"},"weight":100}]` | Rules for the scheduler to find a pod | -| backend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions | list | `[{"key":"app.kubernetes.io/name","operator":"DoesNotExist"}]` | Matching Expressions as key and operators for the pod affinity | -| backend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | Topology key of the Kubernetes cluster | -| backend.autoscaling.enabled | bool | `false` | Enable or disable the autoscaling of pods | -| backend.env | object | `{}` | Extra environment variables that will be passed onto the backend deployment pods | -| backend.image.pullPolicy | string | `"Always"` | THe policy for the image pull process | -| backend.image.repository | string | `"tractusx/app-puris-backend"` | Repository of the docker image | -| backend.image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. | -| backend.imagePullSecrets | list | `[]` | List of used secrets | -| backend.ingress.annotations | object | `{"kubernetes.io/ingress.class":"nginx","nginx.ingress.kubernetes.io/backend-protocol":"HTTP","nginx.ingress.kubernetes.io/force-ssl-redirect":"true","nginx.ingress.kubernetes.io/ssl-passthrough":"true"}` | Annotations for the Ingress controller | -| backend.ingress.annotations."kubernetes.io/ingress.class" | string | `"nginx"` | Kubernetes Ingress class annotation for direct bindings | -| backend.ingress.annotations."nginx.ingress.kubernetes.io/backend-protocol" | string | `"HTTP"` | The backend protocol type (e.g. HTTP) | -| backend.ingress.annotations."nginx.ingress.kubernetes.io/force-ssl-redirect" | string | `"true"` | Force redirects from HTTP to HTTPS | -| backend.ingress.annotations."nginx.ingress.kubernetes.io/ssl-passthrough" | string | `"true"` | Pass SSL traffic to the backend ports | -| backend.ingress.enabled | bool | `false` | Enable the Ingress | -| backend.ingress.hosts | list | `[{"host":"your-backend-host-address.com","paths":[{"path":"/","pathType":"ImplementationSpecific"}]}]` | Hosts for the Ingress controller | -| backend.ingress.tls | list | `[]` | TLS certificates for the Ingress controller | -| backend.livenessProbe | object | `{"failureThreshold":3,"initialDelaySeconds":120,"periodSeconds":25,"successThreshold":1,"timeoutSeconds":1}` | Checks whether a pod is alive or not | -| backend.livenessProbe.failureThreshold | int | `3` | Number of failures (threshold) for a liveness probe | -| backend.livenessProbe.initialDelaySeconds | int | `120` | Delay in seconds after which an initial liveness probe is checked | -| backend.livenessProbe.periodSeconds | int | `25` | Wait time in seconds between liveness probes | -| backend.livenessProbe.successThreshold | int | `1` | Number of trys until a pod is marked alive | -| backend.livenessProbe.timeoutSeconds | int | `1` | Timeout in seconds of the liveness probe | -| backend.nameOverride | string | `""` | Possibility to override the name | -| backend.nodeSelector | object | `{}` | Constrains for the node selector | -| backend.podAnnotations | object | `{}` | Annotations added to a running pod | -| backend.podSecurityContext | object | `{}` | Added security contexts for a pod | -| backend.puris.api.key | string | `"test"` | The API key of the PURIS application | -| backend.puris.api.rootDir | string | `"/catena"` | The root directory of the API | -| backend.puris.baseurl | string | `"your-backend-host-address.com"` | Base url of the PURIS backend | -| backend.puris.datasource.driverClassName | string | `"org.postgresql.Driver"` | Driver class name of the database | -| backend.puris.datasource.password | string | `""` | Password for the database user. Ignored if postgres.enabled is true. | -| backend.puris.datasource.url | string | `"jdbc:postgresql://postgresql-name:5432/puris-database"` | URL of the database. Ignored if postgres.enabled is true. | -| backend.puris.datasource.username | string | `"db-user"` | Username of the database. Ignored if postgres.enabled is true. | -| backend.puris.deliverysubmodel.apiassetid | string | `"deliverysubmodel-api-asset"` | Asset ID for DeliverySubmodel API | -| backend.puris.demandsubmodel.apiassetid | string | `"demandsubmodel-api-asset"` | Asset ID for DemandSubmodel API | -| backend.puris.demonstrator.role | string | `nil` | Current role of the PURIS demonstrator. Default value should be empty. Can be set to "customer" or "supplier" to enable demonstration setup | -| backend.puris.dtr.idp.clients.edc.id | string | `"FOSS-EDC-CLIENT"` | id of the client that has a service account with roles to view the DTR. Used by the application to create DTR asset in the edc with read only access. See Admin Guide. Mandatory if backend.puris.dtr.idp.enabled = true. | -| backend.puris.dtr.idp.clients.edc.secret.alias | string | `"path/secret-name"` | alias for the vault used by the EDC in which the secret is stored. Mandatory if backend.puris.dtr.idp.enabled = true. | -| backend.puris.dtr.idp.clients.puris.id | string | `"FOSS-PURIS-CLIENT"` | id of the client that has a service account with roles to manage the DTR. Used by the application to create and update digital twins. See Admin Guide. Mandatory if backend.puris.dtr.idp.enabled = true. | -| backend.puris.dtr.idp.clients.puris.secret | string | `""` | secret of the client with write access (no vault alias). No default value will be created if empty. Mandatory if backend.puris.dtr.idp.enabled = true. | -| backend.puris.dtr.idp.enabled | bool | `true` | enables the usage of the IDP for the DTR. | -| backend.puris.dtr.idp.tokenurl | string | `"https://keycloak-service.com/realms/your-realm/openid-connect/token"` | token url of the idp for your specific realm. May be different to other idp token url in this config. Mandatory if backend.puris.dtr.idp.enabled = true. | -| backend.puris.dtr.url | string | `"http://localhost:4243"` | Endpoint for DTR | -| backend.puris.edc.controlplane.host | string | `"172.17.0.2"` | | -| backend.puris.edc.controlplane.key | string | `"password"` | Key for the EDC control plane | -| backend.puris.edc.controlplane.management.url | string | `"https:/your-edc-address:8181/management"` | Url to the EDC controlplane management of the edc | -| backend.puris.edc.controlplane.protocol.url | string | `"https://your-edc-address:8184/api/v1/dsp"` | Url to the EDC controlplane protocol API of the edc | -| backend.puris.edc.dataplane.public.url | string | `"https://your-data-plane:8285/api/public/"` | Url of one of your data plane's public api | -| backend.puris.existingSecret | string | `"secret-puris-backend"` | Secret for backend passwords. For more information look into 'backend-secrets.yaml' file. | -| backend.puris.frameworkagreement.credential | string | `"Puris"` | The name of the framework agreement. Starting with Uppercase and using CamelCase. | -| backend.puris.frameworkagreement.version | string | `"1.0"` | The version of the framework agreement, NEEDS TO BE PUT AS "STRING"! | -| backend.puris.generatematerialcatenaxid | bool | `true` | Flag that decides whether the auto-generation feature of the puris backend is enabled. Since all Material entities are required to have a CatenaX-Id, you must enter any pre-existing CatenaX-Id via the materials-API of the backend, when you are inserting a new Material entity to the backend's database. If a CatenaX-Id was not assigned to your Material so far, then this feature can auto-generate one randomly. In a real-world-scenario, you must then use this randomly generated CatenaX-Id for the lifetime of that Material entity. | -| backend.puris.itemstocksubmodel.apiassetid | string | `"itemstocksubmodel-api-asset"` | Asset ID for ItemStockSubmodel API | -| backend.puris.jpa.hibernate.ddl-auto | string | `"create"` | Initialises SQL database with Hibernate property "create" to allow Hibernate to first drop all tables and then create new ones | -| backend.puris.jpa.properties.hibernate.enable_lazy_load_no_trans | bool | `true` | Enables "Lazy load no trans" property to fetch of each lazy entity to open a temporary session and run inside a separate transaction | -| backend.puris.own.bpna | string | `"BPNA4444444444ZZ"` | Own BPNA of the EDC | -| backend.puris.own.bpnl | string | `"BPNL4444444444XX"` | Own BPNL of the EDC | -| backend.puris.own.bpns | string | `"BPNS4444444444XX"` | Own BPNS of the EDC | -| backend.puris.own.country | string | `"Germany"` | Own country | -| backend.puris.own.name | string | `"YOUR-COMPANY-NAME"` | Own name (self-description) | -| backend.puris.own.site.name | string | `"YOUR-SITE-NAME"` | Own site name | -| backend.puris.own.streetnumber | string | `"Musterstraße 110A"` | Own street and number | -| backend.puris.own.zipcodeandcity | string | `"12345 Musterhausen"` | Own zipcode and city | -| backend.puris.productionsubmodel.apiassetid | string | `"productionsubmodel-api-asset"` | Asset ID for ProductionSubmodel API | -| backend.puris.purpose.name | string | `"cx.puris.base"` | The name of the purpose to use for submodel contracts | -| backend.puris.purpose.version | string | `"1"` | The version of the purpose to use for submodel contracts. NEEDS TO BE PUT AS "STRING"! | -| backend.readinessProbe | object | `{"failureThreshold":3,"initialDelaySeconds":120,"periodSeconds":25,"successThreshold":1,"timeoutSeconds":1}` | Checks if the pod is fully ready to operate | -| backend.readinessProbe.failureThreshold | int | `3` | Number of failures (threshold) for a readiness probe | -| backend.readinessProbe.initialDelaySeconds | int | `120` | Delay in seconds after which an initial readiness probe is checked | -| backend.readinessProbe.periodSeconds | int | `25` | Wait time in seconds between readiness probes | -| backend.readinessProbe.successThreshold | int | `1` | Number of trys until a pod is marked ready | -| backend.readinessProbe.timeoutSeconds | int | `1` | Timeout in seconds of the readiness probe | -| backend.replicaCount | int | `1` | Number of replicas of the Kubernetes deployment | -| backend.resources.limits | object | `{"cpu":"3000m","memory":"2048Mi"}` | Maximum resource limits of CPU und memory | -| backend.resources.requests | object | `{"cpu":"1000m","memory":"2048Mi"}` | Minimum requested resources for CPU und memory | -| backend.securityContext | object | `{"allowPrivilegeEscalation":false,"runAsGroup":3000,"runAsNonRoot":true,"runAsUser":8877}` | Security configurations | -| backend.securityContext.allowPrivilegeEscalation | bool | `false` | Get more privileges than the parent process | -| backend.securityContext.runAsGroup | int | `3000` | Configures the group id of a user for a run | -| backend.securityContext.runAsNonRoot | bool | `true` | Configures the non-root privileges for a run | -| backend.securityContext.runAsUser | int | `8877` | Configures the user id for a run | -| backend.service.port | int | `8081` | The port of the service | -| backend.service.type | string | `"ClusterIP"` | Type of the service | -| backend.serviceAccount.annotations | object | `{}` | Annotations to add to the service account | -| backend.serviceAccount.create | bool | `true` | Specifies whether a service account should be created | -| backend.serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | -| backend.tolerations | list | `[]` | Constrains for tolerations | -| frontend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution | list | `[{"podAffinityTerm":{"labelSelector":{"matchExpressions":[{"key":"app.kubernetes.io/name","operator":"DoesNotExist"}]},"topologyKey":"kubernetes.io/hostname"},"weight":100}]` | Rules for the scheduler to find a pod | -| frontend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions | list | `[{"key":"app.kubernetes.io/name","operator":"DoesNotExist"}]` | Matching Expressions as key and operators for the pod affinity | -| frontend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | Topology key of the Kubernetes cluster | -| frontend.autoscaling.enabled | bool | `false` | Enable or disable the autoscaling of pods | -| frontend.autoscaling.maxReplicas | int | `100` | Number of maximum replica pods for autoscaling | -| frontend.autoscaling.minReplicas | int | `1` | Number of minimum replica pods for autoscaling | -| frontend.autoscaling.targetCPUUtilizationPercentage | int | `80` | Value of CPU usage in percentage for autoscaling decisions | -| frontend.env | object | `{}` | Extra environment variables that will be passed onto the frontend deployment pods | -| frontend.image.pullPolicy | string | `"IfNotPresent"` | THe policy for the image pull process | -| frontend.image.repository | string | `"tractusx/app-puris-frontend"` | Repository of the docker image | -| frontend.image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. | -| frontend.imagePullSecrets | list | `[]` | List of used secrets | -| frontend.ingress.annotations | object | `{}` | Annotations for the Ingress controller | -| frontend.ingress.className | string | `"nginx"` | Class name for the Ingress controller | -| frontend.ingress.enabled | bool | `false` | Enable the Ingress | -| frontend.ingress.hosts | list | `[{"host":"your-frontend-host-address.com","paths":[{"path":"/","pathType":"ImplementationSpecific"}]}]` | Hosts for the Ingress controller | -| frontend.ingress.tls | list | `[]` | TLS certificates for the Ingress controller | -| frontend.livenessProbe | object | `{"failureThreshold":3,"initialDelaySeconds":10,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":1}` | Checks whether a pod is alive or not | -| frontend.livenessProbe.failureThreshold | int | `3` | Number of failures (threshold) for a liveness probe | -| frontend.livenessProbe.initialDelaySeconds | int | `10` | Delay in seconds after which an initial liveness probe is checked | -| frontend.livenessProbe.periodSeconds | int | `10` | Wait time in seconds between liveness probes | -| frontend.livenessProbe.successThreshold | int | `1` | Number of trys until a pod is marked alive | -| frontend.livenessProbe.timeoutSeconds | int | `1` | Timeout in seconds of the liveness probe | -| frontend.nameOverride | string | `""` | Possibility to override the name | -| frontend.nodeSelector | object | `{}` | Constrains for the node selector | -| frontend.podAnnotations | object | `{}` | Annotations added to a running pod | -| frontend.podSecurityContext | object | `{}` | Added security contexts for a pod | -| frontend.puris.appName | string | `"PURIS"` | The name of the app displayed in the frontend | -| frontend.puris.baseUrl | string | `"your-backend-host-address.com"` | The base URL for the backend base URL without further endpoints | -| frontend.puris.endpointCustomer | string | `"stockView/customer?ownMaterialNumber="` | The endpoint for the customers who buy a material identified via the own material number for the stock view | -| frontend.puris.endpointDelivery | string | `"delivery"` | The endpoint for the delivery submodel | -| frontend.puris.endpointDemand | string | `"demand"` | The endpoint for the demand submodel | -| frontend.puris.endpointMaterialStocks | string | `"stockView/material-stocks"` | The endpoint for material stocks for the stock view | -| frontend.puris.endpointMaterials | string | `"stockView/materials"` | The endpoint for materials for the stock view | -| frontend.puris.endpointPartners | string | `"partners"` | The endpoint for partner information | -| frontend.puris.endpointProductStocks | string | `"stockView/product-stocks"` | The endpoint for product stocks for the stock view | -| frontend.puris.endpointProduction | string | `"production"` | The endpoint for the production submodel | -| frontend.puris.endpointProductionRange | string | `"production/range"` | The endpoint for the production range of the production submodel | -| frontend.puris.endpointProducts | string | `"stockView/products"` | The endpoint for products for the stock view | -| frontend.puris.endpointReportedMaterialStocks | string | `"stockView/reported-material-stocks?ownMaterialNumber="` | The endpoint for the partners' (supplier) material stocks that they potentially will deliver to me | -| frontend.puris.endpointReportedProductStocks | string | `"stockView/reported-product-stocks?ownMaterialNumber="` | The endpoint for the partners' (customer) product stocks that they received from me | -| frontend.puris.endpointSupplier | string | `"stockView/supplier?ownMaterialNumber="` | The endpoint for the suppliers who buy a material identified via the own material number for the stock view | -| frontend.puris.endpointUpdateReportedMaterialStocks | string | `"stockView/update-reported-material-stocks?ownMaterialNumber="` | The endpoint for triggering an update of your material stocks on your partners side | -| frontend.puris.endpointUpdateReportedProductStocks | string | `"stockView/update-reported-product-stocks?ownMaterialNumber="` | The endpoint for triggering an update of your product stocks on your partners side | -| frontend.puris.keycloak.clientId | string | `"appXYZ"` | Name of the client which is used for the application. | -| frontend.puris.keycloak.disabled | bool | `true` | Disable the Keycloak integration. | -| frontend.puris.keycloak.realm | string | `"Catena-X"` | Name of the Realm of the keycloak instance. | -| frontend.puris.keycloak.redirectUrlFrontend | string | `"https://your-frontend-url.com"` | URL to use as keycloak redirect url. | -| frontend.puris.keycloak.url | string | `"https://idp.com/auth"` | The URL to the IDP that should be used. | -| frontend.puris.rateLimiting.burst | int | `30` | Burst rate limiting for nginx. | -| frontend.puris.rateLimiting.limit | string | `"10m"` | Bucket zone limit for rate limiting in nginx. | -| frontend.puris.rateLimiting.rate | string | `"10r/s"` | Allowed rates per second for nginx rate limiting. | -| frontend.readinessProbe | object | `{"failureThreshold":3,"initialDelaySeconds":10,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":1}` | Checks if the pod is fully ready to operate | -| frontend.readinessProbe.failureThreshold | int | `3` | Number of failures (threshold) for a readiness probe | -| frontend.readinessProbe.initialDelaySeconds | int | `10` | Delay in seconds after which an initial readiness probe is checked | -| frontend.readinessProbe.periodSeconds | int | `10` | Wait time in seconds between readiness probes | -| frontend.readinessProbe.successThreshold | int | `1` | Number of trys until a pod is marked ready | -| frontend.readinessProbe.timeoutSeconds | int | `1` | Timeout in seconds of the readiness probe | -| frontend.replicaCount | int | `1` | | -| frontend.resources.limits | object | `{"cpu":"600m","memory":"128Mi"}` | Maximum resource limits of CPU und memory | -| frontend.resources.requests | object | `{"cpu":"200m","memory":"128Mi"}` | Minimum requested resources for CPU und memory | -| frontend.securityContext | object | `{"allowPrivilegeEscalation":false,"runAsGroup":3000,"runAsNonRoot":true,"runAsUser":101}` | Security configurations | -| frontend.securityContext.allowPrivilegeEscalation | bool | `false` | Get more privileges than the parent process | -| frontend.securityContext.runAsGroup | int | `3000` | Configures the group id of a user for a run | -| frontend.securityContext.runAsNonRoot | bool | `true` | Configures the non-root privileges for a run | -| frontend.securityContext.runAsUser | int | `101` | Configures the user id for a run | -| frontend.service.port | int | `8080` | The port of the service | -| frontend.service.type | string | `"ClusterIP"` | Type of the service | -| frontend.serviceAccount.annotations | object | `{}` | Annotations to add to the service account | -| frontend.serviceAccount.create | bool | `true` | Specifies whether a service account should be created | -| frontend.serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | -| frontend.tolerations | list | `[]` | Constrains for tolerations | -| global.domain.backend.ingress | string | `"your-backend-host-address.com"` | | -| postgresql.auth.database | string | `"postgres"` | Name of the database. | -| postgresql.auth.existingSecret | string | `"secret-puris-postgres-init"` | Secret containing the password. For more information look into 'backend-secrets-postgres.yaml' file. | -| postgresql.auth.password | string | `""` | Password for the custom database user. Secret-key 'password' | -| postgresql.auth.passwordPostgres | string | `""` | Password for the database. Secret-key 'postgres-password'. | -| postgresql.auth.username | string | `"puris"` | Username for the custom database user. | -| postgresql.enabled | bool | `true` | Enable postgres by default, set to false to use existing postgres. Make sure to set backend.puris.jpa.hibernate.ddl-auto accordingly (by default database is created using hibernate ddl from backend). | -| postgresql.service | object | `{"ports":{"postgresql":5432}}` | Possibility to override the name nameOverride: "" | -| postgresql.service.ports.postgresql | int | `5432` | Port of postgres database. | +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| backend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution | list | `[{"podAffinityTerm":{"labelSelector":{"matchExpressions":[{"key":"app.kubernetes.io/name","operator":"DoesNotExist"}]},"topologyKey":"kubernetes.io/hostname"},"weight":100}]` | Rules for the scheduler to find a pod | +| backend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions | list | `[{"key":"app.kubernetes.io/name","operator":"DoesNotExist"}]` | Matching Expressions as key and operators for the pod affinity | +| backend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | Topology key of the Kubernetes cluster | +| backend.autoscaling.enabled | bool | `false` | Enable or disable the autoscaling of pods | +| backend.env | object | `{}` | Extra environment variables that will be passed onto the backend deployment pods | +| backend.image.pullPolicy | string | `"Always"` | THe policy for the image pull process | +| backend.image.repository | string | `"tractusx/app-puris-backend"` | Repository of the docker image | +| backend.image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. | +| backend.imagePullSecrets | list | `[]` | List of used secrets | +| backend.ingress.annotations | object | `{"kubernetes.io/ingress.class":"nginx","nginx.ingress.kubernetes.io/backend-protocol":"HTTP","nginx.ingress.kubernetes.io/force-ssl-redirect":"true","nginx.ingress.kubernetes.io/ssl-passthrough":"true"}` | Annotations for the Ingress controller | +| backend.ingress.annotations."kubernetes.io/ingress.class" | string | `"nginx"` | Kubernetes Ingress class annotation for direct bindings | +| backend.ingress.annotations."nginx.ingress.kubernetes.io/backend-protocol" | string | `"HTTP"` | The backend protocol type (e.g. HTTP) | +| backend.ingress.annotations."nginx.ingress.kubernetes.io/force-ssl-redirect" | string | `"true"` | Force redirects from HTTP to HTTPS | +| backend.ingress.annotations."nginx.ingress.kubernetes.io/ssl-passthrough" | string | `"true"` | Pass SSL traffic to the backend ports | +| backend.ingress.enabled | bool | `false` | Enable the Ingress | +| backend.ingress.hosts | list | `[{"host":"your-backend-host-address.com","paths":[{"path":"/","pathType":"ImplementationSpecific"}]}]` | Hosts for the Ingress controller | +| backend.ingress.tls | list | `[]` | TLS certificates for the Ingress controller | +| backend.livenessProbe | object | `{"failureThreshold":3,"initialDelaySeconds":120,"periodSeconds":25,"successThreshold":1,"timeoutSeconds":1}` | Checks whether a pod is alive or not | +| backend.livenessProbe.failureThreshold | int | `3` | Number of failures (threshold) for a liveness probe | +| backend.livenessProbe.initialDelaySeconds | int | `120` | Delay in seconds after which an initial liveness probe is checked | +| backend.livenessProbe.periodSeconds | int | `25` | Wait time in seconds between liveness probes | +| backend.livenessProbe.successThreshold | int | `1` | Number of trys until a pod is marked alive | +| backend.livenessProbe.timeoutSeconds | int | `1` | Timeout in seconds of the liveness probe | +| backend.nameOverride | string | `""` | Possibility to override the name | +| backend.nodeSelector | object | `{}` | Constrains for the node selector | +| backend.podAnnotations | object | `{}` | Annotations added to a running pod | +| backend.podSecurityContext | object | `{}` | Added security contexts for a pod | +| backend.puris.api.key | string | `"test"` | The API key of the PURIS application | +| backend.puris.api.rootDir | string | `"/catena"` | The root directory of the API | +| backend.puris.baseurl | string | `"your-backend-host-address.com"` | Base url of the PURIS backend | +| backend.puris.datasource.driverClassName | string | `"org.postgresql.Driver"` | Driver class name of the database | +| backend.puris.datasource.password | string | `""` | Password for the database user. Ignored if postgres.enabled is true. | +| backend.puris.datasource.url | string | `"jdbc:postgresql://postgresql-name:5432/puris-database"` | URL of the database. Ignored if postgres.enabled is true. | +| backend.puris.datasource.username | string | `"db-user"` | Username of the database. Ignored if postgres.enabled is true. | +| backend.puris.deliverysubmodel.apiassetid | string | `"deliverysubmodel-api-asset"` | Asset ID for DeliverySubmodel API | +| backend.puris.demandsubmodel.apiassetid | string | `"demandsubmodel-api-asset"` | Asset ID for DemandSubmodel API | +| backend.puris.demonstrator.role | string | `nil` | Current role of the PURIS demonstrator. Default value should be empty. Can be set to "customer" or "supplier" to enable demonstration setup | +| backend.puris.dtr.idp.clients.edc.id | string | `"FOSS-EDC-CLIENT"` | id of the client that has a service account with roles to view the DTR. Used by the application to create DTR asset in the edc with read only access. See Admin Guide. Mandatory if backend.puris.dtr.idp.enabled = true. | +| backend.puris.dtr.idp.clients.edc.secret.alias | string | `"path/secret-name"` | alias for the vault used by the EDC in which the secret is stored. Mandatory if backend.puris.dtr.idp.enabled = true. | +| backend.puris.dtr.idp.clients.puris.id | string | `"FOSS-PURIS-CLIENT"` | id of the client that has a service account with roles to manage the DTR. Used by the application to create and update digital twins. See Admin Guide. Mandatory if backend.puris.dtr.idp.enabled = true. | +| backend.puris.dtr.idp.clients.puris.secret | string | `""` | secret of the client with write access (no vault alias). No default value will be created if empty. Mandatory if backend.puris.dtr.idp.enabled = true. | +| backend.puris.dtr.idp.enabled | bool | `true` | enables the usage of the IDP for the DTR. | +| backend.puris.dtr.idp.tokenurl | string | `"https://keycloak-service.com/realms/your-realm/openid-connect/token"` | token url of the idp for your specific realm. May be different to other idp token url in this config. Mandatory if backend.puris.dtr.idp.enabled = true. | +| backend.puris.dtr.url | string | `"http://localhost:4243"` | Endpoint for DTR | +| backend.puris.edc.controlplane.host | string | `"172.17.0.2"` | | +| backend.puris.edc.controlplane.key | string | `"password"` | Key for the EDC control plane | +| backend.puris.edc.controlplane.management.url | string | `"https:/your-edc-address:8181/management"` | Url to the EDC controlplane management of the edc | +| backend.puris.edc.controlplane.protocol.url | string | `"https://your-edc-address:8184/api/v1/dsp"` | Url to the EDC controlplane protocol API of the edc | +| backend.puris.edc.dataplane.public.url | string | `"https://your-data-plane:8285/api/public/"` | Url of one of your data plane's public api | +| backend.puris.erpadapter.authkey | string | `"x-api-key"` | | +| backend.puris.erpadapter.authsecret | string | `"erp-password"` | | +| backend.puris.erpadapter.url | string | `"http://my-erpadapter:8080"` | | +| backend.puris.existingSecret | string | `"secret-puris-backend"` | Secret for backend passwords. For more information look into 'backend-secrets.yaml' file. | +| backend.puris.frameworkagreement.credential | string | `"Puris"` | The name of the framework agreement. Starting with Uppercase and using CamelCase. | +| backend.puris.frameworkagreement.version | string | `"1.0"` | The version of the framework agreement, NEEDS TO BE PUT AS "STRING"! | +| backend.puris.generatematerialcatenaxid | bool | `true` | Flag that decides whether the auto-generation feature of the puris backend is enabled. Since all Material entities are required to have a CatenaX-Id, you must enter any pre-existing CatenaX-Id via the materials-API of the backend, when you are inserting a new Material entity to the backend's database. If a CatenaX-Id was not assigned to your Material so far, then this feature can auto-generate one randomly. In a real-world-scenario, you must then use this randomly generated CatenaX-Id for the lifetime of that Material entity. | +| backend.puris.itemstocksubmodel.apiassetid | string | `"itemstocksubmodel-api-asset"` | Asset ID for ItemStockSubmodel API | +| backend.puris.jpa.hibernate.ddl-auto | string | `"create"` | Initialises SQL database with Hibernate property "create" to allow Hibernate to first drop all tables and then create new ones | +| backend.puris.jpa.properties.hibernate.enable_lazy_load_no_trans | bool | `true` | Enables "Lazy load no trans" property to fetch of each lazy entity to open a temporary session and run inside a separate transaction | +| backend.puris.own.bpna | string | `"BPNA4444444444ZZ"` | Own BPNA of the EDC | +| backend.puris.own.bpnl | string | `"BPNL4444444444XX"` | Own BPNL of the EDC | +| backend.puris.own.bpns | string | `"BPNS4444444444XX"` | Own BPNS of the EDC | +| backend.puris.own.country | string | `"Germany"` | Own country | +| backend.puris.own.name | string | `"YOUR-COMPANY-NAME"` | Own name (self-description) | +| backend.puris.own.site.name | string | `"YOUR-SITE-NAME"` | Own site name | +| backend.puris.own.streetnumber | string | `"Musterstraße 110A"` | Own street and number | +| backend.puris.own.zipcodeandcity | string | `"12345 Musterhausen"` | Own zipcode and city | +| backend.puris.productionsubmodel.apiassetid | string | `"productionsubmodel-api-asset"` | Asset ID for ProductionSubmodel API | +| backend.puris.purpose.name | string | `"cx.puris.base"` | The name of the purpose to use for submodel contracts | +| backend.puris.purpose.version | string | `"1"` | The version of the purpose to use for submodel contracts. NEEDS TO BE PUT AS "STRING"! | +| backend.readinessProbe | object | `{"failureThreshold":3,"initialDelaySeconds":120,"periodSeconds":25,"successThreshold":1,"timeoutSeconds":1}` | Checks if the pod is fully ready to operate | +| backend.readinessProbe.failureThreshold | int | `3` | Number of failures (threshold) for a readiness probe | +| backend.readinessProbe.initialDelaySeconds | int | `120` | Delay in seconds after which an initial readiness probe is checked | +| backend.readinessProbe.periodSeconds | int | `25` | Wait time in seconds between readiness probes | +| backend.readinessProbe.successThreshold | int | `1` | Number of trys until a pod is marked ready | +| backend.readinessProbe.timeoutSeconds | int | `1` | Timeout in seconds of the readiness probe | +| backend.replicaCount | int | `1` | Number of replicas of the Kubernetes deployment | +| backend.resources.limits | object | `{"cpu":"3000m","memory":"2048Mi"}` | Maximum resource limits of CPU und memory | +| backend.resources.requests | object | `{"cpu":"1000m","memory":"2048Mi"}` | Minimum requested resources for CPU und memory | +| backend.securityContext | object | `{"allowPrivilegeEscalation":false,"runAsGroup":3000,"runAsNonRoot":true,"runAsUser":8877}` | Security configurations | +| backend.securityContext.allowPrivilegeEscalation | bool | `false` | Get more privileges than the parent process | +| backend.securityContext.runAsGroup | int | `3000` | Configures the group id of a user for a run | +| backend.securityContext.runAsNonRoot | bool | `true` | Configures the non-root privileges for a run | +| backend.securityContext.runAsUser | int | `8877` | Configures the user id for a run | +| backend.service.port | int | `8081` | The port of the service | +| backend.service.type | string | `"ClusterIP"` | Type of the service | +| backend.serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| backend.serviceAccount.create | bool | `true` | Specifies whether a service account should be created | +| backend.serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| backend.tolerations | list | `[]` | Constrains for tolerations | +| frontend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution | list | `[{"podAffinityTerm":{"labelSelector":{"matchExpressions":[{"key":"app.kubernetes.io/name","operator":"DoesNotExist"}]},"topologyKey":"kubernetes.io/hostname"},"weight":100}]` | Rules for the scheduler to find a pod | +| frontend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions | list | `[{"key":"app.kubernetes.io/name","operator":"DoesNotExist"}]` | Matching Expressions as key and operators for the pod affinity | +| frontend.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.topologyKey | string | `"kubernetes.io/hostname"` | Topology key of the Kubernetes cluster | +| frontend.autoscaling.enabled | bool | `false` | Enable or disable the autoscaling of pods | +| frontend.autoscaling.maxReplicas | int | `100` | Number of maximum replica pods for autoscaling | +| frontend.autoscaling.minReplicas | int | `1` | Number of minimum replica pods for autoscaling | +| frontend.autoscaling.targetCPUUtilizationPercentage | int | `80` | Value of CPU usage in percentage for autoscaling decisions | +| frontend.env | object | `{}` | Extra environment variables that will be passed onto the frontend deployment pods | +| frontend.image.pullPolicy | string | `"IfNotPresent"` | THe policy for the image pull process | +| frontend.image.repository | string | `"tractusx/app-puris-frontend"` | Repository of the docker image | +| frontend.image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. | +| frontend.imagePullSecrets | list | `[]` | List of used secrets | +| frontend.ingress.annotations | object | `{}` | Annotations for the Ingress controller | +| frontend.ingress.className | string | `"nginx"` | Class name for the Ingress controller | +| frontend.ingress.enabled | bool | `false` | Enable the Ingress | +| frontend.ingress.hosts | list | `[{"host":"your-frontend-host-address.com","paths":[{"path":"/","pathType":"ImplementationSpecific"}]}]` | Hosts for the Ingress controller | +| frontend.ingress.tls | list | `[]` | TLS certificates for the Ingress controller | +| frontend.livenessProbe | object | `{"failureThreshold":3,"initialDelaySeconds":10,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":1}` | Checks whether a pod is alive or not | +| frontend.livenessProbe.failureThreshold | int | `3` | Number of failures (threshold) for a liveness probe | +| frontend.livenessProbe.initialDelaySeconds | int | `10` | Delay in seconds after which an initial liveness probe is checked | +| frontend.livenessProbe.periodSeconds | int | `10` | Wait time in seconds between liveness probes | +| frontend.livenessProbe.successThreshold | int | `1` | Number of trys until a pod is marked alive | +| frontend.livenessProbe.timeoutSeconds | int | `1` | Timeout in seconds of the liveness probe | +| frontend.nameOverride | string | `""` | Possibility to override the name | +| frontend.nodeSelector | object | `{}` | Constrains for the node selector | +| frontend.podAnnotations | object | `{}` | Annotations added to a running pod | +| frontend.podSecurityContext | object | `{}` | Added security contexts for a pod | +| frontend.puris.appName | string | `"PURIS"` | The name of the app displayed in the frontend | +| frontend.puris.baseUrl | string | `"your-backend-host-address.com"` | The base URL for the backend base URL without further endpoints | +| frontend.puris.endpointCustomer | string | `"stockView/customer?ownMaterialNumber="` | The endpoint for the customers who buy a material identified via the own material number for the stock view | +| frontend.puris.endpointDelivery | string | `"delivery"` | The endpoint for the delivery submodel | +| frontend.puris.endpointDemand | string | `"demand"` | The endpoint for the demand submodel | +| frontend.puris.endpointMaterialStocks | string | `"stockView/material-stocks"` | The endpoint for material stocks for the stock view | +| frontend.puris.endpointMaterials | string | `"stockView/materials"` | The endpoint for materials for the stock view | +| frontend.puris.endpointPartners | string | `"partners"` | The endpoint for partner information | +| frontend.puris.endpointProductStocks | string | `"stockView/product-stocks"` | The endpoint for product stocks for the stock view | +| frontend.puris.endpointProduction | string | `"production"` | The endpoint for the production submodel | +| frontend.puris.endpointProductionRange | string | `"production/range"` | The endpoint for the production range of the production submodel | +| frontend.puris.endpointProducts | string | `"stockView/products"` | The endpoint for products for the stock view | +| frontend.puris.endpointReportedMaterialStocks | string | `"stockView/reported-material-stocks?ownMaterialNumber="` | The endpoint for the partners' (supplier) material stocks that they potentially will deliver to me | +| frontend.puris.endpointReportedProductStocks | string | `"stockView/reported-product-stocks?ownMaterialNumber="` | The endpoint for the partners' (customer) product stocks that they received from me | +| frontend.puris.endpointSupplier | string | `"stockView/supplier?ownMaterialNumber="` | The endpoint for the suppliers who buy a material identified via the own material number for the stock view | +| frontend.puris.endpointUpdateReportedMaterialStocks | string | `"stockView/update-reported-material-stocks?ownMaterialNumber="` | The endpoint for triggering an update of your material stocks on your partners side | +| frontend.puris.endpointUpdateReportedProductStocks | string | `"stockView/update-reported-product-stocks?ownMaterialNumber="` | The endpoint for triggering an update of your product stocks on your partners side | +| frontend.puris.keycloak.clientId | string | `"appXYZ"` | Name of the client which is used for the application. | +| frontend.puris.keycloak.disabled | bool | `true` | Disable the Keycloak integration. | +| frontend.puris.keycloak.realm | string | `"Catena-X"` | Name of the Realm of the keycloak instance. | +| frontend.puris.keycloak.redirectUrlFrontend | string | `"https://your-frontend-url.com"` | URL to use as keycloak redirect url. | +| frontend.puris.keycloak.url | string | `"https://idp.com/auth"` | The URL to the IDP that should be used. | +| frontend.puris.rateLimiting.burst | int | `30` | Burst rate limiting for nginx. | +| frontend.puris.rateLimiting.limit | string | `"10m"` | Bucket zone limit for rate limiting in nginx. | +| frontend.puris.rateLimiting.rate | string | `"10r/s"` | Allowed rates per second for nginx rate limiting. | +| frontend.readinessProbe | object | `{"failureThreshold":3,"initialDelaySeconds":10,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":1}` | Checks if the pod is fully ready to operate | +| frontend.readinessProbe.failureThreshold | int | `3` | Number of failures (threshold) for a readiness probe | +| frontend.readinessProbe.initialDelaySeconds | int | `10` | Delay in seconds after which an initial readiness probe is checked | +| frontend.readinessProbe.periodSeconds | int | `10` | Wait time in seconds between readiness probes | +| frontend.readinessProbe.successThreshold | int | `1` | Number of trys until a pod is marked ready | +| frontend.readinessProbe.timeoutSeconds | int | `1` | Timeout in seconds of the readiness probe | +| frontend.replicaCount | int | `1` | | +| frontend.resources.limits | object | `{"cpu":"600m","memory":"128Mi"}` | Maximum resource limits of CPU und memory | +| frontend.resources.requests | object | `{"cpu":"200m","memory":"128Mi"}` | Minimum requested resources for CPU und memory | +| frontend.securityContext | object | `{"allowPrivilegeEscalation":false,"runAsGroup":3000,"runAsNonRoot":true,"runAsUser":101}` | Security configurations | +| frontend.securityContext.allowPrivilegeEscalation | bool | `false` | Get more privileges than the parent process | +| frontend.securityContext.runAsGroup | int | `3000` | Configures the group id of a user for a run | +| frontend.securityContext.runAsNonRoot | bool | `true` | Configures the non-root privileges for a run | +| frontend.securityContext.runAsUser | int | `101` | Configures the user id for a run | +| frontend.service.port | int | `8080` | The port of the service | +| frontend.service.type | string | `"ClusterIP"` | Type of the service | +| frontend.serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| frontend.serviceAccount.create | bool | `true` | Specifies whether a service account should be created | +| frontend.serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| frontend.tolerations | list | `[]` | Constrains for tolerations | +| global.domain.backend.ingress | string | `"your-backend-host-address.com"` | | +| postgresql.auth.database | string | `"postgres"` | Name of the database. | +| postgresql.auth.existingSecret | string | `"secret-puris-postgres-init"` | Secret containing the password. For more information look into 'backend-secrets-postgres.yaml' file. | +| postgresql.auth.password | string | `""` | Password for the custom database user. Secret-key 'password' | +| postgresql.auth.passwordPostgres | string | `""` | Password for the database. Secret-key 'postgres-password'. | +| postgresql.auth.username | string | `"puris"` | Username for the custom database user. | +| postgresql.enabled | bool | `true` | Enable postgres by default, set to false to use existing postgres. Make sure to set backend.puris.jpa.hibernate.ddl-auto accordingly (by default database is created using hibernate ddl from backend). | +| postgresql.service | object | `{"ports":{"postgresql":5432}}` | Possibility to override the name nameOverride: "" | +| postgresql.service.ports.postgresql | int | `5432` | Port of postgres database. | ## NOTICE diff --git a/charts/puris/templates/backend-deployment.yaml b/charts/puris/templates/backend-deployment.yaml index 21071f28..e52839c7 100644 --- a/charts/puris/templates/backend-deployment.yaml +++ b/charts/puris/templates/backend-deployment.yaml @@ -168,6 +168,13 @@ spec: key: "puris-dtr-idp-puris-client-secret" - name: PURIS_GENERATEMATERIALCATENAXID value: "{{ .Values.backend.puris.generatematerialcatenaxid | default true}}" + - name: PURIS_ERPADAPTER_URL + value: "{{ .Values.backend.puris.erpadapter.url}}" + - name: PURIS_ERPADAPTER_AUTHKEY + value: "{{ .Values.backend.puris.erpadapter.authkey}}" + - name: PURIS_ERPADAPTER_AUTHSECRET + value: "{{ .Values.backend.puris.erpadapter.authsecret}}" + ###################################### ## Additional environment variables ## ###################################### diff --git a/charts/puris/values.yaml b/charts/puris/values.yaml index 63651bf4..433f4f76 100644 --- a/charts/puris/values.yaml +++ b/charts/puris/values.yaml @@ -471,6 +471,10 @@ backend: # In a real-world-scenario, you must then use this randomly generated CatenaX-Id for the lifetime of that # Material entity. generatematerialcatenaxid: true + erpadapter: + url: http://my-erpadapter:8080 + authkey: x-api-key + authsecret: erp-password # -- Extra environment variables that will be passed onto the backend deployment pods env: {} diff --git a/local/tractus-x-edc/config/customer/puris-backend.properties b/local/tractus-x-edc/config/customer/puris-backend.properties index 20cd322c..6a639d2b 100644 --- a/local/tractus-x-edc/config/customer/puris-backend.properties +++ b/local/tractus-x-edc/config/customer/puris-backend.properties @@ -22,6 +22,10 @@ puris.dtr.idp.edc-client.id=${KC_MANAGE_CLIENT_ID} puris.dtr.idp.edc-client.secret.alias=${CUSTOMER_KC_DTR_PURIS_CLIENT_ALIAS} puris.dtr.idp.puris-client.id=${KC_MANAGE_CLIENT_ID} puris.dtr.idp.puris-client.secret=${CUSTOMER_KC_DTR_PURIS_CLIENT_SECRET} + +puris.erpadapter.url=http://my-erpadapter:8080 +puris.erpadapter.authkey=x-api-key +puris.erpadapter.authsecret=erp-password # edc.controlplane.key=${EDC_API_PW} edc.controlplane.management.url=http://customer-control-plane:8181/management diff --git a/local/tractus-x-edc/config/supplier/puris-backend.properties b/local/tractus-x-edc/config/supplier/puris-backend.properties index 65aaa222..712b4eb2 100644 --- a/local/tractus-x-edc/config/supplier/puris-backend.properties +++ b/local/tractus-x-edc/config/supplier/puris-backend.properties @@ -22,6 +22,10 @@ puris.dtr.idp.edc-client.id=${KC_MANAGE_CLIENT_ID} puris.dtr.idp.edc-client.secret.alias=${SUPPLIER_KC_DTR_PURIS_CLIENT_ALIAS} puris.dtr.idp.puris-client.id=${KC_MANAGE_CLIENT_ID} puris.dtr.idp.puris-client.secret=${SUPPLIER_KC_DTR_PURIS_CLIENT_SECRET} + +puris.erpadapter.url=http://my-erpadapter:8080 +puris.erpadapter.authkey=x-api-key +puris.erpadapter.authsecret=erp-password # edc.controlplane.key=${EDC_API_PW} edc.controlplane.management.url=http://supplier-control-plane:9181/management From 2f3875b56f700b7847eb92a2a2fd9a94a974bb6b Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Wed, 12 Jun 2024 12:10:00 +0200 Subject: [PATCH 02/10] feat: added unit test --- .../service/ErpAdapterRequestClient.java | 6 +- .../service/ErpAdapterRequestService.java | 9 +- .../service/ErpAdapterRequestClientTest.java | 110 ++++++++++++++++++ 3 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java index d83a7ed4..ce07b556 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java @@ -2,25 +2,25 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import okhttp3.*; import org.eclipse.tractusx.puris.backend.common.util.VariablesService; import org.eclipse.tractusx.puris.backend.erpadapter.domain.model.ErpAdapterRequest; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.IOException; @Service @Slf4j +@RequiredArgsConstructor public class ErpAdapterRequestClient { private final OkHttpClient client = new OkHttpClient(); private final ObjectMapper mapper = new ObjectMapper(); - @Autowired - private VariablesService variablesService; + private final VariablesService variablesService; public Integer sendRequest(ErpAdapterRequest erpAdapterRequest){ HttpUrl.Builder urlBuilder = HttpUrl.parse(variablesService.getErpAdapterUrl()).newBuilder(); diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java index 1d355dce..c37c2bb2 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java @@ -20,23 +20,22 @@ package org.eclipse.tractusx.puris.backend.erpadapter.logic.service; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.eclipse.tractusx.puris.backend.erpadapter.domain.model.ErpAdapterRequest; import org.eclipse.tractusx.puris.backend.erpadapter.domain.repository.ErpAdapterRequestRepository; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.UUID; @Service @Slf4j +@RequiredArgsConstructor public class ErpAdapterRequestService { - @Autowired - private ErpAdapterRequestRepository repository; + private final ErpAdapterRequestRepository repository; - @Autowired - private ErpAdapterRequestClient erpAdapterRequestClient; + private final ErpAdapterRequestClient erpAdapterRequestClient; public ErpAdapterRequest create(ErpAdapterRequest erpAdapterRequest) { if (erpAdapterRequest.getId() != null && repository.existsById(erpAdapterRequest.getId())) { diff --git a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java new file mode 100644 index 00000000..e0241f06 --- /dev/null +++ b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java @@ -0,0 +1,110 @@ +package org.eclipse.tractusx.puris.backend.erpadapter.logic.service; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.assertj.core.api.Assertions; +import org.eclipse.tractusx.puris.backend.common.util.VariablesService; +import org.eclipse.tractusx.puris.backend.erpadapter.domain.model.ErpAdapterRequest; +import org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm.DirectionCharacteristic; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.io.InputStream; +import java.util.Date; +import java.util.UUID; + +@ExtendWith(MockitoExtension.class) +public class ErpAdapterRequestClientTest { + + private MockWebServer mockWebServer; + + @Mock + private VariablesService variablesService; + + @InjectMocks + private ErpAdapterRequestClient erpAdapterRequestClient; + + private static final String erpResponseUrl = "http://localhost:8081/catena/erpadapter"; + + private static final String matNbrCustomer = "MNR-7307-AU340474.002"; + + private static final String supplierPartnerBpnl = "BPNL1234567890ZZ"; + + private static final ObjectMapper objectMapper = new ObjectMapper(); + + private static final String apiKey = "x-api-key"; + + private static final String apiSecret = "my-secret"; + + private static final String requestType = "itemstock"; + + private static final String sammVersion = "2.0"; + + @BeforeEach + public void setUp() throws Exception { + mockWebServer = new MockWebServer(); + mockWebServer.start(); + erpAdapterRequestClient = new ErpAdapterRequestClient(variablesService); + + } + + @AfterEach + public void tearDown() throws Exception { + mockWebServer.shutdown(); + } + + private void prepareVariablesService() { + Mockito.when(variablesService.getErpAdapterUrl()).thenReturn(mockWebServer.url("/").toString()); + Mockito.when(variablesService.getErpAdapterAuthKey()).thenReturn(apiKey); + Mockito.when(variablesService.getErpAdapterAuthSecret()).thenReturn(apiSecret); + Mockito.when(variablesService.getErpResponseUrl()).thenReturn(erpResponseUrl); + } + + @Test + public void test_should_success() throws Exception { + // given + UUID uuid = UUID.randomUUID(); + ErpAdapterRequest erpAdapterRequest = ErpAdapterRequest.builder() + .requestDate(new Date()) + .partnerBpnl(supplierPartnerBpnl) + .id(uuid) + .directionCharacteristic(DirectionCharacteristic.INBOUND) + .ownMaterialNumber(matNbrCustomer) + .requestType(requestType) + .sammVersion(sammVersion) + .build(); + + // when + prepareVariablesService(); + erpAdapterRequestClient.sendRequest(erpAdapterRequest); + RecordedRequest request = mockWebServer.takeRequest(); + + // then + Assertions.assertThat(request.getMethod()).isEqualTo("POST"); + + Assertions.assertThat(request.getHeader(apiKey)).isEqualTo(apiSecret); + Assertions.assertThat(request.getHeader("Content-type")).contains("application/json"); + + Assertions.assertThat(request.getPath()).contains(supplierPartnerBpnl); + Assertions.assertThat(request.getPath()).contains(requestType); + Assertions.assertThat(request.getPath()).contains(sammVersion); + Assertions.assertThat(request.getPath()).contains(uuid.toString()); + + try (InputStream stream = request.getBody().inputStream()) { + JsonNode requestBodyNode = objectMapper.readTree(new String(stream.readAllBytes())); + Assertions.assertThat(requestBodyNode.get("material").asText()).isEqualTo(matNbrCustomer); + Assertions.assertThat(requestBodyNode.get("direction").asText()).isEqualTo(DirectionCharacteristic.INBOUND.toString()); + Assertions.assertThat(requestBodyNode.get("response-url").asText()).isEqualTo(erpResponseUrl); + } + + + } +} From b2692c8a561754b2fd91a5bdc2c4bcb111842083 Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Wed, 12 Jun 2024 12:15:22 +0200 Subject: [PATCH 03/10] chore: added license headers --- .../service/ErpAdapterRequestClient.java | 20 +++++++++++++++++++ .../service/ErpAdapterRequestClientTest.java | 20 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java index ce07b556..27344182 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java @@ -1,3 +1,23 @@ +/* + * Copyright (c) 2024 Volkswagen AG + * 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 + */ + package org.eclipse.tractusx.puris.backend.erpadapter.logic.service; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java index e0241f06..c8754e3e 100644 --- a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java +++ b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java @@ -1,3 +1,23 @@ +/* + * Copyright (c) 2024 Volkswagen AG + * 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 + */ + package org.eclipse.tractusx.puris.backend.erpadapter.logic.service; import com.fasterxml.jackson.databind.JsonNode; From 55359cbf2ce7b66259f92a1be401d71ab048bd4a Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Wed, 12 Jun 2024 12:25:09 +0200 Subject: [PATCH 04/10] chore: updated chart version nbr --- charts/puris/Chart.yaml | 2 +- charts/puris/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/puris/Chart.yaml b/charts/puris/Chart.yaml index f95fbeac..d79e0ccc 100644 --- a/charts/puris/Chart.yaml +++ b/charts/puris/Chart.yaml @@ -35,7 +35,7 @@ dependencies: # 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: 2.6.3 +version: 2.6.4 # 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 diff --git a/charts/puris/README.md b/charts/puris/README.md index 6080739d..2e6c056f 100644 --- a/charts/puris/README.md +++ b/charts/puris/README.md @@ -1,6 +1,6 @@ # puris -![Version: 2.6.3](https://img.shields.io/badge/Version-2.6.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.0.2](https://img.shields.io/badge/AppVersion-2.0.2-informational?style=flat-square) +![Version: 2.6.4](https://img.shields.io/badge/Version-2.6.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.0.2](https://img.shields.io/badge/AppVersion-2.0.2-informational?style=flat-square) A helm chart for Kubernetes deployment of PURIS From e0d2649d5a99ebc3ea1053857b3f152715dd72f9 Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Thu, 13 Jun 2024 10:56:53 +0200 Subject: [PATCH 05/10] fix: review fixes --- .../service/ErpAdapterRequestClient.java | 7 +-- .../service/ErpAdapterRequestService.java | 6 +- .../service/ErpAdapterRequestClientTest.java | 63 +++++++++++++++---- .../puris/templates/backend-deployment.yaml | 11 +++- charts/puris/templates/backend-secrets.yaml | 2 + charts/puris/values.yaml | 3 + 6 files changed, 70 insertions(+), 22 deletions(-) diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java index 27344182..cd25a5dd 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java @@ -48,13 +48,13 @@ public Integer sendRequest(ErpAdapterRequest erpAdapterRequest){ urlBuilder.addQueryParameter("request-type", erpAdapterRequest.getRequestType()); urlBuilder.addQueryParameter("request-id", erpAdapterRequest.getId().toString()); urlBuilder.addQueryParameter("samm-version", erpAdapterRequest.getSammVersion()); - urlBuilder.addQueryParameter("request-timestamp", erpAdapterRequest.getRequestDate().toString()); + urlBuilder.addQueryParameter("request-timestamp", String.valueOf(erpAdapterRequest.getRequestDate().getTime())); ObjectNode requestBody = mapper.createObjectNode(); requestBody.put("material", erpAdapterRequest.getOwnMaterialNumber()); requestBody.put("direction", erpAdapterRequest.getDirectionCharacteristic().toString()); - requestBody.put("response-url", variablesService.getErpResponseUrl()); + requestBody.put("responseUrl", variablesService.getErpResponseUrl()); RequestBody body = RequestBody.create(requestBody.toString(), MediaType.parse("application/json")); @@ -64,8 +64,7 @@ public Integer sendRequest(ErpAdapterRequest erpAdapterRequest){ .header(variablesService.getErpAdapterAuthKey(), variablesService.getErpAdapterAuthSecret()) .header("Content-Type", "application/json") .build(); - try { - var response = client.newCall(request).execute(); + try (var response = client.newCall(request).execute()) { return response.code(); } catch (IOException e) { log.error("Error while sending ErpAdapterRequest", e); diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java index c37c2bb2..3c7ec974 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestService.java @@ -51,14 +51,14 @@ public void createAndSend(ErpAdapterRequest erpAdapterRequest) { Integer responseCode = erpAdapterRequestClient.sendRequest(erpAdapterRequest); if (responseCode != null) { if (responseCode >= 200 && responseCode < 400) { - log.info("Successfully sent request to ERP Adapter"); + log.info("Successfully sent request to ERP Adapter, got status code {} for request:\n{}", responseCode, erpAdapterRequest); } else { - log.warn("Received status code {} from ERP Adapter ", responseCode); + log.warn("Received status code {} from ERP Adapter for request:\n{}", responseCode, erpAdapterRequest); } erpAdapterRequest.setResponseCode(responseCode); update(erpAdapterRequest); } else { - log.error("Failed to send request to ERP Adapter"); + log.error("Failed to send request to ERP Adapter:\n{}", erpAdapterRequest); } } } diff --git a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java index c8754e3e..58df1ab3 100644 --- a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java +++ b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java @@ -39,7 +39,11 @@ import java.io.InputStream; import java.util.Date; +import java.util.Map; import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; +import java.util.stream.Stream; @ExtendWith(MockitoExtension.class) public class ErpAdapterRequestClientTest { @@ -81,12 +85,6 @@ public void tearDown() throws Exception { mockWebServer.shutdown(); } - private void prepareVariablesService() { - Mockito.when(variablesService.getErpAdapterUrl()).thenReturn(mockWebServer.url("/").toString()); - Mockito.when(variablesService.getErpAdapterAuthKey()).thenReturn(apiKey); - Mockito.when(variablesService.getErpAdapterAuthSecret()).thenReturn(apiSecret); - Mockito.when(variablesService.getErpResponseUrl()).thenReturn(erpResponseUrl); - } @Test public void test_should_success() throws Exception { @@ -103,9 +101,12 @@ public void test_should_success() throws Exception { .build(); // when - prepareVariablesService(); + Mockito.when(variablesService.getErpAdapterUrl()).thenReturn(mockWebServer.url("/").toString()); + Mockito.when(variablesService.getErpAdapterAuthKey()).thenReturn(apiKey); + Mockito.when(variablesService.getErpAdapterAuthSecret()).thenReturn(apiSecret); + Mockito.when(variablesService.getErpResponseUrl()).thenReturn(erpResponseUrl); erpAdapterRequestClient.sendRequest(erpAdapterRequest); - RecordedRequest request = mockWebServer.takeRequest(); + RecordedRequest request = mockWebServer.takeRequest(2, TimeUnit.SECONDS); // then Assertions.assertThat(request.getMethod()).isEqualTo("POST"); @@ -113,18 +114,54 @@ public void test_should_success() throws Exception { Assertions.assertThat(request.getHeader(apiKey)).isEqualTo(apiSecret); Assertions.assertThat(request.getHeader("Content-type")).contains("application/json"); - Assertions.assertThat(request.getPath()).contains(supplierPartnerBpnl); - Assertions.assertThat(request.getPath()).contains(requestType); - Assertions.assertThat(request.getPath()).contains(sammVersion); - Assertions.assertThat(request.getPath()).contains(uuid.toString()); + var pairs = request.getPath().substring(2).split("&"); + Map parameters = Stream.of(pairs) + .map(string -> { + var keyValue = string.split("="); + return Map.entry(keyValue[0], keyValue[1]); + }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Assertions.assertThat(parameters.size()).isEqualTo(5); + Assertions.assertThat(parameters.get("bpnl")).isEqualTo(supplierPartnerBpnl); + Assertions.assertThat(parameters.get("request-type")).isEqualTo(requestType); + Assertions.assertThat(parameters.get("samm-version")).isEqualTo(sammVersion); + Assertions.assertThat(parameters.get("request-timestamp")).isEqualTo(String.valueOf(erpAdapterRequest.getRequestDate().getTime())); + Assertions.assertThat(parameters.get("request-id")).isEqualTo(uuid.toString()); + try (InputStream stream = request.getBody().inputStream()) { JsonNode requestBodyNode = objectMapper.readTree(new String(stream.readAllBytes())); Assertions.assertThat(requestBodyNode.get("material").asText()).isEqualTo(matNbrCustomer); Assertions.assertThat(requestBodyNode.get("direction").asText()).isEqualTo(DirectionCharacteristic.INBOUND.toString()); - Assertions.assertThat(requestBodyNode.get("response-url").asText()).isEqualTo(erpResponseUrl); + Assertions.assertThat(requestBodyNode.get("responseUrl").asText()).isEqualTo(erpResponseUrl); } + } + @Test + public void test_with_faulty_credentials_should_fail() throws Exception { + // given + UUID uuid = UUID.randomUUID(); + ErpAdapterRequest erpAdapterRequest = ErpAdapterRequest.builder() + .requestDate(new Date()) + .partnerBpnl(supplierPartnerBpnl) + .id(uuid) + .directionCharacteristic(DirectionCharacteristic.INBOUND) + .ownMaterialNumber(matNbrCustomer) + .requestType(requestType) + .sammVersion(sammVersion) + .build(); + + // when + Mockito.when(variablesService.getErpAdapterUrl()).thenReturn(mockWebServer.url("/").toString()); + Mockito.when(variablesService.getErpAdapterAuthKey()).thenReturn("wrong-key"); + Mockito.when(variablesService.getErpAdapterAuthSecret()).thenReturn(apiSecret); + Mockito.when(variablesService.getErpResponseUrl()).thenReturn(erpResponseUrl); + erpAdapterRequestClient.sendRequest(erpAdapterRequest); + RecordedRequest request = mockWebServer.takeRequest(2, TimeUnit.SECONDS); + // then + Assertions.assertThat(request.getMethod()).isEqualTo("POST"); + Assertions.assertThat(request.getHeader("Content-type")).contains("application/json"); + Assertions.assertThat(request.getHeader(apiKey)).isNotEqualTo(apiSecret); } } diff --git a/charts/puris/templates/backend-deployment.yaml b/charts/puris/templates/backend-deployment.yaml index e52839c7..20c36a70 100644 --- a/charts/puris/templates/backend-deployment.yaml +++ b/charts/puris/templates/backend-deployment.yaml @@ -171,9 +171,16 @@ spec: - name: PURIS_ERPADAPTER_URL value: "{{ .Values.backend.puris.erpadapter.url}}" - name: PURIS_ERPADAPTER_AUTHKEY - value: "{{ .Values.backend.puris.erpadapter.authkey}}" +{{/* value: "{{ .Values.backend.puris.erpadapter.authkey}}"*/}} + valueFrom: + secretKeyRef: + name: "{{ .Values.backend.puris.existingSecret }}" + key: "puris-erpadapter-authkey" - name: PURIS_ERPADAPTER_AUTHSECRET - value: "{{ .Values.backend.puris.erpadapter.authsecret}}" + valueFrom: + secretKeyRef: + name: "{{ .Values.backend.puris.existingSecret }}" + key: "puris-erpadapter-authsecret" ###################################### ## Additional environment variables ## diff --git a/charts/puris/templates/backend-secrets.yaml b/charts/puris/templates/backend-secrets.yaml index 462879e4..e386c1d3 100644 --- a/charts/puris/templates/backend-secrets.yaml +++ b/charts/puris/templates/backend-secrets.yaml @@ -17,6 +17,8 @@ data: puris-datasource-password: {{ (.Values.backend.puris.datasource.password | b64enc) | default (index $secret.data "puris-datasource-password") | quote }} puris-edc-controlplane-key: {{ (.Values.backend.puris.edc.controlplane.key | b64enc) | default (index $secret.data "puris-edc-controlplane-key") | quote }} puris-dtr-idp-puris-client-secret: {{ (.Values.backend.puris.dtr.idp.clients.puris.secret | b64enc) | default (index $secret.data "puris-dtr-idp-puris-client-secret") | quote }} + puris-erpadapter-authkey: {{ (.Values.backend.puris.erpadapter.authkey | b64enc) default (index $secret.data "puris-erpadapter-authkey") | quote }} + puris-erpadapter-authsecret: {{ (.Values.backend.puris.erpadapter.authsecret | b64enc) default (index $secret.data "puris-erpadapter-authsecret") | quote }} {{ else -}} stringData: # if secret doesn't exist, use provided value from values file or generate a random one diff --git a/charts/puris/values.yaml b/charts/puris/values.yaml index 433f4f76..ee684248 100644 --- a/charts/puris/values.yaml +++ b/charts/puris/values.yaml @@ -472,8 +472,11 @@ backend: # Material entity. generatematerialcatenaxid: true erpadapter: + # The url of your ERP adapter's request api url: http://my-erpadapter:8080 + # The auth key to be used on your ERP adapter's request api authkey: x-api-key + # The auth secret to be used on your ERP adapter's request api authsecret: erp-password # -- Extra environment variables that will be passed onto the backend deployment pods From 992d60aaa01bc1eda657b3f74e65eecb6f5291cd Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Thu, 13 Jun 2024 11:08:31 +0200 Subject: [PATCH 06/10] fix: syntax in yaml --- charts/puris/templates/backend-deployment.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/charts/puris/templates/backend-deployment.yaml b/charts/puris/templates/backend-deployment.yaml index 20c36a70..481138b8 100644 --- a/charts/puris/templates/backend-deployment.yaml +++ b/charts/puris/templates/backend-deployment.yaml @@ -171,7 +171,6 @@ spec: - name: PURIS_ERPADAPTER_URL value: "{{ .Values.backend.puris.erpadapter.url}}" - name: PURIS_ERPADAPTER_AUTHKEY -{{/* value: "{{ .Values.backend.puris.erpadapter.authkey}}"*/}} valueFrom: secretKeyRef: name: "{{ .Values.backend.puris.existingSecret }}" From f2a0c526f22bf7c1de520049a2d4df3e808315d4 Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Thu, 13 Jun 2024 11:54:16 +0200 Subject: [PATCH 07/10] fix: added default string data --- charts/puris/templates/backend-secrets.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/puris/templates/backend-secrets.yaml b/charts/puris/templates/backend-secrets.yaml index e386c1d3..22d024de 100644 --- a/charts/puris/templates/backend-secrets.yaml +++ b/charts/puris/templates/backend-secrets.yaml @@ -27,4 +27,6 @@ stringData: puris-edc-controlplane-key: {{ .Values.backend.puris.edc.controlplane.key | default ( randAlphaNum 32 ) | quote }} # don't generate a random one as this is set in identity provider puris-dtr-idp-puris-client-secret: {{ .Values.backend.puris.dtr.idp.clients.puris.secret | quote }} + puris-erpadapter-authkey: {{ .Values.backend.puris.erpadapter.authkey | default ("x-api-key") | quote }} + puris-erpadapter-authsecret: {{ .Values.backend.puris.erpadapter.authkey | default ( randAlphaNum 32 ) | quote }} {{ end }} From 345b56912dd006ea587aa75a63ec315f33d162fc Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Fri, 14 Jun 2024 08:45:41 +0200 Subject: [PATCH 08/10] fix: review issues --- .../ErpAdapterSecurityConfiguration.java | 44 +++++++++++++++++ .../backend/common/util/VariablesService.java | 27 ---------- .../service/ErpAdapterRequestClient.java | 10 ++-- .../src/main/resources/application.properties | 1 + .../service/ErpAdapterRequestClientTest.java | 49 ++++--------------- .../src/test/resources/application.properties | 4 +- charts/puris/README.md | 1 + .../puris/templates/backend-deployment.yaml | 7 ++- charts/puris/templates/backend-secrets.yaml | 2 - charts/puris/values.yaml | 2 + 10 files changed, 69 insertions(+), 78 deletions(-) create mode 100644 backend/src/main/java/org/eclipse/tractusx/puris/backend/common/security/ErpAdapterSecurityConfiguration.java diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/security/ErpAdapterSecurityConfiguration.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/security/ErpAdapterSecurityConfiguration.java new file mode 100644 index 00000000..93ab5ee5 --- /dev/null +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/security/ErpAdapterSecurityConfiguration.java @@ -0,0 +1,44 @@ +package org.eclipse.tractusx.puris.backend.common.security; + +import lombok.Getter; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +@Configuration +@Getter +public class ErpAdapterSecurityConfiguration { + + + /** + * Toggles usage of the ERP adapter + */ + @Value("${puris.erpadapter.enabled}") + private boolean erpAdapterEnabled; + + /** + * The URL of the ERP adapter + */ + @Value("${puris.erpadapter.url}") + private String erpAdapterUrl; + + /** + * The URL under which we expect responses from + * the ERP adapter + */ + @Value("${puris.baseurl}" + "catena/erp-adapter") + private String erpResponseUrl; + + /** + * The auth-key used when accessing the ERP adapter's + * request interface + */ + @Value("${puris.erpadapter.authkey}") + private String erpAdapterAuthKey; + + /** + * The auth-secret used when accessing the ERP adapter's + * request interface + */ + @Value("${puris.erpadapter.authsecret}") + private String erpAdapterAuthSecret; +} diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java index c5f3c7b8..9f51420e 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java @@ -50,33 +50,6 @@ public class VariablesService { */ private String demoRole; - @Value("${puris.erpadapter.url}") - /** - * The URL of the ERP adapter - */ - private String erpAdapterUrl; - - /** - * The URL under which we expect responses from - * the ERP adapter - */ - @Value("${puris.baseurl}" + "catena/erp-adapter") - private String erpResponseUrl; - - /** - * The auth-key used when accessing the ERP adapter's - * request interface - */ - @Value("${puris.erpadapter.authkey}") - private String erpAdapterAuthKey; - - /** - * The auth-secret used when accessing the ERP adapter's - * request interface - */ - @Value("${puris.erpadapter.authsecret}") - private String erpAdapterAuthSecret; - @Value("${puris.baseurl}" + "catena/item-stock/request") /** * The url under which this application's request endpoint can diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java index cd25a5dd..229e45c2 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java @@ -25,7 +25,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import okhttp3.*; -import org.eclipse.tractusx.puris.backend.common.util.VariablesService; +import org.eclipse.tractusx.puris.backend.common.security.ErpAdapterSecurityConfiguration; import org.eclipse.tractusx.puris.backend.erpadapter.domain.model.ErpAdapterRequest; import org.springframework.stereotype.Service; @@ -40,10 +40,10 @@ public class ErpAdapterRequestClient { private final ObjectMapper mapper = new ObjectMapper(); - private final VariablesService variablesService; + private final ErpAdapterSecurityConfiguration erpAdapterSecurityConfiguration; public Integer sendRequest(ErpAdapterRequest erpAdapterRequest){ - HttpUrl.Builder urlBuilder = HttpUrl.parse(variablesService.getErpAdapterUrl()).newBuilder(); + HttpUrl.Builder urlBuilder = HttpUrl.parse(erpAdapterSecurityConfiguration.getErpAdapterUrl()).newBuilder(); urlBuilder.addQueryParameter("bpnl", erpAdapterRequest.getPartnerBpnl()); urlBuilder.addQueryParameter("request-type", erpAdapterRequest.getRequestType()); urlBuilder.addQueryParameter("request-id", erpAdapterRequest.getId().toString()); @@ -54,14 +54,14 @@ public Integer sendRequest(ErpAdapterRequest erpAdapterRequest){ requestBody.put("material", erpAdapterRequest.getOwnMaterialNumber()); requestBody.put("direction", erpAdapterRequest.getDirectionCharacteristic().toString()); - requestBody.put("responseUrl", variablesService.getErpResponseUrl()); + requestBody.put("responseUrl", erpAdapterSecurityConfiguration.getErpResponseUrl()); RequestBody body = RequestBody.create(requestBody.toString(), MediaType.parse("application/json")); Request request = new Request.Builder() .post(body) .url(urlBuilder.build()) - .header(variablesService.getErpAdapterAuthKey(), variablesService.getErpAdapterAuthSecret()) + .header(erpAdapterSecurityConfiguration.getErpAdapterAuthKey(), erpAdapterSecurityConfiguration.getErpAdapterAuthSecret()) .header("Content-Type", "application/json") .build(); try (var response = client.newCall(request).execute()) { diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 8d7976f2..970f0432 100755 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -21,6 +21,7 @@ puris.dtr.idp.edc-client.id=${PURIS_DTR_IDP_EDC-CLIENT_ID:FOSS-DTR-CLIENT} puris.dtr.idp.edc-client.secret.alias=${PURIS_DTR_IDP_EDC-CLIENT_SECRET_ALIAS} puris.dtr.idp.puris-client.id=${PURIS_DTR_IDP_PURIS-CLIENT_ID:FOSS-DTR-CLIENT} puris.dtr.idp.puris-client.secret=${PURIS_DTR_IDP_PURIS-CLIENT_SECRET} +puris.erpadapter.enabled=${PURIS_ERPADAPTER_ENABLED:false} puris.erpadapter.url=${PURIS_ERPADAPTER_URL:http://my-erpadapter:8080} puris.erpadapter.authkey=${PURIS_ERPADAPTER_AUTHKEY:x-api-key} puris.erpadapter.authsecret=${PURIS_ERPADAPTER_AUTHSECRET:erp-password} diff --git a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java index 58df1ab3..ef9ed9b6 100644 --- a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java +++ b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java @@ -25,7 +25,7 @@ import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; import org.assertj.core.api.Assertions; -import org.eclipse.tractusx.puris.backend.common.util.VariablesService; +import org.eclipse.tractusx.puris.backend.common.security.ErpAdapterSecurityConfiguration; import org.eclipse.tractusx.puris.backend.erpadapter.domain.model.ErpAdapterRequest; import org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm.DirectionCharacteristic; import org.junit.jupiter.api.AfterEach; @@ -50,8 +50,9 @@ public class ErpAdapterRequestClientTest { private MockWebServer mockWebServer; + @Mock - private VariablesService variablesService; + private ErpAdapterSecurityConfiguration erpAdapterSecurityConfiguration; @InjectMocks private ErpAdapterRequestClient erpAdapterRequestClient; @@ -76,7 +77,7 @@ public class ErpAdapterRequestClientTest { public void setUp() throws Exception { mockWebServer = new MockWebServer(); mockWebServer.start(); - erpAdapterRequestClient = new ErpAdapterRequestClient(variablesService); + erpAdapterRequestClient = new ErpAdapterRequestClient(erpAdapterSecurityConfiguration); } @@ -101,10 +102,10 @@ public void test_should_success() throws Exception { .build(); // when - Mockito.when(variablesService.getErpAdapterUrl()).thenReturn(mockWebServer.url("/").toString()); - Mockito.when(variablesService.getErpAdapterAuthKey()).thenReturn(apiKey); - Mockito.when(variablesService.getErpAdapterAuthSecret()).thenReturn(apiSecret); - Mockito.when(variablesService.getErpResponseUrl()).thenReturn(erpResponseUrl); + Mockito.when(erpAdapterSecurityConfiguration.getErpAdapterUrl()).thenReturn(mockWebServer.url("/").toString()); + Mockito.when(erpAdapterSecurityConfiguration.getErpAdapterAuthKey()).thenReturn(apiKey); + Mockito.when(erpAdapterSecurityConfiguration.getErpAdapterAuthSecret()).thenReturn(apiSecret); + Mockito.when(erpAdapterSecurityConfiguration.getErpResponseUrl()).thenReturn(erpResponseUrl); erpAdapterRequestClient.sendRequest(erpAdapterRequest); RecordedRequest request = mockWebServer.takeRequest(2, TimeUnit.SECONDS); @@ -116,10 +117,8 @@ public void test_should_success() throws Exception { var pairs = request.getPath().substring(2).split("&"); Map parameters = Stream.of(pairs) - .map(string -> { - var keyValue = string.split("="); - return Map.entry(keyValue[0], keyValue[1]); - }).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + .map(string -> string.split("=")) + .collect(Collectors.toMap(pair -> pair[0], pair -> pair[1])); Assertions.assertThat(parameters.size()).isEqualTo(5); Assertions.assertThat(parameters.get("bpnl")).isEqualTo(supplierPartnerBpnl); @@ -136,32 +135,4 @@ public void test_should_success() throws Exception { Assertions.assertThat(requestBodyNode.get("responseUrl").asText()).isEqualTo(erpResponseUrl); } } - - @Test - public void test_with_faulty_credentials_should_fail() throws Exception { - // given - UUID uuid = UUID.randomUUID(); - ErpAdapterRequest erpAdapterRequest = ErpAdapterRequest.builder() - .requestDate(new Date()) - .partnerBpnl(supplierPartnerBpnl) - .id(uuid) - .directionCharacteristic(DirectionCharacteristic.INBOUND) - .ownMaterialNumber(matNbrCustomer) - .requestType(requestType) - .sammVersion(sammVersion) - .build(); - - // when - Mockito.when(variablesService.getErpAdapterUrl()).thenReturn(mockWebServer.url("/").toString()); - Mockito.when(variablesService.getErpAdapterAuthKey()).thenReturn("wrong-key"); - Mockito.when(variablesService.getErpAdapterAuthSecret()).thenReturn(apiSecret); - Mockito.when(variablesService.getErpResponseUrl()).thenReturn(erpResponseUrl); - erpAdapterRequestClient.sendRequest(erpAdapterRequest); - RecordedRequest request = mockWebServer.takeRequest(2, TimeUnit.SECONDS); - - // then - Assertions.assertThat(request.getMethod()).isEqualTo("POST"); - Assertions.assertThat(request.getHeader("Content-type")).contains("application/json"); - Assertions.assertThat(request.getHeader(apiKey)).isNotEqualTo(apiSecret); - } } diff --git a/backend/src/test/resources/application.properties b/backend/src/test/resources/application.properties index 747f5b56..bf266c71 100755 --- a/backend/src/test/resources/application.properties +++ b/backend/src/test/resources/application.properties @@ -20,8 +20,10 @@ puris.dtr.idp.edc-client.secret.alias=${PURIS_DTR_IDP_EDC-CLIENT_SECRET_ALIAS:te puris.dtr.idp.puris-client.id=${PURIS_DTR_IDP_PURIS-CLIENT_ID:FOSS-DTR-CLIENT} puris.dtr.idp.puris-client.secret=${PURIS_DTR_IDP_PURIS-CLIENT_SECRET:test} +puris.erpadapter.enabled=${PURIS_ERPADAPTER_ENABLED:false} puris.erpadapter.url=${PURIS_ERPADAPTER_URL:http://my-erpadapter:8080} - +puris.erpadapter.authkey=${PURIS_ERPADAPTER_AUTHKEY:x-api-key} +puris.erpadapter.authsecret=${PURIS_ERPADAPTER_AUTHSECRET:erp-password} puris.generatematerialcatenaxid=${PURIS_GENERATEMATERIALCATENAXID:true} # DB Configuration diff --git a/charts/puris/README.md b/charts/puris/README.md index 2e6c056f..6c7f73bf 100644 --- a/charts/puris/README.md +++ b/charts/puris/README.md @@ -98,6 +98,7 @@ dependencies: | backend.puris.edc.dataplane.public.url | string | `"https://your-data-plane:8285/api/public/"` | Url of one of your data plane's public api | | backend.puris.erpadapter.authkey | string | `"x-api-key"` | | | backend.puris.erpadapter.authsecret | string | `"erp-password"` | | +| backend.puris.erpadapter.enabled | bool | `false` | | | backend.puris.erpadapter.url | string | `"http://my-erpadapter:8080"` | | | backend.puris.existingSecret | string | `"secret-puris-backend"` | Secret for backend passwords. For more information look into 'backend-secrets.yaml' file. | | backend.puris.frameworkagreement.credential | string | `"Puris"` | The name of the framework agreement. Starting with Uppercase and using CamelCase. | diff --git a/charts/puris/templates/backend-deployment.yaml b/charts/puris/templates/backend-deployment.yaml index 481138b8..e252155a 100644 --- a/charts/puris/templates/backend-deployment.yaml +++ b/charts/puris/templates/backend-deployment.yaml @@ -168,13 +168,12 @@ spec: key: "puris-dtr-idp-puris-client-secret" - name: PURIS_GENERATEMATERIALCATENAXID value: "{{ .Values.backend.puris.generatematerialcatenaxid | default true}}" + - name: PURIS_ERPADAPTER_ENABLED + value: "{{ .Values.backend.puris.erpadapter.enabled}}" - name: PURIS_ERPADAPTER_URL value: "{{ .Values.backend.puris.erpadapter.url}}" - name: PURIS_ERPADAPTER_AUTHKEY - valueFrom: - secretKeyRef: - name: "{{ .Values.backend.puris.existingSecret }}" - key: "puris-erpadapter-authkey" + value: {{ .Values.backend.puris.erpadapter.authkey }} - name: PURIS_ERPADAPTER_AUTHSECRET valueFrom: secretKeyRef: diff --git a/charts/puris/templates/backend-secrets.yaml b/charts/puris/templates/backend-secrets.yaml index 22d024de..35fdcf40 100644 --- a/charts/puris/templates/backend-secrets.yaml +++ b/charts/puris/templates/backend-secrets.yaml @@ -17,7 +17,6 @@ data: puris-datasource-password: {{ (.Values.backend.puris.datasource.password | b64enc) | default (index $secret.data "puris-datasource-password") | quote }} puris-edc-controlplane-key: {{ (.Values.backend.puris.edc.controlplane.key | b64enc) | default (index $secret.data "puris-edc-controlplane-key") | quote }} puris-dtr-idp-puris-client-secret: {{ (.Values.backend.puris.dtr.idp.clients.puris.secret | b64enc) | default (index $secret.data "puris-dtr-idp-puris-client-secret") | quote }} - puris-erpadapter-authkey: {{ (.Values.backend.puris.erpadapter.authkey | b64enc) default (index $secret.data "puris-erpadapter-authkey") | quote }} puris-erpadapter-authsecret: {{ (.Values.backend.puris.erpadapter.authsecret | b64enc) default (index $secret.data "puris-erpadapter-authsecret") | quote }} {{ else -}} stringData: @@ -27,6 +26,5 @@ stringData: puris-edc-controlplane-key: {{ .Values.backend.puris.edc.controlplane.key | default ( randAlphaNum 32 ) | quote }} # don't generate a random one as this is set in identity provider puris-dtr-idp-puris-client-secret: {{ .Values.backend.puris.dtr.idp.clients.puris.secret | quote }} - puris-erpadapter-authkey: {{ .Values.backend.puris.erpadapter.authkey | default ("x-api-key") | quote }} puris-erpadapter-authsecret: {{ .Values.backend.puris.erpadapter.authkey | default ( randAlphaNum 32 ) | quote }} {{ end }} diff --git a/charts/puris/values.yaml b/charts/puris/values.yaml index ee684248..aff45ad8 100644 --- a/charts/puris/values.yaml +++ b/charts/puris/values.yaml @@ -472,6 +472,8 @@ backend: # Material entity. generatematerialcatenaxid: true erpadapter: + # Toggles usage of the ERP adapter + enabled: false # The url of your ERP adapter's request api url: http://my-erpadapter:8080 # The auth key to be used on your ERP adapter's request api From 5217cb9011c257733ec7f08b790ef3298c55b733 Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Tue, 18 Jun 2024 09:19:23 +0200 Subject: [PATCH 09/10] fix: additional review issues --- .../backend/common/util/VariablesService.java | 60 ++++++++++++++----- .../ErpAdapterConfiguration.java} | 7 +-- .../service/ErpAdapterRequestClient.java | 10 ++-- .../service/ErpAdapterRequestClientTest.java | 17 +++--- charts/puris/templates/backend-secrets.yaml | 2 +- 5 files changed, 61 insertions(+), 35 deletions(-) rename backend/src/main/java/org/eclipse/tractusx/puris/backend/{common/security/ErpAdapterSecurityConfiguration.java => erpadapter/ErpAdapterConfiguration.java} (83%) diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java index 9f51420e..547a28d7 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java @@ -22,10 +22,11 @@ package org.eclipse.tractusx.puris.backend.common.util; import lombok.Getter; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; - +@Slf4j @Getter @Service /** @@ -42,6 +43,14 @@ public class VariablesService { @Value("${puris.baseurl}") private String purisBaseUrl; + /** + * The puris base url as defined in the property puris.baseurl, + * ending with a slash ('/'). + */ + public String getPurisBaseUrl() { + return purisBaseUrl.endsWith("/") ? purisBaseUrl : purisBaseUrl + "/"; + } + @Value("${puris.demonstrator.role}") /** * Must be set to "CUSTOMER" or "SUPPLIER" if @@ -50,12 +59,24 @@ public class VariablesService { */ private String demoRole; - @Value("${puris.baseurl}" + "catena/item-stock/request") + @Value("${server.servlet.context-path}") + private String contextPath; + + /** + * The context path as defined in the property server.servlet.context-path, + * ending with a slash ('/'). + */ + public String getContextPath() { + return contextPath.replace("/", "") + "/"; + } + /** - * The url under which this application's request endpoint can + * The url under which this application's item stock request endpoint can * be reached by external machines. */ - private String itemStockSubmodelEndpoint; + public String getItemStockSubmodelEndpoint() { + return getPurisBaseUrl() + getContextPath() + "item-stock/request"; + } @Value("${puris.itemstocksubmodel.apiassetid}") /** @@ -64,12 +85,13 @@ public class VariablesService { */ private String itemStockSubmodelAssetId; - @Value("${puris.baseurl}" + "catena/planned-production/request") /** - * The url under which this application's request endpoint can + * The url under which this application's planned production request endpoint can * be reached by external machines. */ - private String productionSubmodelEndpoint; + public String getProductionSubmodelEndpoint() { + return getPurisBaseUrl() + getContextPath() + "planned-production/request"; + } @Value("${puris.productionsubmodel.apiassetid}") /** @@ -78,12 +100,14 @@ public class VariablesService { */ private String productionSubmodelAssetId; - @Value("${puris.baseurl}" + "catena/material-demand/request") /** - * The url under which this application's request endpoint can + * The url under which this application's material demand request endpoint can * be reached by external machines. */ - private String demandSubmodelEndpoint; + public String getDemandSubmodelEndpoint() { + return getPurisBaseUrl() + getContextPath() + "material-demand/request"; + } + @Value("${puris.demandsubmodel.apiassetid}") /** @@ -92,12 +116,13 @@ public class VariablesService { */ private String demandSubmodelAssetId; - @Value("${puris.baseurl}" + "catena/delivery-information/request") /** - * The url under which this application's request endpoint can + * The url under which this application's delivery information request endpoint can * be reached by external machines. */ - private String deliverySubmodelEndpoint; + public String getDeliverySubmodelEndpoint() { + return getPurisBaseUrl() + getContextPath() + "delivery-information/request"; + } @Value("${puris.deliverysubmodel.apiassetid}") /** @@ -142,8 +167,13 @@ public class VariablesService { */ private String dtrUrl; - @Value("${puris.baseurl}" + "catena/parttypeinformation") - private String parttypeInformationServerendpoint; + /** + * The url under which this application's part type request endpoint can + * be reached by external machines. + */ + public String getParttypeInformationServerendpoint() { + return getPurisBaseUrl() + getContextPath() + "parttypeinformation"; + } @Value("${puris.generatematerialcatenaxid}") /** diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/security/ErpAdapterSecurityConfiguration.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/ErpAdapterConfiguration.java similarity index 83% rename from backend/src/main/java/org/eclipse/tractusx/puris/backend/common/security/ErpAdapterSecurityConfiguration.java rename to backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/ErpAdapterConfiguration.java index 93ab5ee5..edcc6871 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/security/ErpAdapterSecurityConfiguration.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/ErpAdapterConfiguration.java @@ -1,4 +1,4 @@ -package org.eclipse.tractusx.puris.backend.common.security; +package org.eclipse.tractusx.puris.backend.erpadapter; import lombok.Getter; import org.springframework.beans.factory.annotation.Value; @@ -6,8 +6,7 @@ @Configuration @Getter -public class ErpAdapterSecurityConfiguration { - +public class ErpAdapterConfiguration { /** * Toggles usage of the ERP adapter @@ -25,7 +24,7 @@ public class ErpAdapterSecurityConfiguration { * The URL under which we expect responses from * the ERP adapter */ - @Value("${puris.baseurl}" + "catena/erp-adapter") + @Value("${puris.baseurl}" + "${server.servlet.context-path}" + "/erp-adapter") private String erpResponseUrl; /** diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java index 229e45c2..27401ea2 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClient.java @@ -25,7 +25,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import okhttp3.*; -import org.eclipse.tractusx.puris.backend.common.security.ErpAdapterSecurityConfiguration; +import org.eclipse.tractusx.puris.backend.erpadapter.ErpAdapterConfiguration; import org.eclipse.tractusx.puris.backend.erpadapter.domain.model.ErpAdapterRequest; import org.springframework.stereotype.Service; @@ -40,10 +40,10 @@ public class ErpAdapterRequestClient { private final ObjectMapper mapper = new ObjectMapper(); - private final ErpAdapterSecurityConfiguration erpAdapterSecurityConfiguration; + private final ErpAdapterConfiguration erpAdapterConfiguration; public Integer sendRequest(ErpAdapterRequest erpAdapterRequest){ - HttpUrl.Builder urlBuilder = HttpUrl.parse(erpAdapterSecurityConfiguration.getErpAdapterUrl()).newBuilder(); + HttpUrl.Builder urlBuilder = HttpUrl.parse(erpAdapterConfiguration.getErpAdapterUrl()).newBuilder(); urlBuilder.addQueryParameter("bpnl", erpAdapterRequest.getPartnerBpnl()); urlBuilder.addQueryParameter("request-type", erpAdapterRequest.getRequestType()); urlBuilder.addQueryParameter("request-id", erpAdapterRequest.getId().toString()); @@ -54,14 +54,14 @@ public Integer sendRequest(ErpAdapterRequest erpAdapterRequest){ requestBody.put("material", erpAdapterRequest.getOwnMaterialNumber()); requestBody.put("direction", erpAdapterRequest.getDirectionCharacteristic().toString()); - requestBody.put("responseUrl", erpAdapterSecurityConfiguration.getErpResponseUrl()); + requestBody.put("responseUrl", erpAdapterConfiguration.getErpResponseUrl()); RequestBody body = RequestBody.create(requestBody.toString(), MediaType.parse("application/json")); Request request = new Request.Builder() .post(body) .url(urlBuilder.build()) - .header(erpAdapterSecurityConfiguration.getErpAdapterAuthKey(), erpAdapterSecurityConfiguration.getErpAdapterAuthSecret()) + .header(erpAdapterConfiguration.getErpAdapterAuthKey(), erpAdapterConfiguration.getErpAdapterAuthSecret()) .header("Content-Type", "application/json") .build(); try (var response = client.newCall(request).execute()) { diff --git a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java index ef9ed9b6..086704b5 100644 --- a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java +++ b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java @@ -25,7 +25,7 @@ import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; import org.assertj.core.api.Assertions; -import org.eclipse.tractusx.puris.backend.common.security.ErpAdapterSecurityConfiguration; +import org.eclipse.tractusx.puris.backend.erpadapter.ErpAdapterConfiguration; import org.eclipse.tractusx.puris.backend.erpadapter.domain.model.ErpAdapterRequest; import org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm.DirectionCharacteristic; import org.junit.jupiter.api.AfterEach; @@ -50,9 +50,8 @@ public class ErpAdapterRequestClientTest { private MockWebServer mockWebServer; - @Mock - private ErpAdapterSecurityConfiguration erpAdapterSecurityConfiguration; + private ErpAdapterConfiguration erpAdapterConfiguration; @InjectMocks private ErpAdapterRequestClient erpAdapterRequestClient; @@ -77,8 +76,7 @@ public class ErpAdapterRequestClientTest { public void setUp() throws Exception { mockWebServer = new MockWebServer(); mockWebServer.start(); - erpAdapterRequestClient = new ErpAdapterRequestClient(erpAdapterSecurityConfiguration); - + erpAdapterRequestClient = new ErpAdapterRequestClient(erpAdapterConfiguration); } @AfterEach @@ -102,10 +100,10 @@ public void test_should_success() throws Exception { .build(); // when - Mockito.when(erpAdapterSecurityConfiguration.getErpAdapterUrl()).thenReturn(mockWebServer.url("/").toString()); - Mockito.when(erpAdapterSecurityConfiguration.getErpAdapterAuthKey()).thenReturn(apiKey); - Mockito.when(erpAdapterSecurityConfiguration.getErpAdapterAuthSecret()).thenReturn(apiSecret); - Mockito.when(erpAdapterSecurityConfiguration.getErpResponseUrl()).thenReturn(erpResponseUrl); + Mockito.when(erpAdapterConfiguration.getErpAdapterUrl()).thenReturn(mockWebServer.url("/").toString()); + Mockito.when(erpAdapterConfiguration.getErpAdapterAuthKey()).thenReturn(apiKey); + Mockito.when(erpAdapterConfiguration.getErpAdapterAuthSecret()).thenReturn(apiSecret); + Mockito.when(erpAdapterConfiguration.getErpResponseUrl()).thenReturn(erpResponseUrl); erpAdapterRequestClient.sendRequest(erpAdapterRequest); RecordedRequest request = mockWebServer.takeRequest(2, TimeUnit.SECONDS); @@ -127,7 +125,6 @@ public void test_should_success() throws Exception { Assertions.assertThat(parameters.get("request-timestamp")).isEqualTo(String.valueOf(erpAdapterRequest.getRequestDate().getTime())); Assertions.assertThat(parameters.get("request-id")).isEqualTo(uuid.toString()); - try (InputStream stream = request.getBody().inputStream()) { JsonNode requestBodyNode = objectMapper.readTree(new String(stream.readAllBytes())); Assertions.assertThat(requestBodyNode.get("material").asText()).isEqualTo(matNbrCustomer); diff --git a/charts/puris/templates/backend-secrets.yaml b/charts/puris/templates/backend-secrets.yaml index 35fdcf40..1a14df02 100644 --- a/charts/puris/templates/backend-secrets.yaml +++ b/charts/puris/templates/backend-secrets.yaml @@ -17,7 +17,7 @@ data: puris-datasource-password: {{ (.Values.backend.puris.datasource.password | b64enc) | default (index $secret.data "puris-datasource-password") | quote }} puris-edc-controlplane-key: {{ (.Values.backend.puris.edc.controlplane.key | b64enc) | default (index $secret.data "puris-edc-controlplane-key") | quote }} puris-dtr-idp-puris-client-secret: {{ (.Values.backend.puris.dtr.idp.clients.puris.secret | b64enc) | default (index $secret.data "puris-dtr-idp-puris-client-secret") | quote }} - puris-erpadapter-authsecret: {{ (.Values.backend.puris.erpadapter.authsecret | b64enc) default (index $secret.data "puris-erpadapter-authsecret") | quote }} + puris-erpadapter-authsecret: {{ (.Values.backend.puris.erpadapter.authsecret | b64enc) | default (index $secret.data "puris-erpadapter-authsecret") | quote }} {{ else -}} stringData: # if secret doesn't exist, use provided value from values file or generate a random one From 234e4fb4cb7ddade44c4ae01dbf7eaf5f982910f Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Thu, 20 Jun 2024 07:59:19 +0200 Subject: [PATCH 10/10] fix: styling issues --- .../tractusx/puris/backend/common/util/VariablesService.java | 3 --- .../erpadapter/logic/service/ErpAdapterRequestClientTest.java | 2 -- 2 files changed, 5 deletions(-) diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java index 547a28d7..aa991ce1 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java @@ -22,11 +22,9 @@ package org.eclipse.tractusx.puris.backend.common.util; import lombok.Getter; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -@Slf4j @Getter @Service /** @@ -108,7 +106,6 @@ public String getDemandSubmodelEndpoint() { return getPurisBaseUrl() + getContextPath() + "material-demand/request"; } - @Value("${puris.demandsubmodel.apiassetid}") /** * The assetId that shall be assigned to the request API diff --git a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java index 086704b5..6b018e5e 100644 --- a/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java +++ b/backend/src/test/java/org/eclipse/tractusx/puris/backend/erpadapter/logic/service/ErpAdapterRequestClientTest.java @@ -36,7 +36,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; - import java.io.InputStream; import java.util.Date; import java.util.Map; @@ -84,7 +83,6 @@ public void tearDown() throws Exception { mockWebServer.shutdown(); } - @Test public void test_should_success() throws Exception { // given