From d9bb81366400e355a1c02b74064b663c9c3a546f Mon Sep 17 00:00:00 2001 From: Achour berrahma Date: Fri, 13 Sep 2024 15:08:57 +0200 Subject: [PATCH] Delete endpoints not called from the fronts (#112) Signed-off-by: achour94 --- .../org/gridsuite/gateway/GatewayConfig.java | 11 ----- .../gateway/endpoints/CaseImportServer.java | 35 ---------------- .../endpoints/CgmesBoundaryServer.java | 35 ---------------- .../gateway/endpoints/CgmesGlServer.java | 35 ---------------- .../gateway/endpoints/GeoDataServer.java | 35 ---------------- .../endpoints/MergeNotificationServer.java | 35 ---------------- .../gateway/endpoints/MergeServer.java | 35 ---------------- .../gateway/endpoints/OdreServer.java | 35 ---------------- .../gateway/endpoints/ReportServer.java | 35 ---------------- .../StateEstimationOrchestratorServer.java | 35 ---------------- .../endpoints/StateEstimationServer.java | 35 ---------------- ...lementAccessControllerGlobalPreFilter.java | 40 ------------------- .../gateway/TokenValidationTest.java | 29 -------------- 13 files changed, 430 deletions(-) delete mode 100644 src/main/java/org/gridsuite/gateway/endpoints/CaseImportServer.java delete mode 100644 src/main/java/org/gridsuite/gateway/endpoints/CgmesBoundaryServer.java delete mode 100644 src/main/java/org/gridsuite/gateway/endpoints/CgmesGlServer.java delete mode 100644 src/main/java/org/gridsuite/gateway/endpoints/GeoDataServer.java delete mode 100644 src/main/java/org/gridsuite/gateway/endpoints/MergeNotificationServer.java delete mode 100644 src/main/java/org/gridsuite/gateway/endpoints/MergeServer.java delete mode 100644 src/main/java/org/gridsuite/gateway/endpoints/OdreServer.java delete mode 100644 src/main/java/org/gridsuite/gateway/endpoints/ReportServer.java delete mode 100644 src/main/java/org/gridsuite/gateway/endpoints/StateEstimationOrchestratorServer.java delete mode 100644 src/main/java/org/gridsuite/gateway/endpoints/StateEstimationServer.java delete mode 100644 src/main/java/org/gridsuite/gateway/filters/ElementAccessControllerGlobalPreFilter.java diff --git a/src/main/java/org/gridsuite/gateway/GatewayConfig.java b/src/main/java/org/gridsuite/gateway/GatewayConfig.java index 80e8e8e..c008f16 100644 --- a/src/main/java/org/gridsuite/gateway/GatewayConfig.java +++ b/src/main/java/org/gridsuite/gateway/GatewayConfig.java @@ -6,7 +6,6 @@ */ package org.gridsuite.gateway; -import org.gridsuite.gateway.endpoints.CgmesGlServer; import org.gridsuite.gateway.endpoints.*; import org.springframework.cloud.gateway.route.RouteLocator; import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder; @@ -34,34 +33,24 @@ public RouteLocator myRoutes(RouteLocatorBuilder builder, ApplicationContext con return builder.routes() .route(p -> context.getBean(StudyServer.class).getRoute(p)) .route(p -> context.getBean(CaseServer.class).getRoute(p)) - .route(p -> context.getBean(MergeServer.class).getRoute(p)) .route(p -> context.getBean(StudyNotificationServer.class).getRoute(p)) - .route(p -> context.getBean(MergeNotificationServer.class).getRoute(p)) .route(p -> context.getBean(DirectoryNotificationServer.class).getRoute(p)) .route(p -> context.getBean(ContingencyServer.class).getRoute(p)) .route(p -> context.getBean(ConfigServer.class).getRoute(p)) .route(p -> context.getBean(ConfigNotificationServer.class).getRoute(p)) .route(p -> context.getBean(DirectoryServer.class).getRoute(p)) .route(p -> context.getBean(ExploreServer.class).getRoute(p)) - .route(p -> context.getBean(CgmesBoundaryServer.class).getRoute(p)) .route(p -> context.getBean(DynamicMappingServer.class).getRoute(p)) .route(p -> context.getBean(FilterServer.class).getRoute(p)) - .route(p -> context.getBean(ReportServer.class).getRoute(p)) .route(p -> context.getBean(NetworkModificationServer.class).getRoute(p)) .route(p -> context.getBean(NetworkConversionServer.class).getRoute(p)) - .route(p -> context.getBean(OdreServer.class).getRoute(p)) - .route(p -> context.getBean(GeoDataServer.class).getRoute(p)) .route(p -> context.getBean(UserAdminServer.class).getRoute(p)) - .route(p -> context.getBean(CgmesGlServer.class).getRoute(p)) .route(p -> context.getBean(SensitivityAnalysisServer.class).getRoute(p)) .route(p -> context.getBean(LoadFlowServer.class).getRoute(p)) .route(p -> context.getBean(SecurityAnalysisServer.class).getRoute(p)) .route(p -> context.getBean(DynamicSimulationServer.class).getRoute(p)) - .route(p -> context.getBean(CaseImportServer.class).getRoute(p)) .route(p -> context.getBean(VoltageInitServer.class).getRoute(p)) .route(p -> context.getBean(ShortCircuitServer.class).getRoute(p)) - .route(p -> context.getBean(StateEstimationServer.class).getRoute(p)) - .route(p -> context.getBean(StateEstimationOrchestratorServer.class).getRoute(p)) .build(); } } diff --git a/src/main/java/org/gridsuite/gateway/endpoints/CaseImportServer.java b/src/main/java/org/gridsuite/gateway/endpoints/CaseImportServer.java deleted file mode 100644 index 09766d2..0000000 --- a/src/main/java/org/gridsuite/gateway/endpoints/CaseImportServer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) 2023, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.gateway.endpoints; - -import org.gridsuite.gateway.ServiceURIsConfig; -import org.springframework.stereotype.Component; - -/** - * @author Abdelsalem Hedhili - */ -@Component(value = CaseImportServer.ENDPOINT_NAME) -public class CaseImportServer implements EndPointServer { - - public static final String ENDPOINT_NAME = "case-import"; - - private final ServiceURIsConfig servicesURIsConfig; - - public CaseImportServer(ServiceURIsConfig servicesURIsConfig) { - this.servicesURIsConfig = servicesURIsConfig; - } - - @Override - public String getEndpointBaseUri() { - return servicesURIsConfig.getCaseImportServerBaseUri(); - } - - @Override - public String getEndpointName() { - return ENDPOINT_NAME; - } -} diff --git a/src/main/java/org/gridsuite/gateway/endpoints/CgmesBoundaryServer.java b/src/main/java/org/gridsuite/gateway/endpoints/CgmesBoundaryServer.java deleted file mode 100644 index 659f9a1..0000000 --- a/src/main/java/org/gridsuite/gateway/endpoints/CgmesBoundaryServer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) 2021, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.gateway.endpoints; - -import org.gridsuite.gateway.ServiceURIsConfig; -import org.springframework.stereotype.Component; - -/** - * @author Slimane Amar - */ -@Component(value = CgmesBoundaryServer.ENDPOINT_NAME) -public class CgmesBoundaryServer implements EndPointServer { - - public static final String ENDPOINT_NAME = "boundary"; - - private final ServiceURIsConfig servicesURIsConfig; - - public CgmesBoundaryServer(ServiceURIsConfig servicesURIsConfig) { - this.servicesURIsConfig = servicesURIsConfig; - } - - @Override - public String getEndpointBaseUri() { - return servicesURIsConfig.getBoundaryServerBaseUri(); - } - - @Override - public String getEndpointName() { - return ENDPOINT_NAME; - } -} diff --git a/src/main/java/org/gridsuite/gateway/endpoints/CgmesGlServer.java b/src/main/java/org/gridsuite/gateway/endpoints/CgmesGlServer.java deleted file mode 100644 index adc47a8..0000000 --- a/src/main/java/org/gridsuite/gateway/endpoints/CgmesGlServer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) 2022, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.gateway.endpoints; - -import org.gridsuite.gateway.ServiceURIsConfig; -import org.springframework.stereotype.Component; - -/** - * @author bendaamerahm - */ -@Component(value = CgmesGlServer.ENDPOINT_NAME) -public class CgmesGlServer implements EndPointServer { - - public static final String ENDPOINT_NAME = "cgmes-gl"; - - private final ServiceURIsConfig servicesURIsConfig; - - public CgmesGlServer(ServiceURIsConfig servicesURIsConfig) { - this.servicesURIsConfig = servicesURIsConfig; - } - - @Override - public String getEndpointBaseUri() { - return servicesURIsConfig.getCgmesGlServerBaseUri(); - } - - @Override - public String getEndpointName() { - return ENDPOINT_NAME; - } -} diff --git a/src/main/java/org/gridsuite/gateway/endpoints/GeoDataServer.java b/src/main/java/org/gridsuite/gateway/endpoints/GeoDataServer.java deleted file mode 100644 index 1a314e0..0000000 --- a/src/main/java/org/gridsuite/gateway/endpoints/GeoDataServer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) 2022, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.gateway.endpoints; - -import org.gridsuite.gateway.ServiceURIsConfig; -import org.springframework.stereotype.Component; - -/** - * @author bendaamerahm - */ -@Component(value = GeoDataServer.ENDPOINT_NAME) -public class GeoDataServer implements EndPointServer { - - public static final String ENDPOINT_NAME = "geo-data"; - - private final ServiceURIsConfig servicesURIsConfig; - - public GeoDataServer(ServiceURIsConfig servicesURIsConfig) { - this.servicesURIsConfig = servicesURIsConfig; - } - - @Override - public String getEndpointBaseUri() { - return servicesURIsConfig.getGeoDataServerBaseUri(); - } - - @Override - public String getEndpointName() { - return ENDPOINT_NAME; - } -} diff --git a/src/main/java/org/gridsuite/gateway/endpoints/MergeNotificationServer.java b/src/main/java/org/gridsuite/gateway/endpoints/MergeNotificationServer.java deleted file mode 100644 index 18465d8..0000000 --- a/src/main/java/org/gridsuite/gateway/endpoints/MergeNotificationServer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) 2021, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.gateway.endpoints; - -import org.gridsuite.gateway.ServiceURIsConfig; -import org.springframework.stereotype.Component; - -/** - * @author Slimane Amar - */ -@Component(value = MergeNotificationServer.ENDPOINT_NAME) -public class MergeNotificationServer implements EndPointServer { - - public static final String ENDPOINT_NAME = "merge-notification"; - - private final ServiceURIsConfig servicesURIsConfig; - - public MergeNotificationServer(ServiceURIsConfig servicesURIsConfig) { - this.servicesURIsConfig = servicesURIsConfig; - } - - @Override - public String getEndpointBaseUri() { - return servicesURIsConfig.getMergeNotificationServerBaseUri(); - } - - @Override - public String getEndpointName() { - return ENDPOINT_NAME; - } -} diff --git a/src/main/java/org/gridsuite/gateway/endpoints/MergeServer.java b/src/main/java/org/gridsuite/gateway/endpoints/MergeServer.java deleted file mode 100644 index cef20a3..0000000 --- a/src/main/java/org/gridsuite/gateway/endpoints/MergeServer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) 2021, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.gateway.endpoints; - -import org.gridsuite.gateway.ServiceURIsConfig; -import org.springframework.stereotype.Component; - -/** - * @author Slimane Amar - */ -@Component(value = MergeServer.ENDPOINT_NAME) -public class MergeServer implements EndPointServer { - - public static final String ENDPOINT_NAME = "merge"; - - private final ServiceURIsConfig servicesURIsConfig; - - public MergeServer(ServiceURIsConfig servicesURIsConfig) { - this.servicesURIsConfig = servicesURIsConfig; - } - - @Override - public String getEndpointBaseUri() { - return servicesURIsConfig.getMergeOrchestratorServerBaseUri(); - } - - @Override - public String getEndpointName() { - return ENDPOINT_NAME; - } -} diff --git a/src/main/java/org/gridsuite/gateway/endpoints/OdreServer.java b/src/main/java/org/gridsuite/gateway/endpoints/OdreServer.java deleted file mode 100644 index 0906c3f..0000000 --- a/src/main/java/org/gridsuite/gateway/endpoints/OdreServer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) 2022, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.gateway.endpoints; - -import org.gridsuite.gateway.ServiceURIsConfig; -import org.springframework.stereotype.Component; - -/** - * @author bendaamerahm - */ -@Component(value = OdreServer.ENDPOINT_NAME) -public class OdreServer implements EndPointServer { - - public static final String ENDPOINT_NAME = "odre"; - - private final ServiceURIsConfig servicesURIsConfig; - - public OdreServer(ServiceURIsConfig servicesURIsConfig) { - this.servicesURIsConfig = servicesURIsConfig; - } - - @Override - public String getEndpointBaseUri() { - return servicesURIsConfig.getOdreServerBaseUri(); - } - - @Override - public String getEndpointName() { - return ENDPOINT_NAME; - } -} diff --git a/src/main/java/org/gridsuite/gateway/endpoints/ReportServer.java b/src/main/java/org/gridsuite/gateway/endpoints/ReportServer.java deleted file mode 100644 index 5ec40e5..0000000 --- a/src/main/java/org/gridsuite/gateway/endpoints/ReportServer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright (c) 2021, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.gateway.endpoints; - -import org.gridsuite.gateway.ServiceURIsConfig; -import org.springframework.stereotype.Component; - -/** - * @author Slimane Amar - */ -@Component(value = ReportServer.ENDPOINT_NAME) -public class ReportServer implements EndPointServer { - - public static final String ENDPOINT_NAME = "report"; - - private final ServiceURIsConfig servicesURIsConfig; - - public ReportServer(ServiceURIsConfig servicesURIsConfig) { - this.servicesURIsConfig = servicesURIsConfig; - } - - @Override - public String getEndpointBaseUri() { - return servicesURIsConfig.getReportServerBaseUri(); - } - - @Override - public String getEndpointName() { - return ENDPOINT_NAME; - } -} diff --git a/src/main/java/org/gridsuite/gateway/endpoints/StateEstimationOrchestratorServer.java b/src/main/java/org/gridsuite/gateway/endpoints/StateEstimationOrchestratorServer.java deleted file mode 100644 index 33d59b4..0000000 --- a/src/main/java/org/gridsuite/gateway/endpoints/StateEstimationOrchestratorServer.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - Copyright (c) 2024, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.gateway.endpoints; - -import org.gridsuite.gateway.ServiceURIsConfig; -import org.springframework.stereotype.Component; - -/** - * @author Franck Lecuyer - */ -@Component(value = StateEstimationOrchestratorServer.ENDPOINT_NAME) -public class StateEstimationOrchestratorServer implements EndPointServer { - - public static final String ENDPOINT_NAME = "state-estimation-orchestrator"; - - private final ServiceURIsConfig servicesURIsConfig; - - public StateEstimationOrchestratorServer(ServiceURIsConfig servicesURIsConfig) { - this.servicesURIsConfig = servicesURIsConfig; - } - - @Override - public String getEndpointBaseUri() { - return servicesURIsConfig.getStateEstimationOrchestratorServerBaseUri(); - } - - @Override - public String getEndpointName() { - return ENDPOINT_NAME; - } -} diff --git a/src/main/java/org/gridsuite/gateway/endpoints/StateEstimationServer.java b/src/main/java/org/gridsuite/gateway/endpoints/StateEstimationServer.java deleted file mode 100644 index 83a8fbe..0000000 --- a/src/main/java/org/gridsuite/gateway/endpoints/StateEstimationServer.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - Copyright (c) 2024, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package org.gridsuite.gateway.endpoints; - -import org.gridsuite.gateway.ServiceURIsConfig; -import org.springframework.stereotype.Component; - -/** - * @author Franck Lecuyer - */ -@Component(value = StateEstimationServer.ENDPOINT_NAME) -public class StateEstimationServer implements EndPointServer { - - public static final String ENDPOINT_NAME = "state-estimation"; - - private final ServiceURIsConfig servicesURIsConfig; - - public StateEstimationServer(ServiceURIsConfig servicesURIsConfig) { - this.servicesURIsConfig = servicesURIsConfig; - } - - @Override - public String getEndpointBaseUri() { - return servicesURIsConfig.getStateEstimationServerBaseUri(); - } - - @Override - public String getEndpointName() { - return ENDPOINT_NAME; - } -} diff --git a/src/main/java/org/gridsuite/gateway/filters/ElementAccessControllerGlobalPreFilter.java b/src/main/java/org/gridsuite/gateway/filters/ElementAccessControllerGlobalPreFilter.java deleted file mode 100644 index 18ae08c..0000000 --- a/src/main/java/org/gridsuite/gateway/filters/ElementAccessControllerGlobalPreFilter.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (c) 2021, RTE (http://www.rte-france.com) - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -package org.gridsuite.gateway.filters; - -import lombok.NonNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.cloud.gateway.filter.GatewayFilterChain; -import org.springframework.core.Ordered; -import org.springframework.stereotype.Component; -import org.springframework.web.server.ServerWebExchange; -import reactor.core.publisher.Mono; - -/** - * @author Slimane Amar - */ -@Component -public class ElementAccessControllerGlobalPreFilter extends AbstractGlobalPreFilter { - - private static final Logger LOGGER = LoggerFactory.getLogger(ElementAccessControllerGlobalPreFilter.class); - - @Override - public int getOrder() { - // Before WebsocketRoutingFilter to control access - return Ordered.LOWEST_PRECEDENCE - 2; - } - - @Override - public Mono filter(@NonNull ServerWebExchange exchange, @NonNull GatewayFilterChain chain) { - LOGGER.debug("Filter : {}", getClass().getSimpleName()); - //TODO: the control is disabled for the moment, it will be processed in another US. For more details contact slimane - return chain.filter(exchange); - } -} - diff --git a/src/test/java/org/gridsuite/gateway/TokenValidationTest.java b/src/test/java/org/gridsuite/gateway/TokenValidationTest.java index 693f422..d6dc89b 100644 --- a/src/test/java/org/gridsuite/gateway/TokenValidationTest.java +++ b/src/test/java/org/gridsuite/gateway/TokenValidationTest.java @@ -287,16 +287,6 @@ private void testToken(UUID elementUuid, String token) { .jsonPath("$[0].id").isEqualTo(elementUuid.toString()) .jsonPath("$[0].caseFormat").isEqualTo("IIDM"); - webClient - .get().uri("merge/v1/configs") - .header("Authorization", "Bearer " + token) - .exchange() - .expectStatus().isOk() - .expectBody() - .jsonPath("$[0].process").isEqualTo("TEST") - .jsonPath("$[0].tsos[0]").isEqualTo("BE") - .jsonPath("$[0].tsos[1]").isEqualTo("NL"); - webClient .get().uri("actions/v1/contingency-lists/metadata?ids=" + elementUuid) .header("Authorization", "Bearer " + token) @@ -322,15 +312,6 @@ private void testToken(UUID elementUuid, String token) { .expectBody() .jsonPath("$[0].name").isEqualTo("test"); - webClient - .get().uri("boundary/v1/boundaries") - .header("Authorization", "Bearer " + token) - .exchange() - .expectStatus().isOk() - .expectBody() - .jsonPath("$[0].name").isEqualTo("boundary1") - .jsonPath("$[0].id").isEqualTo("da47a173-22d2-47e8-8a84-aa66e2d0fafb"); - webClient .get().uri("dynamic-mapping/mappings") .header("Authorization", "Bearer " + token) @@ -348,16 +329,6 @@ private void testToken(UUID elementUuid, String token) { .jsonPath("$[0].id").isEqualTo(elementUuid.toString()) .jsonPath("$[0].type").isEqualTo("LINE"); - webClient - .get().uri("report/v1/reports") - .header("Authorization", "Bearer " + token) - .exchange() - .expectStatus().isOk() - .expectBody() - .jsonPath("$.id").isEqualTo("report1") - .jsonPath("$.reports[0].report").isEqualTo("Lets Rock") - .jsonPath("$.reports[0].date").isEqualTo("2001:01:01T11:11"); - webClient .get().uri("explore/v1/explore/elements/metadata?ids=" + elementUuid) .header("Authorization", "Bearer " + token)