Skip to content

Commit 8ad6686

Browse files
authored
Add spreadsheet config server (#115)
Signed-off-by: achour94 <[email protected]>
1 parent c5390f7 commit 8ad6686

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed

src/main/java/org/gridsuite/gateway/GatewayConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public RouteLocator myRoutes(RouteLocatorBuilder builder, ApplicationContext con
5151
.route(p -> context.getBean(DynamicSimulationServer.class).getRoute(p))
5252
.route(p -> context.getBean(VoltageInitServer.class).getRoute(p))
5353
.route(p -> context.getBean(ShortCircuitServer.class).getRoute(p))
54+
.route(p -> context.getBean(SpreadsheetConfigServer.class).getRoute(p))
5455
.build();
5556
}
5657
}

src/main/java/org/gridsuite/gateway/ServiceURIsConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,7 @@ public class ServiceURIsConfig {
110110

111111
@Value("${gridsuite.services.state-estimation-orchestrator-server.base-uri:http://state-estimation-orchestrator-server/}")
112112
String stateEstimationOrchestratorServerBaseUri;
113+
114+
@Value("${gridsuite.services.spreadsheet-config-server.base-uri:http://spreadsheet-config-server/}")
115+
String spreadsheetConfigServerBaseUri;
113116
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright (c) 2024, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
package org.gridsuite.gateway.endpoints;
8+
9+
import lombok.RequiredArgsConstructor;
10+
import org.gridsuite.gateway.ServiceURIsConfig;
11+
import org.springframework.stereotype.Component;
12+
13+
/**
14+
* @author Achour BERRAHMA <achour.berrahma at rte-france.com>
15+
*/
16+
@RequiredArgsConstructor
17+
@Component(value = SpreadsheetConfigServer.ENDPOINT_NAME)
18+
public class SpreadsheetConfigServer implements EndPointServer {
19+
20+
public static final String ENDPOINT_NAME = "spreadsheet-config";
21+
22+
private final ServiceURIsConfig servicesURIsConfig;
23+
24+
@Override
25+
public String getEndpointBaseUri() {
26+
return servicesURIsConfig.getSpreadsheetConfigServerBaseUri();
27+
}
28+
29+
@Override
30+
public String getEndpointName() {
31+
return ENDPOINT_NAME;
32+
}
33+
}

src/main/resources/application-local.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,5 @@ gridsuite:
6666
base-uri: http://localhost:5040
6767
state-estimation-orchestrator-server:
6868
base-uri: http://localhost:5041
69+
spreadsheet-config-server:
70+
base-uri: http://localhost:5035

src/test/java/org/gridsuite/gateway/ElementAccessControlTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"gridsuite.services.filter-server.base-uri=http://localhost:${wiremock.server.port}",
4949
"gridsuite.services.user-admin-server.base-uri=http://localhost:${wiremock.server.port}",
5050
"gridsuite.services.sensitivity-analysis-server.base-uri=http://localhost:${wiremock.server.port}",
51+
"gridsuite.services.spreadsheet-config-server.base-uri=http://localhost:${wiremock.server.port}",
5152
}
5253
)
5354
@AutoConfigureWireMock(port = 0)
@@ -207,6 +208,27 @@ public void testGetElements() {
207208
stubFor(get(urlEqualTo(String.format("/v1/contingency-lists/%s", uuid))).withHeader("userId", equalTo("user1"))
208209
.willReturn(aResponse()));
209210

211+
stubFor(get(urlEqualTo(String.format("/v1/spreadsheet-configs/%s", uuid))).withHeader("userId", equalTo("user1"))
212+
.willReturn(aResponse()));
213+
214+
webClient
215+
.get().uri(String.format("spreadsheet-config/v1/spreadsheet-configs/%s", uuid))
216+
.header("Authorization", "Bearer " + tokenUser1)
217+
.exchange()
218+
.expectStatus().isOk();
219+
220+
webClient
221+
.get().uri(String.format("spreadsheet-config/v1/spreadsheet-configs/%s", uuid))
222+
.header("Authorization", "Bearer " + tokenUser2)
223+
.exchange()
224+
.expectStatus().isNotFound();
225+
226+
webClient
227+
.get().uri("spreadsheet-config/v1/spreadsheet-configs/invalid-uuid")
228+
.header("Authorization", "Bearer " + tokenUser1)
229+
.exchange()
230+
.expectStatus().isNotFound();
231+
210232
webClient
211233
.get().uri("study/v1/studies")
212234
.header("Authorization", "Bearer " + tokenUser1)

0 commit comments

Comments
 (0)