Skip to content

Commit 4836c9e

Browse files
committed
feat: #144 Allow getting validation-enabled URLs
Signed-off-by: Laurent Broudoux <laurent.broudoux@gmail.com>
1 parent 8782c8f commit 4836c9e

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/main/java/io/github/microcks/testcontainers/MicrocksContainer.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,26 @@ public String getSoapMockEndpointPath(String service, String version) {
248248
return String.format("/soap/%s/%s", service, version);
249249
}
250250

251+
/**
252+
* Get the exposed mock endpoint - with request validation enabled - for a SOAP Service.
253+
* @param service The name of Service/API
254+
* @param version The version of Service/API
255+
* @return A usable endpoint to interact with Microcks mocks.
256+
*/
257+
public String getValidatingSoapMockEndpoint(String service, String version) {
258+
return String.format("%s/soap/%s/%s?validate=true", getHttpEndpoint(), service, version);
259+
}
260+
261+
/**
262+
* Get the exposed mock endpoint path - with request validation enabled - for a SOAP Service.
263+
* @param service The name of Service/API
264+
* @param version The version of Service/API
265+
* @return A path endpoint to interact with Microcks mocks - starts with '/'.
266+
*/
267+
public String getValidatingSoapMockEndpointPath(String service, String version) {
268+
return String.format("/soap/%s/%s?validate=true", service, version);
269+
}
270+
251271
/**
252272
* Get the exposed mock endpoint for a REST API.
253273
* @param service The name of Service/API
@@ -268,6 +288,26 @@ public String getRestMockEndpointPath(String service, String version) {
268288
return String.format("/rest/%s/%s", service, version);
269289
}
270290

291+
/**
292+
* Get the exposed mock endpoint - with request validation enabled - for a REST API.
293+
* @param service The name of Service/API
294+
* @param version The version of Service/API
295+
* @return A usable endpoint to interact with Microcks mocks.
296+
*/
297+
public String getValidatingRestMockEndpoint(String service, String version) {
298+
return String.format("%s/rest-valid/%s/%s", getHttpEndpoint(), service, version);
299+
}
300+
301+
/**
302+
* Get the exposed mock endpoint path - with request validation enabled - for a REST API.
303+
* @param service The name of Service/API
304+
* @param version The version of Service/API
305+
* @return A path endpoint to interact with Microcks mocks - starts with '/'.
306+
*/
307+
public String getValidatingRestMockEndpointPath(String service, String version) {
308+
return String.format("/rest-valid/%s/%s", service, version);
309+
}
310+
271311
/**
272312
* Get the exposed mock endpoint for a GRPC Service.
273313
* @param service The name of Service/API

src/test/java/io/github/microcks/testcontainers/MicrocksContainerTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ private void testMockEndpoints(MicrocksContainer microcks) {
228228

229229
String baseGraphPath = microcks.getGraphQLMockEndpointPath("Pastries Graph", "1");
230230
assertEquals("/graphql/Pastries Graph/1", baseGraphPath);
231+
232+
String validWsUrl = microcks.getValidatingSoapMockEndpoint("Pastries Service", "1.0");
233+
assertEquals(microcks.getHttpEndpoint() + "/soap/Pastries Service/1.0?validate=true", validWsUrl);
234+
235+
String validApiUrl = microcks.getValidatingRestMockEndpoint("API Pastries", "0.0.1");
236+
assertEquals(microcks.getHttpEndpoint() + "/rest-valid/API Pastries/0.0.1", validApiUrl);
237+
238+
String validWsPath = microcks.getValidatingSoapMockEndpointPath("Pastries Service", "1.0");
239+
assertEquals("/soap/Pastries Service/1.0?validate=true", validWsPath);
240+
241+
String validApiPath = microcks.getValidatingRestMockEndpointPath("API Pastries", "0.0.1");
242+
assertEquals("/rest-valid/API Pastries/0.0.1", validApiPath);
231243
}
232244

233245
private void testMicrocksMockingFunctionality(MicrocksContainer microcks) {

0 commit comments

Comments
 (0)