Skip to content

Commit 3c49b9d

Browse files
authored
Add spreadsheet config collections endpoints (#123)
Signed-off-by: Ayoub LABIDI <[email protected]>
1 parent f549118 commit 3c49b9d

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-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
@@ -54,6 +54,7 @@ public RouteLocator myRoutes(RouteLocatorBuilder builder, ApplicationContext con
5454
.route(p -> context.getBean(ShortCircuitServer.class).getRoute(p))
5555
.route(p -> context.getBean(StateEstimationOrchestratorServer.class).getRoute(p))
5656
.route(p -> context.getBean(SpreadsheetConfigServer.class).getRoute(p))
57+
.route(p -> context.getBean(SpreadsheetConfigCollection.class).getRoute(p))
5758
.build();
5859
}
5960
}
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 Ayoub LABIDI <ayoub.labidi at rte-france.com>
15+
*/
16+
@RequiredArgsConstructor
17+
@Component(value = SpreadsheetConfigCollection.ENDPOINT_NAME)
18+
public class SpreadsheetConfigCollection implements EndPointServer {
19+
20+
public static final String ENDPOINT_NAME = "spreadsheet-config-collections";
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/test/java/org/gridsuite/gateway/ElementAccessControlTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,24 +207,45 @@ void testGetElements() {
207207
stubFor(get(urlEqualTo(String.format("/v1/spreadsheet-configs/%s", uuid))).withHeader("userId", equalTo("user1"))
208208
.willReturn(aResponse()));
209209

210+
stubFor(get(urlEqualTo(String.format("/v1/spreadsheet-config-collections/%s", uuid))).withHeader("userId", equalTo("user1"))
211+
.willReturn(aResponse()));
212+
210213
webClient
211214
.get().uri(String.format("spreadsheet-config/v1/spreadsheet-configs/%s", uuid))
212215
.header("Authorization", "Bearer " + tokenUser1)
213216
.exchange()
214217
.expectStatus().isOk();
215218

219+
webClient
220+
.get().uri(String.format("spreadsheet-config/v1/spreadsheet-config-collections/%s", uuid))
221+
.header("Authorization", "Bearer " + tokenUser1)
222+
.exchange()
223+
.expectStatus().isOk();
224+
216225
webClient
217226
.get().uri(String.format("spreadsheet-config/v1/spreadsheet-configs/%s", uuid))
218227
.header("Authorization", "Bearer " + tokenUser2)
219228
.exchange()
220229
.expectStatus().isNotFound();
221230

231+
webClient
232+
.get().uri(String.format("spreadsheet-config/v1/spreadsheet-config-collections/%s", uuid))
233+
.header("Authorization", "Bearer " + tokenUser2)
234+
.exchange()
235+
.expectStatus().isNotFound();
236+
222237
webClient
223238
.get().uri("spreadsheet-config/v1/spreadsheet-configs/invalid-uuid")
224239
.header("Authorization", "Bearer " + tokenUser1)
225240
.exchange()
226241
.expectStatus().isNotFound();
227242

243+
webClient
244+
.get().uri("spreadsheet-config/v1/spreadsheet-config-collections/invalid-uuid")
245+
.header("Authorization", "Bearer " + tokenUser1)
246+
.exchange()
247+
.expectStatus().isNotFound();
248+
228249
webClient
229250
.get().uri("study/v1/studies")
230251
.header(HttpHeaders.AUTHORIZATION, "Bearer " + tokenUser1)

0 commit comments

Comments
 (0)