diff --git a/CHANGELOG.md b/CHANGELOG.md index 08c63780..91d33a13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] + - NA + +## [1.2.2] - 2023-03-30 + +### Added + - Connector test service integration for managed connector connectivity test + - Update email template for connector status ## [1.2.1] - 2023-03-20 diff --git a/README.md b/README.md index 6dce7be2..2778b049 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ This service will help service provider to set up DFT/SDE with EDC and EDC as se ### Software Version ```shell -Application version: 1.2.1 -Helm release version: 1.2.1 +Application version: 1.2.2 +Helm release version: 1.2.2 ``` diff --git a/charts/orchestrator/Chart.yaml b/charts/orchestrator/Chart.yaml index 78be3efe..c3e16efc 100644 --- a/charts/orchestrator/Chart.yaml +++ b/charts/orchestrator/Chart.yaml @@ -38,14 +38,14 @@ sources: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.2.1 +version: 1.2.2 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.2.1" +appVersion: "1.2.2" dependencies: - condition: postgresql.enabled name: postgresql diff --git a/charts/orchestrator/README.md b/charts/orchestrator/README.md index 7d130d31..c5b6b4e0 100644 --- a/charts/orchestrator/README.md +++ b/charts/orchestrator/README.md @@ -1,6 +1,6 @@ # autosetup -![Version: 1.2.1](https://img.shields.io/badge/Version-1.2.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.1](https://img.shields.io/badge/AppVersion-1.2.1-informational?style=flat-square) +![Version: 1.2.2](https://img.shields.io/badge/Version-1.2.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.2](https://img.shields.io/badge/AppVersion-1.2.2-informational?style=flat-square) This service will help service provider to set up DFT/SDE with EDC and EDC as service in service provider environment. diff --git a/pom.xml b/pom.xml index 588b3abd..2b2cc7d4 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.eclipse.tractusx auto-setup - 1.2.1 + 1.2.2 auto-setup auto-setup @@ -34,6 +34,11 @@ + + org.springframework + spring-core + 6.0.7 + org.springframework.boot spring-boot-starter-web @@ -138,7 +143,11 @@ spring-boot-starter-test test - + + net.minidev + json-smart + 2.4.9 + org.flywaydb @@ -208,6 +217,12 @@ org.springframework.security spring-security-oauth2-client + + + net.minidev + json-smart + + com.h2database diff --git a/src/main/java/org/eclipse/tractusx/autosetup/constant/AppNameConstant.java b/src/main/java/org/eclipse/tractusx/autosetup/constant/AppNameConstant.java index 2a1766d9..11210cc2 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/constant/AppNameConstant.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/constant/AppNameConstant.java @@ -35,7 +35,6 @@ public enum AppNameConstant { DFT_FRONTEND, - DFT_BACKEND - - + DFT_BACKEND, + } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java b/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java new file mode 100644 index 00000000..379ebb09 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/manager/TestConnectorServiceManager.java @@ -0,0 +1,111 @@ +/******************************************************************************** + * Copyright (c) 2022, 2023 T-Systems International GmbH + * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.manager; + +import java.util.Map; +import java.util.UUID; + +import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum; +import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerDetails; +import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; +import org.eclipse.tractusx.autosetup.exception.ServiceException; +import org.eclipse.tractusx.autosetup.model.Customer; +import org.eclipse.tractusx.autosetup.testservice.proxy.ConnectorTestRequest; +import org.eclipse.tractusx.autosetup.testservice.proxy.ConnectorTestServiceProxy; +import org.eclipse.tractusx.autosetup.testservice.proxy.ConnectorTestServiceResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.retry.annotation.Backoff; +import org.springframework.retry.annotation.Retryable; +import org.springframework.retry.support.RetrySynchronizationManager; +import org.springframework.stereotype.Service; + +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; + +@Service +@Slf4j +@RequiredArgsConstructor +public class TestConnectorServiceManager { + + private final AutoSetupTriggerManager autoSetupTriggerManager; + + private final ConnectorTestServiceProxy connectorTestServiceProxy; + + @Value("${connector.test.service.url}") + private String connectorTestServiceURL; + + @Retryable(value = { + ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "${retry.backOffDelay}")) + public Map verifyConnectorTestingThroughTestService(Customer customerDetails, + Map inputData, AutoSetupTriggerEntry triger) { + + AutoSetupTriggerDetails autoSetupTriggerDetails = AutoSetupTriggerDetails.builder() + .id(UUID.randomUUID().toString()).step("CONNECTOR_TEST_SERVICE").build(); + try { + + ConnectorTestRequest connectorTestRequest = ConnectorTestRequest.builder() + .apiKeyHeader(inputData.get("edcApiKey")).apiKeyValue(inputData.get("edcApiKeyValue")) + .connectorHost(inputData.get("controlPlaneEndpoint")).build(); + + inputData.put("testServiceURL", connectorTestServiceURL); + + waitingTime(); + + ConnectorTestServiceResponse testResult = connectorTestServiceProxy + .verifyConnectorTestingThroughTestService(connectorTestRequest); + + log.info("Connector status: " + testResult.getMessage()); + + inputData.put("connectorTestResult", testResult.getMessage()); + + autoSetupTriggerDetails.setStatus(TriggerStatusEnum.SUCCESS.name()); + + } catch (Exception ex) { + + inputData.put("connectorTestResult", "The automatic test wasn't successfully completed"); + + log.error("ConnectorTestService failed retry attempt: : {}", + RetrySynchronizationManager.getContext().getRetryCount() + 1); + + autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name()); + autoSetupTriggerDetails.setRemark(ex.getMessage()); + throw new ServiceException("ConnectorTestService Oops! We have an exception - " + ex.getMessage()); + } finally { + autoSetupTriggerManager.saveTriggerDetails(autoSetupTriggerDetails, triger); + } + + return inputData; + } + + @SneakyThrows + private void waitingTime() { + + try { + log.info("Waiting after connector setup to get pod up to test connector as data provider/consumer"); + Thread.sleep(60000); + } catch (InterruptedException e) { + + Thread.currentThread().interrupt(); + } + } + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java b/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java index 44076592..892f2f51 100644 --- a/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java +++ b/src/main/java/org/eclipse/tractusx/autosetup/service/EDCConnectorWorkFlow.java @@ -22,19 +22,21 @@ import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.EDC_CONTROLPLANE; import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.EDC_DATAPLANE; -import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.TRACTUS_CONNECTOR; import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.POSTGRES_DB; +import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.TRACTUS_CONNECTOR; import java.util.Map; import org.eclipse.tractusx.autosetup.constant.AppActions; import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry; +import org.eclipse.tractusx.autosetup.exception.ServiceException; import org.eclipse.tractusx.autosetup.manager.AppDeleteManager; import org.eclipse.tractusx.autosetup.manager.CertificateManager; import org.eclipse.tractusx.autosetup.manager.ConnectorRegistrationManager; import org.eclipse.tractusx.autosetup.manager.EDCControlplaneManager; import org.eclipse.tractusx.autosetup.manager.EDCDataplaneManager; import org.eclipse.tractusx.autosetup.manager.PostgresDBManager; +import org.eclipse.tractusx.autosetup.manager.TestConnectorServiceManager; import org.eclipse.tractusx.autosetup.manager.TractusConnectorManager; import org.eclipse.tractusx.autosetup.manager.VaultManager; import org.eclipse.tractusx.autosetup.model.Customer; @@ -42,9 +44,11 @@ import org.springframework.stereotype.Component; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Component @RequiredArgsConstructor +@Slf4j public class EDCConnectorWorkFlow { private final CertificateManager certificateManager; @@ -54,6 +58,7 @@ public class EDCConnectorWorkFlow { private final EDCDataplaneManager edcDataplaneManager; private final TractusConnectorManager tractusConnectorManager; private final ConnectorRegistrationManager connectorRegistrationManager; + private final TestConnectorServiceManager testConnectorServiceManager; private final AppDeleteManager appDeleteManager; @@ -70,6 +75,13 @@ public Map getWorkFlow(Customer customerDetails, SelectedTools t inputConfiguration.putAll( connectorRegistrationManager.registerConnector(customerDetails, tool, inputConfiguration, triger)); + try { + inputConfiguration.putAll(testConnectorServiceManager + .verifyConnectorTestingThroughTestService(customerDetails, inputConfiguration, triger)); + } catch (ServiceException ex) { + log.warn(ex.getMessage()); + } + return inputConfiguration; } @@ -95,6 +107,13 @@ public Map getWorkFlowSeparateCPandDP(Customer customerDetails, inputConfiguration.putAll( connectorRegistrationManager.registerConnector(customerDetails, tool, inputConfiguration, triger)); + try { + inputConfiguration.putAll(testConnectorServiceManager + .verifyConnectorTestingThroughTestService(customerDetails, inputConfiguration, triger)); + } catch (ServiceException ex) { + log.warn(ex.getMessage()); + } + return inputConfiguration; } diff --git a/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestRequest.java b/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestRequest.java new file mode 100644 index 00000000..a8b18727 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestRequest.java @@ -0,0 +1,36 @@ +/******************************************************************************** + * Copyright (c) 2022, 2023 T-Systems International GmbH + * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.testservice.proxy; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class ConnectorTestRequest { + + private String connectorHost; + + private String apiKeyHeader; + + private String apiKeyValue; + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestServiceProxy.java b/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestServiceProxy.java new file mode 100644 index 00000000..62fc44ea --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestServiceProxy.java @@ -0,0 +1,33 @@ +/******************************************************************************** + * Copyright (c) 2022, 2023 T-Systems International GmbH + * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.testservice.proxy; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@FeignClient(name = "ConnectorTestServiceProxy", url = "${connector.test.service.url}") +public interface ConnectorTestServiceProxy { + + @PostMapping("/connector-test") + public ConnectorTestServiceResponse verifyConnectorTestingThroughTestService(@RequestBody ConnectorTestRequest connectorTestRequest); + +} diff --git a/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestServiceResponse.java b/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestServiceResponse.java new file mode 100644 index 00000000..fc6497e9 --- /dev/null +++ b/src/main/java/org/eclipse/tractusx/autosetup/testservice/proxy/ConnectorTestServiceResponse.java @@ -0,0 +1,30 @@ +/******************************************************************************** + * Copyright (c) 2022, 2023 T-Systems International GmbH + * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.autosetup.testservice.proxy; + +import lombok.Data; + +@Data +public class ConnectorTestServiceResponse { + + private String message; + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 997ce591..8b318b80 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -64,6 +64,8 @@ vault.url=${vaultUrl} vault.token=${vaultToken} vault.timeout=30 +#Connector Test service details +connector.test.service.url=${connectorTestServiceUrl} #Portal interface info portal.url=${portalurl} diff --git a/src/main/resources/flyway/V1__auto-setup-table.sql b/src/main/resources/flyway/V1__auto-setup-table.sql index 2c26c246..73490e53 100644 --- a/src/main/resources/flyway/V1__auto-setup-table.sql +++ b/src/main/resources/flyway/V1__auto-setup-table.sql @@ -112,7 +112,7 @@ connector.discovery.token-url=$\{sde.connector.discovery.token-url\} connector.discovery.clientId=$\{sde.connector.discovery.clientId\} -connector.discovery.clientSecret=$\{sde.connector.discovery.clientSecret\}', NULL, 'sde-backend/dftbackend', '1.9.0', 'helm.packages', 'v1alpha1', '{"dftpostgresql": {"enabled": true, "auth" : {"secretKeys":{"password":"$\{postgresPassword}"\},"username":"$\{username\}","database":"$\{database\}"}},"ingresses":[{"enabled": true, "hostname":"$\{dnsName\}", "annotations": {}, "className": "nginx", "endpoints":["default"], "tls":{"enabled":true, "secretName":"dftbackend"}, "certManager":{"clusterIssuer":"letsencrypt-prod"}}], "configuration": {"properties": "$\{yamlValues\}"}}', 'PROPERTY'); +connector.discovery.clientSecret=$\{sde.connector.discovery.clientSecret\}', NULL, 'sde-backend/dftbackend', '2.0.0', 'helm.packages', 'v1alpha1', '{"dftpostgresql": {"enabled": true, "primary":{"persistence":{"size" :"1Gi"}},"persistence":{"size" :"1Gi"}, "auth" : {"secretKeys":{"password":"$\{postgresPassword}"\},"username":"$\{username\}","database":"$\{database\}"}},"ingresses":[{"enabled": true, "hostname":"$\{dnsName\}", "annotations": {}, "className": "nginx", "endpoints":["default"], "tls":{"enabled":true, "secretName":"dftbackend"}, "certManager":{"clusterIssuer":"letsencrypt-prod"}}], "configuration": {"properties": "$\{yamlValues\}"}}', 'PROPERTY'); INSERT INTO app_tbl (app_name, context_cluster, context_namespace, expected_input_data, output_data, package_identifier, package_version, plugin_name, plugin_version, required_yaml_configuration, yaml_value_field_type) VALUES('DFT_FRONTEND', 'default', 'kubeapps', 'REACT_APP_API_URL=$\{dftBackEndUrl\} @@ -125,7 +125,7 @@ REACT_APP_CLIENT_ID=$\{dftfrontendkeycloakclientid\} REACT_APP_DEFAULT_COMPANY_BPN=$\{bpnNumber\} -REACT_APP_FILESIZE=268435456', NULL, 'sde-frontend/dftfrontend', '1.9.0', 'helm.packages', 'v1alpha1', '{"ingresses":[{"enabled": true, "hostname":"$\{dnsName\}", "annotations": {}, "className": "nginx", "endpoints":["default"], "tls":{"enabled":true, "secretName":"dftfrontend"}, "certManager":{"clusterIssuer":"letsencrypt-prod"}}], "configuration": {"properties": "$\{yamlValues\}"}}', 'PROPERTY'); +REACT_APP_FILESIZE=268435456', NULL, 'sde-frontend/dftfrontend', '2.0.0', 'helm.packages', 'v1alpha1', '{"ingresses":[{"enabled": true, "hostname":"$\{dnsName\}", "annotations": {}, "className": "nginx", "endpoints":["default"], "tls":{"enabled":true, "secretName":"dftfrontend"}, "certManager":{"clusterIssuer":"letsencrypt-prod"}}], "configuration": {"properties": "$\{yamlValues\}"}}', 'PROPERTY'); INSERT INTO app_tbl (app_name, context_cluster, context_namespace, expected_input_data, output_data, package_identifier, package_version, plugin_name, plugin_version, required_yaml_configuration, yaml_value_field_type) VALUES('EDC_CONTROLPLANE', 'default', 'kubeapps', 'edc.receiver.http.endpoint=$\{dftAddress\} diff --git a/src/main/resources/templates/edc_success_activate.html b/src/main/resources/templates/edc_success_activate.html index cdc116ca..2e8d5fbe 100644 --- a/src/main/resources/templates/edc_success_activate.html +++ b/src/main/resources/templates/edc_success_activate.html @@ -41,7 +41,8 @@

