Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 14 21:45
    aaron-pacora edited #966
  • Jan 14 21:45
    aaron-pacora closed #966
  • Jan 14 21:45
    aaron-pacora opened #967
  • Jan 14 21:42
    aaron-pacora opened #966
  • Jan 13 12:27
    fr4ncidir commented #954
  • Jan 13 09:21
    manuel-koch opened #965
  • Jan 12 14:28
    latuszek opened #964
  • Jan 07 00:22
    FrankOwen commented #963
  • Jan 06 21:36
    FrankOwen opened #963
  • Jan 01 14:07
    loveiset opened #962
  • Dec 21 2020 14:15
    boonen labeled #961
  • Dec 21 2020 14:15
    boonen opened #961
  • Dec 21 2020 13:27
    pimuzzo edited #960
  • Dec 21 2020 13:26
    pimuzzo opened #960
  • Dec 19 2020 17:58

    jamesdbloom on master

    downgrading jersey version due … (compare)

  • Dec 18 2020 05:16
    dependabot[bot] labeled #959
  • Dec 18 2020 05:16
    dependabot[bot] labeled #959
  • Dec 18 2020 05:16
    dependabot[bot] opened #959
  • Dec 18 2020 05:16

    dependabot[bot] on maven

    Bump jetty.version from 9.4.35.… (compare)

  • Dec 18 2020 05:15
    dependabot[bot] labeled #958
Evan Brodie
@ecbrodie

Hello Mockserver community.

I would like to know if it is possible to build a Mockserver Expectation where a value of the HTTP Response can be dynamically created based on a value from the HTTP Request. I'm thinking something like capturing a regex match from the request and putting that captured value into the response.

My use case is that I want to match all requests to a particular route, but I want to capture the query parameters. I then want to be able to have these query parameters stored in an HTTP header in my response (in my specific case, the Location header).

Is this currently possible in Mockserver? I am using the API client right now. Thank you.

James D Bloom
@jamesdbloom
@ecbrodie This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join.slack.com/t/mock-server/shared_invite/enQtODM3NDY0NzA1NTQwLWM0NTFmOGJhN2ExNTViNDRmZjk0MDgyOGNmNDU0YjE3YzZhNjBjMmM5Y2FlYTI1ZmJhNzNkMWJkMTE5ZTRlZjM
June
@JuneWangC
Hello Mockserver community, I am new to MockServer and new to java. I have been trying to initialize expectations using the initializationClass configuration property 'java -Dmockserver.initializationClass="org.mockserver.server.initialize.ExpectationInitializerExample" -jar ~/Downloads/mockserver-netty-5.9.0-jar-with-dependencies.jar -serverPort 1080 -logLevel INFO', I have changed the path to jar to my local path, but did not change the initializationClass, I got an error 'java.lang.RuntimeException: java.lang.ClassNotFoundException: ExpectationInitializerIntegrationExample'. What should I do to fix this? Thanks!
James D Bloom
@jamesdbloom
@JuneWangC This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join.slack.com/t/mock-server/shared_invite/enQtODM3NDY0NzA1NTQwLWM0NTFmOGJhN2ExNTViNDRmZjk0MDgyOGNmNDU0YjE3YzZhNjBjMmM5Y2FlYTI1ZmJhNzNkMWJkMTE5ZTRlZjM
@JuneWangC you can only use an initializationClass if it is in the classpath of the JVM otherwise it won't be visible to MockServer, if you run MockServer in embedded mode using the org.mockserver.integration.ClientAndServer class from within the same project containing the initialiser then you should find that easier, see: https://mock-server.com/mock_server/running_mock_server.html#client_api
June
@JuneWangC
@jamesdbloom Thanks for answering, I have joined the Slack group, thank you
haripri-vt
@haripri-vt

