Questions tagged [wiremock]

Library used for stubbing and mocking web services.

Wiremock is a library written in Java by Tom Akehurst. It is used for stubbing and mocking web services. It supports HTTP response stubbing, request verification, proxy/intercept, record/playback of stubs and fault injection, and can be used from within a unit test or deployed into a test environment.

For more information see http://wiremock.org

894 questions
2
votes
1 answer

Wiremock withQueryParam not matching regex

I'm trying to do this: stubFor(get("/my/path") .withQueryParam("paramName", matching(format("^(%s)|(%s)|(%s)$", v1, v2, v3))) .willReturn(okJson(RESPONSE))); and I get this error: GET …
Jordan Silva
  • 833
  • 8
  • 18
2
votes
1 answer

Wiremock standalone JSON response.ok equals false never reached

I am trying to test different fetch failure scenarios for a JS app using Wiremock standalone with JSON mappings. try { const response = await fetch('/api', options); // 1 if (response.ok) { // do something with a successful response }…
mummybot
  • 2,668
  • 2
  • 28
  • 31
2
votes
0 answers

Use JSON schema check on POST request with WireMock

I'm using WireMock (Docker) docker.io/rodolpheche/wiremock:2.27.2-alpine. I set it up via Docker Compose and everything works flawlessly. I'm trying to set up a stub/mapping to check the JSON input against the corresponding JSON schema. Basically,…
x80486
  • 6,627
  • 5
  • 52
  • 111
2
votes
0 answers

Wiremock, get request mappings with absoluteUrl that shows host

I am checking all the stubs using http://localhost:9001/__admin/mappings. Pls can you tell if there is a flag we can add in this path http://localhost:9001/__admin/mappings, which can list all mappings with absoluteUrl, just not urlPathPattern. I…
ApprenticeWST
  • 117
  • 1
  • 7
2
votes
1 answer

How we can ignore the order of query parameter in WireMock

Suppose I have endpoint: /url?number="321"&name="TEST" but when we are matching a request matching how we want to ignore the order of query parameter(ignore order of query param) In this case if pass query param in query param tag then I will not…
Piyush Garg
  • 37
  • 2
  • 10
2
votes
0 answers

Disable Request Journaling, without restarting

I want to proxy requests and then snapshot them using Wiremock. So I have to have request-journaling enabled. But for subsequent runs, after taking the snapshot, I don't really need this functionality, is there a way to switch the config, without…
uncaught_exceptions
  • 21,712
  • 4
  • 41
  • 48
2
votes
1 answer

How to remove the last comma in an each loop in Wiremock

I need to write a stub for a request that would look something like this: [ { "todo_id": 1 }, { "todo_id": 2 } ] The number of todo objects in the request can vary. My response currently looks like this: "response": { "status": 200, …
2
votes
0 answers

wiremock stub with query params not working

I am trying to match this url path - /abc-service/abc?param1=value1¶m2=VALUE_2 This gets matched with a json file as below { "request": { "method": "GET", "urlPathPattern": "/abc-service/abc(.*)" }, "response": { "headers": { …
Mia
  • 61
  • 5
2
votes
1 answer

How to use mappingsloader in wiremock to load mappings file(s)?

I have created my mappings by recording the server's transactions. Now I want to use my json mapping file(s) to load the mappings. For that I have the code below: import com.github.tomakehurst.wiremock.WireMockServer; public class mockedTests{ …
Mansour.M
  • 500
  • 4
  • 18
2
votes
1 answer

Is it possible to mock two ports using Java version of Wiremock-standalone?

I have an app which fetches some data from a url on port 8085. processes the data, then sends it to another url on port 8080 for another process, then processes the response from port 8080 again. Is it possible to have either wiremock or wiremock…
Mansour.M
  • 500
  • 4
  • 18
2
votes
0 answers

How to do parallel wire mock test execution having dynamic stubbing through json files

I am currently running a single test case with wire mock. Following is the code snippet: @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class, webEnvironment = DEFINED_PORT) public class ResolveIT { @ClassRule public static…
2
votes
1 answer

Wiremock url matching - "null. When using a regex, "?" should be "\\?". URLs must start with a /"

I have a urlPattern: "urlPattern" : "^\/blah\/players\/1000\/game\/tickets\\?drawFrom=(.*)&drawTo=(.*)&take=10&skip=0" But when trying to match them, I get "Request not matched" and this error <<<<< null. When using a regex, "?" should be "\\?".…
JoeGeC
  • 187
  • 3
  • 10
2
votes
1 answer

How to setup standalone wiremock server under an application path

I am trying to setup wiremock under an application path. I have wiremock dockerized and running under some path https://local.wiremock/ and that works fine, so I can access the admin like this https://local.wiremock/__admin/docs However when I…
Nick
  • 2,877
  • 2
  • 33
  • 62
2
votes
2 answers

wiremock with 2 services on different ports

I'm struggling a bit with wiremock. I have 2 HTTP calls that need to be made. They are on different ports. I have create 2 rules in the test on different ports. The 1 configured URL is working fine(I received the expected response in my code). The…
user3465651
  • 706
  • 1
  • 4
  • 22
2
votes
0 answers

Wiremock: byte range request for mp4

I'm trying to mock a byte range request for mp4 videos with Wiremock (standalone jar). My mapping is currently: {"mappings": [ { "request": { "method": "GET", "urlPathPattern": "/video/(.*?).mp4" }, "response": { …
Sebastian
  • 3,379
  • 2
  • 23
  • 39