EDC ApiKey : ${edcApiKey}

EDC ApiKeyValue : ${edcApiKeyValue}

Data Plane URL : ${dataPlanePublicEndpoint} - +

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

+

Kind Regards
Catina-X

diff --git a/src/main/resources/templates/success_activate.html b/src/main/resources/templates/success_activate.html index 1cc49b9b..6333062f 100644 --- a/src/main/resources/templates/success_activate.html +++ b/src/main/resources/templates/success_activate.html @@ -33,6 +33,7 @@

Hello ${orgname},

The SDE/DFT tool successfully activated for your use.

Please click here to start using it.

+

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

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

Kind Regards
Catina-X

diff --git a/src/test/java/org/eclipse/tractusx/autosetup/manager/DFTBackendManagerTest.java b/src/test/java/org/eclipse/tractusx/autosetup/manager/DFTBackendManagerTest.java index c901d277..272bea8f 100644 --- a/src/test/java/org/eclipse/tractusx/autosetup/manager/DFTBackendManagerTest.java +++ b/src/test/java/org/eclipse/tractusx/autosetup/manager/DFTBackendManagerTest.java @@ -63,7 +63,7 @@ void managePackage() { mockInputMap.put("dnsNameURLProtocol", "https"); Map resultMap = dftBackendManager.managePackage(null, AppActions.CREATE, selectedTools, mockInputMap, null); - assertEquals(18, resultMap.size()); + assertEquals(17, resultMap.size()); assertEquals("test", mockInputMap.get("dnsName")); } } \ No newline at end of file diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties index 224024dc..57d6dc56 100644 --- a/src/test/resources/application-test.properties +++ b/src/test/resources/application-test.properties @@ -36,6 +36,8 @@ vault.url=test vault.token=test vault.timeout=30 +#Connector Test service details +connector.test.service.url=test #Portal interface info portal.url=test