Stub mapping
{
"request": {
"method": "GET",
"urlPathPattern": "/validation/session/([a-zA-Z0-9/-]*)"
},
"response": {
"status": 200,
"jsonBody": {
"isIpBlocked": "Y",
"serviceMessage": {
"type": "OK",
"code": "200",
"description": "IP validated successfully. No result found"
}
},
"headers": {
"Content-Type": "application/json"
}
}
}
cannot match the URL
https://mywebsite/validation/session/687d69ae-42a8-4584-a395-8e0c876bacae (Both absolute path and the relative path is not working)
Also tried replacing urlPathPattern with urlPattern with no success
Tried all the below combination. Nothing worked
/validation/session/([a-zA-Z0-9\\-]+)
/validation/session/([a-zA-Z0-9\\-]*)
/validation/session/([a-zA-Z0-9/-]+)
/validation/session/([a-zA-Z0-9/-]*)
Note: Wiremock version 2.18.0, Spring Boot 2.0
Actually, except url (in stub mapping with absolute URL) nothing is working for me.
It works perfectly if I use Wiremock alone. It doesn't work if I use Wiremock in tandem with WireMockRestServiceServer (spring-cloud-contract).
Working code - with Wiremock alone
@Rule
public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8080).httpsPort(443));
stubFor(get(urlMatching("/validation/session/([a-zA-Z0-9/-]*)")) .willReturn(aResponse().withStatus(HttpStatus.OK.value()).withHeader("Content-Type", "application/json")
.withBody("{\"isIpBlocked\": \"Y\"}")));
Not working - code with WireMockRestServiceServer
MockRestServiceServer server = WireMockRestServiceServer.with(this.restTemplate)
.stubs("classpath:/stubs/**/validate-ip-success-mock-response.json").build();