Questions tagged [wiremock]
Library used for stubbing and mocking web services.
907
questions
-1
votes
0
answers
17
views
Wiremock issue when upgrading to java 17
We have our application using Spring Boot 2.7 with Java 8. Its a restfull webservice that use JAX-RS with jersey for implementation. I am now tring to move to Java 17 and Application is working as ...
0
votes
0
answers
8
views
Showing error for ResponseTemplateTransformer after upgrading wiremock
How to add custom response template using ResponseTemplateTransformer in wiremock-jre8-standalone 3.0.1 version.
After the upgrage from wiremock-jre8 version 2.32.0 to wiremock-jre8-standalone 3.0.1 ...
1
vote
1
answer
17
views
How to migrate `ResponseTemplateTransformer(false)` into WireMock version 3 - Java code
Being on WireMock version 2, I had the following snippet in some test code, which has been meant to instantiate the WireMockConfig object:
com.github.tomakehurst.wiremock.core.WireMockConfiguration....
0
votes
1
answer
24
views
Fetching dynamic values in wiremock from request json to response json
Request Body Payload-
{
"request":{
"method" : "POST",
"urlPattern" :"/payments/v1/payments",
"headers":{
...
0
votes
1
answer
13
views
spring feign request giving error no suitable converter
SO i have a feign client as follows:
@FeignClient(name = "ServiceClient", url = "${base.url}", configuration = FeignClientConfig.class)
public interface ServiceClient {
@...
0
votes
0
answers
11
views
Spring cloud contract Stub runner wire mock request was not matched'
I'm working with Spring Cloud Contract, and I have an endpoint in a stub generated through Spring Cloud Contract. This endpoint takes a path variable '/files/123456' and returns a byte array. However, ...
0
votes
1
answer
24
views
Wiremock proxy unmatched requests
I am investigating a possibility to proxy all the request that do not have mappings in Wiremock.
I found a mechanism to proxy requests creating a mapping for that.
But I want to have an ability to say:...
0
votes
0
answers
17
views
WireMock client throws JsonException on HTTP 308 permanent redirect response from server
I'm running the two following commands in the debugger:
mockServerClient.register(put(urlEqualTo("apiEndpoint")).willReturn(ok()));
mockServerClient.getStubMapping(UUID.fromString("...
-2
votes
1
answer
45
views
Method threw 'javax.net.ssl.SSLException' exception
I have written a JUnit to test one of the method which calls below getAuthToken
public String getAuthToken() throws URISyntaxException, IOException, InterruptedException {
String formBody = String....
0
votes
0
answers
54
views
@SpringBootTest with WireMock fails in GitLab CI pipeline but passes locally
The following is a simplified version of a @SpringBootTest which spins up a RabbitMQ container using Testcontainers.
The basic workflow to be tested is:
Send a message to the target queue.
Reject the ...
0
votes
1
answer
24
views
Wiremock - use random value from response body into postServeActions
this is __admin/mappings:
I have this response:
"response": {
"status":200,
"headers":{"Content-Type" : "application/json"},
"body": {"...
0
votes
0
answers
36
views
How to mock a complete workflow of google oauth2 authentication using wiremock?
I have a situation where I need to mock entire google drive workflow for internal testing. We don't want to use actual service account for testing. I use wiremock and mocked (or I think) following api ...
0
votes
0
answers
21
views
WireMock. How to return different statuses in response to one request?
Is there any way to redesign a query so that it returns a random status: 200 or 400 in the response?
{
"request": {
"name": "My mock",
"urlPath&...
0
votes
0
answers
23
views
WireMock stub to return one element from a JSON array
I am using a standalone version of WireMock for my application.
Previously I had mappings.json where some my endpoints returned a json arrays that were stored in separate files.
Like
{
"mappings&...
1
vote
1
answer
40
views
how to validate if a parameter is not contained in the request using wiremock (Using JSON)
I'm implementing a mock for a /token endpoint that needs to return an error scenario.
{
"mappings": [
{
"name": "Mock error 400: 'code' is not provided",
...
0
votes
1
answer
61
views
How to override twillio sdk base url
I am writing integration tests for twilio using wiremock in kotlin. Any suggestions how to mock it (change base url of client). I am using init method to initialise client but it do not provide ...
0
votes
1
answer
84
views
Wiremock - How to add --no-request-journal and where to add?
I have a Wiremock project. It contains request - response json files, gitlab-ci.yaml and dockerfile.
And also a GUI project related to wiremock project.
Because the old requests are stored to be ...
0
votes
1
answer
75
views
How to solve problem with wiremock on Jenkins? java.net.BindException: Permission denied
I have problem with wiremock test failing on Jenkins. When I try to run it on my local it runs smoothly, but when I tried to run on Jenkins, this exception occured :
[2023-10-09T12:20:41.562Z]
[2023-...
0
votes
1
answer
120
views
Wiremock dynamic response based on request - jsonPath is not working
I'm using Wiremock standalone and below are sample of request/response. jsonPath is not working and it's returing the whole code. What am I doing wrong?
Sample Request
{
"source": "...
0
votes
0
answers
29
views
wiremock newScenarioState based on request model
I would like to use request model attributes in wiremock mappings newScenarioState field.
Is it possible to use request model attributes in newScenarioState field?
Example:
{
"scenario" :...
0
votes
0
answers
68
views
Wiremock, spring-boot, test, @AutoConfigureWireMock, .p12 File
in my spring-boot project i have a lot of tests which uses Wiremock via @AutoConfigureWireMock
I changed my project to SSL and therfore have an .p12 file under resources/keystore.
As long as the file ...
-1
votes
3
answers
170
views
How to use different mapping files for different test methods?
I am using Wiremock (spring-cloud-contract-wiremock) in my @SpringBootTest so:
import static com.github.tomakehurst.wiremock.client.WireMock.*;
@SpringBootTest
@AutoConfigureWireMock(port = 0)
class ...
0
votes
0
answers
43
views
WireMock mTLS does not work wiremock.org.apache.http.NoHttpResponseException: The target server failed to respond
I am trying to test the Apache HttpClient v4.5 using mTLS with WireMock v2.27.2. I followed this page.
Unluckily I get the following errors:
javax.net.ssl.SSLHandshakeException: Empty client ...
0
votes
0
answers
64
views
Generic container initialization failed for cucumter tests
I am trying to initialize and start a docker container from cucumber hooks in order to write integration tests, uing wiremock.
But the issue, is that initialization fails miserably for some reason.
...
0
votes
0
answers
31
views
Dynamically matching bodyFileName to default file when no match
I am running this using the json request mappings and am running the base Docker image with my repo mounted as a volume. I don't want to do any coding for this because then I'd have to also create the ...
0
votes
0
answers
35
views
Docker-Compose with multible containers connection to wiremock didn't work
I have a Docker Compose setup with a Spring Boot application, Database and WireMock. While this configuration works fine locally, the Spring Boot app cannot communicate with WireMock when running in ...
1
vote
1
answer
59
views
Transform a xml response with wiremock
I would like to change the value of a xml element dynamically to return as a response using wiremock. This value has to be calculated according to some project rules at runtime. It is not something I ...
1
vote
1
answer
75
views
Wiremock standalone - Fetching values from request xml for a mock Soap service
I've been trying to create a stub system for a SOAP service using wiremock standalone. I've got the response.xml s ready and I'm required to return them based on an id value in the SOAP request xml.
...
1
vote
1
answer
42
views
In Wiremock how to write a mappingBuilder which matches a requestBody containing a json, having matchingJsonPath value equal to null?
I want to write a java code which can produce following wiremock mapping-
"request":
{
"urlPattern": "/kziwynya/ep1",
"method": &...
0
votes
0
answers
24
views
Filter wiremock stubs
Hi i have spring application that is using wiremock. Its start wiremock with each test by @AutoConfigureWireMock annotation from springframework.cloud.contract. I'm keeping all of my stubs in ...
1
vote
0
answers
62
views
Rest API mocking with wiremock - json
wiremock stub : curl to json generation
I am trying to set up a wiremock stub
curl -X 'PUT’ \ 'https://ip/upload/file’ \ -H 'accept: application/json’ \ -H 'authorization: sso-auth' \ -H 'Content-Type:...
0
votes
0
answers
42
views
Customise wiremock response in Spring Boot Test
I am using wiremock in my integration tests in Spring Boot.
I need to customize the headers in the Http response coming from WireMock server.
I configured wiremock with configuration below:
@Tag("...
0
votes
1
answer
144
views
Wiremock | How to proxy to server that requires mTLS?
I am trying to use wiremock to record requests to a server as well as the resulting responses.
I've already managed to do that but when proxing via wiremock I'm always getting a 401 response stating ...
0
votes
0
answers
99
views
Mock SSE Endpoind with WireMock in Quarkus
I tried to use rest client reactive to access the WireMock SSE endpoint.
@Test
void getEvents() throws Throwable {
var url = "/posts/events";
String dataStream = """
...
0
votes
0
answers
84
views
Wire Mock - Spring Cloud Feign Integration Test
I have a rest controller that talks with a service class, which calls the feign client. The spring application starts fine and works fine. Now I am trying to write integration tests for the spring ...
0
votes
1
answer
111
views
Wiremock Mapping - use array in one of header values for one of the keys
I want to make mapping for my wiremock server. However I have no idea how to map char array instead of string.
"request": {
"urlPathPattern": "/some/url",
"...
0
votes
0
answers
17
views
Wiremock stub receive connection refused in second call in second class
I am stubbing and http call in my integration test twice by using wiremock scenario states. If I make http request in same class then everything works good but in my case second call is made by ...
0
votes
2
answers
143
views
Wiremock XML request matching with XPath contains or RegEx
Need to implement a matching condition with XPath (or with RegEx) text contains and multiple OR values.
My request body:
<person_obj>
<params>
<name>David J</name>
...
0
votes
0
answers
33
views
How to connect Wiremock server with Aerospike (i.e., as Cache DB) with GraphQL using Spring Boot?
I'm planning/trying to implement a sandbox functionality for the GraphQL schema's using Wiremock Server and Aerospike (i.e., Should work as Cache DB) using Spring Boot 3.x.
I've done some samples with,...
0
votes
1
answer
111
views
Error while setting up wiremock extension
I am trying to setup my wiremock server with extensions as described in the official image. But when I deploy the application via helm, I keep getting error :
--extensions com.opentable.extension....
0
votes
1
answer
142
views
Why is this wiremock setup based on wireMockConfig not working?
Why is this wiremock setup based on wireMockConfig not working?
package com.example.wiremockjunitstandalone;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com....
0
votes
0
answers
24
views
How to make Java class to initialize another class, and execute static java code block conditionally
I am using WireMock and managed to configure it to use SSL in JUnit 4 tests and disable throwing error if the hostname doesn't match the WireMock self signed certificate with CN=Tom Akehurst.
The code ...
1
vote
2
answers
43
views
How to match a number between 1 to 12 via regular expression in wiremock bodyPatterns?
My request pattern looks like below
"request": {
"url": "/stripe/v1/payment_methods",
"method": "POST",
"bodyPatterns&...
0
votes
0
answers
43
views
Configure wiremock with two distinct scenarios with the same url
It is possible to configure wiremock with two distinct scenarios?
So the first scenario name is "server error 3 times" will send certain responses on same URL to simulate server error for 3 ...
0
votes
2
answers
295
views
Error javax.net.ssl.SSLHandshakeException: No name matching localhost found when using WireMock Self Signed SSL
I followed the same steps when I tried to use Mockoon Self-Signed SSL, and all worked fine. I exported the Mockoon SSL using Chrome Browser and added it to jssecacerts using keytool and it worked fine....
1
vote
0
answers
131
views
Connection refused in SpringBootTest with WireMock
I'm observing some behavior in my Spring Boot integration tests which I don't yet understand.
Given the following abstract base class which initializes "generic" test stuff; in this case ...
1
vote
1
answer
237
views
Wiremock response template to use json passed in as request query parameter
Provided with the following request:
http://myserver:8080/api/userinfo?Logins=%5B%22admin%40my.domain%22%5D
How would I get the first value in urlencoded-json array of values found in Logins query ...
1
vote
0
answers
161
views
Wiremock - standalone - proxy authorization header
I'm using standalone wiremock and I'm creating a proxy mapping.
The proxy target requires bearer authentication and the token expires every 5 minute.
I don't want to use the static value of the token ...
0
votes
0
answers
40
views
Randomize `status` value
I'm trying to randomize the status returned by a Wiremock (version 2.33.2) endpoint.
Ideally, my configuration would be something like this:
{
"mappings": [
{
"request":...
1
vote
1
answer
184
views
Combining multiple bodyPattern with logical 'OR' in wiremock
I had a question if its possible to combine multiple body patterns with logical 'OR' operation in wiremock
Currently bodyPatterns is an array that support multiple patterns but they are combined with ...