Hello I am getting closed web socket connection the very first time the tests are run on a linux machine,
ed-api_1 | 2020-03-20 16:27:17 org.mockserver.log.MockServerEventLog WARNING Client 26f5fe02-ef57-488f-bc8f-74b6c8d118df not found for request ed-api_1 | ed-api_1 | { ed-api_1 | "method" : "GET", ed-api_1 | "path" : "/ws/v1/persons", ed-api_1 | "queryStringParameters" : { ed-api_1 | "uupid" : [ "alice" ] ed-api_1 | }, ed-api_1 | "headers" : { ed-api_1 | "accept-encoding" : [ "gzip" ], ed-api_1 | "user-agent" : [ "ReactorNetty/0.8.12.RELEASE" ], ed-api_1 | "host" : [ "ed-api:1080" ], ed-api_1 | "accept" : [ "*/*" ], ed-api_1 | "content-length" : [ "0" ], ed-api_1 | "WebSocketCorrelationId" : [ "bcf16e0e-035a-426f-8629-e1c35a9125ac" ] ed-api_1 | }, ed-api_1 | "keepAlive" : true, ed-api_1 | "secure" : false ed-api_1 | } ed-api_1 | ed-api_1 | client registry only contains ed-api_1 | ed-api_1 | {26f5fe02-ef57-488f-bc8f-74b6c8d118df=ChannelHandlerContext(CallbackWebSocketServerHandler#0, [id: 0x61d82abe, L:ed-api/192.168.32.4:1080 - R:/192.168.32.6:48448]), 1ae4ae2c-d978-4cb1-9697-167016647d96=ChannelHandlerContext(CallbackWebSocketServerHandler#0, [id: 0xca1b173c, L:ed-api/192.168.32.4:1080 - R:/192.168.32.6:48446]), 8f41ac93-f5f0-4033-8e27-4bd927bae4f0=ChannelHandlerContext(CallbackWebSocketServerHandler#0, [id: 0xb391485f, L:ed-api/192.168.32.4:1080 - R:/192.168.32.6:48444])} ed-api_1 | ed-api_1 | 2020-03-20 16:27:17 org.mockserver.log.MockServerEventLog WARNING Returning ed-api_1 | ed-api_1 | { ed-api_1 | "statusCode" : 404, ed-api_1 | "reasonPhrase" : "Not Found" ed-api_1 | } ed-api_1 | ed-api_1 | because client 26f5fe02-ef57-488f-bc8f-74b6c8d118df has closed web socket connection ed-api_1 | 2020-03-20 16:27:17 org.mockserver.log.MockServerEventLog INFO returning response:

So even though the match was found, im getting a 404, because of this, happens only the first time, and runs fine the second time. Any idea why this might happen?

James D Bloom
@jamesdbloom
@haripri-vt This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join-mock-server-slack.herokuapp.com/
HarryHoudini
@HarryHoudini
Hi everyone. I get a timeout error trying to get requests on the following code from the examples. I increased the timeout to 60 sec set through ConfigurationProperties.maxSocketTimeout, but it did not help
Code:
HttpRequest[] recordedRequests = new MockServerClient("serverIp", 1080) .retrieveRecordedRequests( request() );
error:
[ERROR] Time elapsed: 42.308 s <<< FAILURE!
org.mockserver.client.SocketCommunicationException: Response was not received from MockServer after 35000 milliseconds, to wait longer please use "mockserver.maxSocketTimeout" system property or ConfigurationProperties.maxSocketTimeout(long milliseconds)
But getting the same information through api works - checked in postman. http://serverIp:1080/mockserver/retrieve?type=REQUESTS
What could be the problem?
James D Bloom
@jamesdbloom
@HarryHoudini This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join-mock-server-slack.herokuapp.com/
Robertino Aniello
@raniello
Hi, what's the difference on docker hub between mockserver/mockserver repository and jamesbloom/mockserver repository? Which one should I use? Both refers to the same documentation but the documentation refers to mockserver/mockserver even if the latter has 1M+ pulls agains 100K+ of the official one
Julian B.
@jubui
Hi everyone, I'm using MockServer to mock 50MB json responses. After a fixed number of responses (iirc ~25 responses), MockServer responds with 404 and then a short while later I get "Exception in thread "MockServer-EventLog0" java.lang.OutOfMemoryError: Java heap space". My mock is using a callback with a fixed static buffer, so I'm not creating it at every invocation of the callback. Is there something simple I can do to avoid this? MockServer is in a separate process, right? So how can I, from my junit rule, configure the heap size of the other process? Or is there something I can do to optimize the memory usage?
vivekmalhotragithub
@vivekmalhotragithub
hi I created an expectation that mock-server gets a POST request with a gzipped body but when i actually send it a gzipped body the expectation fails. I also dont see my content-type : gzip header in mock-server logs. Is it because mock-server automatically unzips the body ?
Hem Chand
@versatile-hem

0

I am facing an issue in apache http configuration.

Requirement :

A request has land on apache with some header.

for example :

Header myToken

Url https://localhost/fetch-r

Response new Url https://localhost/fetch-r?id=myToken

How can i achieve this in Apache Http 2.4 ?

can any one help me here ?
James D Bloom
@jamesdbloom
@raniello This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join-mock-server-slack.herokuapp.com/
@jubui This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join-mock-server-slack.herokuapp.com/
@vivekmalhotragithub This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join-mock-server-slack.herokuapp.com/
@versatile-hem This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join-mock-server-slack.herokuapp.com/
@/all This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join-mock-server-slack.herokuapp.com/
kapokmi
@kapokmi

@here, For an integration test, I am running 5 services, mocked using mockserver by spinning them up with docker compose. Here is my docker compose file:

version: "3.7"
services:
  order-management-webapp:
    image: mockserver/mockserver:mockserver-5.10.0
    command: -logLevel DEBUG -serverPort 1080
    ports:
      - ${ORDER_MGMT_PORT}:1080
    networks:
      - default
  location-webapp:
    image: mockserver/mockserver:mockserver-5.10.0
    ports:
      - ${LOCATION_PORT}:1080
    networks:
      - default
  availability-webapp:
    image: mockserver/mockserver:mockserver-5.10.0
    ports:
      - ${AVAILABILITY_PORT}:1080
    networks:
      - default
  supplier-webapp:
    image: mockserver/mockserver:mockserver-5.10.0
    ports:
      - ${SUPPLIER_PORT}:1080
    networks:
      - default
  content-webapp:
    image: mockserver/mockserver:mockserver-5.10.0
    ports:
      - ${CONTENT_PORT}:1080
    networks:
      - default

networks:
  default:
    name: integration-test-network

I would like to get the logs of order-management-webapp for which I have increased the log level. How can I do that please?
The mockserver doc does not provide any details on getting logs when using docker-compose and I am very new to Mockserver. Thanks in advance for your answers!

James D Bloom
@jamesdbloom
@kapokmi This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join-mock-server-slack.herokuapp.com/
@kapokmi the logs get printed out on the console so your’l need to look at the console logs for that container using docker-compose
sarut0bi
@sarut0bi
hi, i am using mockServer.mockServerClient javascript client, my instance of mockserver is running behind an api proxy which needs extra authentification header, any way to use the javascript client in this case?
James D Bloom
@jamesdbloom
@sarut0bi This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join-mock-server-slack.herokuapp.com/
@sarut0bi I think the setDefaultHeaders() function on the client should allow you to do what you need to set some default headers for proxy authentication
Java Auto QA Tools
@jaqat
изображение.png
Hi all. There is a problem with cast RequestDefinition to HttpRequest in latest Java Client lib
James D Bloom
@jamesdbloom
@jaqat This chat group has migrated to Slack if you would like to join the new Slack group please use the following link https://join-mock-server-slack.herokuapp.com/
@jaqat you can't cast an array in java, you need to do something like the following Arrays.stream(requests).map(HttpRequest.class::cast).toArray(HttpRequest[]::new)
Paul Fortin
@pfortin-urbn
I need to take the input request parse it and use some of that data in the response. I have not seen any examples of how to do that I was wondering if there is one or oen could be provided please?
Paul Fortin
@pfortin-urbn
BTW I am using python/tavern to test my APIs with mock server and the API creates some data and passes it to mockserver which will use it to create a response...
Fabien DUMINY
@fduminy
hi all
Fabien DUMINY
@fduminy
I am trying to record request and response of a REST server. I ran command "mvn -Dmockserver.serverPort=1080 -Dmockserver.proxyRemoteHost=8060 -Dmockserver.logLevel=INFO org.mock-server:mockserver-maven-plugin:5.11.1:runForked" and can browse "http://127.0.0.1:1080/mockserver/dashboard". But I can't call my webservice replacing only the port by 1080 in the URL. What's wrong ?
for example, when using http://127.0.0.1:1080/Api/swagger-ui.html instead of http://127.0.0.1:8060/Api/swagger-ui.html I got a 404 error
Fabien DUMINY
@fduminy
in the dashboard, I see my request in received request panel and I see "NO_MATCH_RESPONSE" in the log panel. any idea what's the problem ?
Fabien DUMINY
@fduminy
I found the problem : I was setting proxyRemoteHost instead of proxyRemotePort
Fabien DUMINY
@fduminy
hi all
Fabien DUMINY
@fduminy
I captured requests and responses and saved it as a json. I would like to verify that actual request and responses matches with java code : I call initializationJsonPath(expectations) and call the WS to test. I modified the json file of expectations but that still match actual requests/responses
Fabien DUMINY
@fduminy
I see that activeExpectation is empty. It's like if my file wasn't loaded despite I see "loading JSON initialization file: "mockserverInitialization.json" in the logs
Fabien DUMINY
@fduminy
Hi @jamesdbloom. Do you have an example showing how to run mockserver both as a proxy and as a verifier using a json file with expected request & response ?
DenisSerebryansky
@DenisSerebryansky

Hi guys

My goal is to setup HTTP server mock in code and then reach this mocked server from remote (in my case from within docker container).
After start of my mocked server (startClientAndServer(1180)) I can reach it from local host machine, but not from remote (curl -XGET http://host.docker.internal:1180/ from within container leads to "Connection refused" error, whereas I can easily reach another service launched on my host machine)

How should I configure my mock-server in order to make it available from remote?

Wagner Caetano
@WagnerCaetano
Hey Guys,
i want to know if there's a way of converting the requests body charsets from retrieveRecordRequests because those body are in a different charset that i'm comparing , for example the expect is às and the incoming is à s and my request is being made as expected. (Btw i updated mock server version , it was on 5.6.1 now it's on 5.11.0 and use to work well on 5.6.1)
angus
@dangus21
is there a way to set required queryParameters?
manjeet1987
@manjeet1987

Hi Guys,

Can anyone please tell me How can I create POST request expectations with JSONPATH with multiple fields in request body.

I am able to create expectation for get end point but not sure How I can call endpoint for post request with multiple fields with JsonPath or any other way to create it.


My Post request that I want call in postman.
http://localhost:8080/api/xyz?simulation=false
Body:
{
"alias": "Mister XYZ",
"accountId": "BE122",
"accountType": "IBAN", //this is ENUM
"address": {
"countryCode": "BE"
}
}


And for this I am creating expectation like below
( It created successfully with 201 created ):

PUT: http://localhost:8080/mockserver/expectation
Body:
"httpRequest": {
"path": "/api/xyz",
"method": "POST",
"queryStringParameters": {
"?simulation": ["false"]
},
"headers": {
"Content-Type" : [ "application/json" ],
"Authorization": ["Bearer .+"]
},
"body": [
{
"type": "JSON_PATH",
"jsonPath": "$[?(@.['alias'] == 'Mister XYZ')]"
},
{
"type": "JSON_PATH",
"jsonPath": "$[?(@.['accountId'] == 'BE122')]"
},
{
"type": "JSON_PATH",
"jsonPath": "$[?(@.['accountType'] =~ /(IBAN|BAN|BBAN|OTHER)/)]" //these are ENUMs
}
{
"type": "JSON_PATH",
"jsonPath": "$.['address'].[?(@.['countryCode'] == 'BE')]"
}
]
},
"httpResponse": {
"statusCode": 201,
"headers": {
"Content-Type": ["application/json"]
},
"body": {
"id": "5a0eaf2012a9a12f1c98947a"
}
}
}

Also give me some solution for ENUM type of fields like accountType in above request. How can I handle it?

Please let me know if you want more clarification on this problem.

Inês Moreira
@simoreira
hey @jamesdbloom, quick question: is it possible to delete expectations by id with the mockserver javascript client?
Ghost
@ghost~55aad2398a7b72f55c3fc7ff
Hi all, I'm having some trouble with my expectations not aligning with what I want. I have my mock server set to respond with mock data when requested on 4 different paths, all GET requests. But for some reason the path it expects turns out to be different from the path it gets every time causing it to fail, but there's no way for me to figure out why its contacting the wrong path in the first place
org.mockserver.logging.MockServerLogger [MockServer-EventLog0] INFO  13030 request:

  {
    "method" : "GET",
    "path" : "/services/rest/server/containers/test_1.0.0/processes",
    "queryStringParameters" : {
      "pageSize" : [ "1000" ],
      "page" : [ "0" ],
      "sortOrder" : [ "true" ]
    },
    "headers" : {
      "Host" : [ "localhost:13030" ],
      "Connection" : [ "Keep-Alive" ],
      "User-Agent" : [ "Apache-HttpClient/4.5.12 (Java/15.0.1)" ],
      "Accept-Encoding" : [ "gzip,deflate" ],
      "content-length" : [ "0" ]
    },
    "keepAlive" : true,
    "secure" : true
  }

 didn't match expectation:

  {
    "id" : "ffce78dc-60a3-4022-af3a-290049ce251b",
    "priority" : 0,
    "httpRequest" : {
      "method" : "GET",
      "path" : "/services/rest/server/containers/test_1.0.0/processes/instances",
      "queryStringParameters" : {
        "page" : [ "0" ],
        "status" : [ "1" ],
        "pageSize" : [ "1000" ],
        "sortOrder" : [ "true" ]
      }
    },
    "times" : {
      "unlimited" : true
    },
    "timeToLive" : {
      "unlimited" : true
    },
    "httpResponse" : {
      "statusCode" : 200,
      "headers" : {
        "content-type" : [ "application/json" ]
      },
      "body" : ...
the paths seem to be mismatched but I have no idea why
Lucas
@j-lucas-d
Hi. A question for the room; I need to configure a mock-server with multiple expectations, which all use the same path. They have different HTTP methods and URL parameters. From my testing, it seems the mock server is only keeping the last expectation. Is there a way to have them all configured?