Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 09 16:50
    baniocarpentercode42 opened #760
  • Apr 08 23:08
    mattnelson opened #759
  • Apr 07 13:30
    golx opened #758
  • Apr 06 17:13

    jamesdbloom on master

    Add apiVersion to Chart.yaml M… (compare)

  • Apr 06 17:13
    jamesdbloom closed #756
  • Apr 06 14:35
    jakubjab commented #756
  • Apr 06 11:42
    jamesdbloom commented #756
  • Apr 06 09:02
    jakubjab commented #756
  • Apr 06 08:54
    jamesdbloom commented #756
  • Apr 06 08:49
    jamesdbloom closed #757
  • Apr 06 08:49
    jamesdbloom commented #757
  • Apr 06 08:35
    davidwestonuk2000 labeled #757
  • Apr 06 08:35
    davidwestonuk2000 opened #757
  • Apr 06 08:21
    jakubjab commented #756
  • Apr 06 08:08
    jamesdbloom commented #756
  • Apr 06 08:03
    jakubjab opened #756
  • Apr 06 02:46
    gabrielkirsten commented #755
  • Apr 06 02:45
    gabrielkirsten closed #755
  • Apr 06 02:45
    gabrielkirsten commented #755
  • Apr 06 00:48
    gabrielkirsten edited #755
Raajeev H dave
@Raajeevhdave_twitter
Any help will be appriciated
niklasuhrberg
@niklasuhrberg

Hello all, I have a testsuite which uses a standalone mock server instance and the tests use a client created like so return new MockServerClient("localhost", 1080); The test are run locally (using Docker containers ) and in a Jenkins job (also using Docker containers) and things have worked very nicely. However, for reasons that I cannot figure out the Jenkins job is now failing and I have localized the failing step to where the test issue reset() on the mockserver client : MockServerClient mc = mockserverClient(); mc.reset(); (where mockserverClient()just does the creation stated above. In the log of the MockServer container I see java -Xmx128m -Dfile.encoding=UTF-8 -jar /opt/mockserver/mockserver-netty-jar-with-dependencies.jar -serverPort 1080 -logLevel INFO & 2019-10-21 07:57:26,307 INFO o.m.m.HttpStateHandler started on port: 1080 2019-10-21 07:59:18,581 INFO o.m.m.HttpStateHandler resetting all expectations and request logs 2019-10-21 07:59:18,837 INFO o.m.m.HttpStateHandler resetting all expectations and request logs 2019-10-21 07:59:18,878 INFO o.m.m.HttpStateHandler resetting all expectations and request logs 2019-10-21 07:59:18,936 INFO o.m.m.HttpStateHandler resetting all expectations and request logs 2019-10-21 07:59:18,969 INFO o.m.m.HttpStateHandler resetting all expectations and request logs 2019-10-21 07:59:19,038 INFO o.m.m.HttpStateHandler resetting all expectations and request logs 2019-10-21 07:59:19,073 INFO o.m.m.HttpStateHandler resetting all expectations and request logs 2019-10-21 07:59:19,162 INFO o.m.m.HttpStateHandler resetting all expectations and request logs 2019-10-21 07:59:19,242 INFO o.m.m.HttpStateHandler resetting all expectations and request logs 2019-10-21 07:59:26,098 INFO o.m.m.HttpStateHandler resetting all expectations and request logs 2019-10-21 07:59:31,684 INFO o.m.m.HttpStateHandler resetting all expectations and request logs and the test log shows that it's the reset step that fails with a org.mockserver.client.ClientException : ```com.resurs.signicatdocumentmover.workinitiator.service.AlternativeFlowsIntegrationTest > service_disabled_renders_no_action FAILED
java.lang.Exception
Caused by: org.mockserver.client.ClientException at AlternativeFlowsIntegrationTest.java:133 ( mc.reset() )

com.resurs.signicatdocumentmover.workinitiator.service.AlternativeFlowsIntegrationTest > multiple_taskinfo_searches_for_current_period FAILED
org.mockserver.client.ClientException at AlternativeFlowsIntegrationTest.java:391 ( mc.reset(); )

com.resurs.signicatdocumentmover.workinitiator.service.AlternativeFlowsIntegrationTest > no_taskinfo_for_current_period_and_next_period_too_recent_yields_no_action FAILED
java.lang.Exception
Caused by: org.mockserver.client.ClientException at AlternativeFlowsIntegrationTest.java:336 ``` ( mc.reset(); ) I have no idea about why this happens, anyone with a clue?

scierniak
@scierniak
Hello, did someone already use configuration option: mockserver.disableRequestAudit=true ? into our env, we are generating too much traffic for mock server and so we would like to not store the requests as we are not using /verify. But I always see the requests when using /retrieve, did I misunderstand this option ?
scierniak
@scierniak

FYI, I do:
cmd : docker run -p1080:1080 jamesdbloom/mockserver:latest -serverPort 1080 -jvmOptions "-Dmockserver.disableRequestAudit=true"
executing: java -Dmockserver.disableRequestAudit=true -Dfile.encoding=UTF-8 -jar /opt/mockserver/mockserver-netty-jar-with-dependencies.jar -serverPort 1080 -logLevel INFO

And I got 202 response when do PUT http://localhost:1080/mockserver/verify with {
"httpRequest": {
"method": "GET",
"path": "/demo",
"queryStringParameters": {
"test": [
"1"
]
}
},
"times": {
"atLeast": 1,
"atMost": 2
}
}

yhjhoo
@yhjhoo
hi, Does mock-server support browser proxy?
the document doesn't seem to be clear about this
ZCH2005
@ZCH2005
anyone knows how to set up MockServer to support https?
Franz Allan Valencia See
@franz-see
@ZCH2005 im using mockserver to record and replay against https and seems to work out of the box without any special configuration
@yhjhoo it creates a mock server, if you can connect your browser to your mockserver as proxy, then theoretically, it should work :)
not sure though if it was meant for htat
i.e. not sure if it can handle images, css, html, js, etc
any body knows how to do mock server expectations wherein part of the response echos back part of the request?
Asif Ameer
@Asif-Ameer-Bose
@franz-see I use response templates with javascript code to handle the processing. Look at http://www.mock-server.com/mock_server/creating_expectations.html#button_javascript_templated_response to see an example.
egonzalezfaster
@egonzalezfaster
is it possible to run expectations with Mockserver running or at Docker ???
sowmya
@sowmya2709_gitlab
Hi All, I downloaded the mockerver repo to my Intellij and have been struggling to get the maven dependecies to resolve, we use Nexus and have made change to refer to Nexus
However the problem still continues to exists.... I am interested in the MockProxy server for one of the projects
pforesi
@pforesi
Hi All, I'm trying to match a request which has "[" and "]" characters into the querystring and I can't manage to make it works. Does anybody have a clue about this. Thanks in advance.
Manuel EVENO
@meveno
Hi everyone
Is there a way to use path param in response or body fields (json input) in response ?
Manuel EVENO
@meveno
In the doc, we can see how to use headers or request attributes but I can't find out how to use json body values
Asif Ameer
@Asif-Ameer-Bose
@meveno try the template response format and use JSON.parse(request.body.string).<yourfield> within the javascript.
Manuel EVENO
@meveno
ok I'll try this ! Thanks
PetersonZhang
@PetersonZhang
hello
anyone here?
Rajendra Prasad Reddy Penumalli
@rajendrapenumalli
How to add an expectation ( via REST interface) to match certain headers and and ignoring any other headers ? Is it possible? I don't find this example or capability for mock server for this feature.
James D Bloom
@jamesdbloom
@/all This chat group is migrating 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
There will in due course be an auto-join page but for now the two ways to join the new slack group is to either use this link https://join.slack.com/t/mock-server/shared_invite/enQtODM3NDY0NzA1NTQwLWM0NTFmOGJhN2ExNTViNDRmZjk0MDgyOGNmNDU0YjE3YzZhNjBjMmM5Y2FlYTI1ZmJhNzNkMWJkMTE5ZTRlZjM which expires in 30 days or send an email to join.mock.server@gmail.com
Parag Somani
@paragsomani

Hello @jamesdbloom

I was able to run the mock-server successfully using docker container. I was able to create expectation and access via REST interface successfully.

Can you assist, how can i persist created expectation, so that even after restart, i should be able to access them.

P.S. I have tried mounting volume to docker container, but did not have luck. Looks like i am missing something.

James D Bloom
@jamesdbloom
@/all @paragsomani 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
James D Bloom
@jamesdbloom
@paragsomani there is no current support for persisting expectations because typically MockServer expectations are created inside the test using them, long-running expectations is an anti-pattern for tests because this introduces coupling and break encapsulation making those tests more complex and harder to debug, there, however, other use cases where persisted expectations could help, such as when a service is not yet available but integration development can't wait, so this item is on the backlog: https://trello.com/c/qOgJgBee/26-persistence-expectations to persistence expectations
Parag Somani
@paragsomani
thank you @jamesdbloom
Christoph
@Chr3is
Hey, I'm using the mockserver to return an xml response with a custom mediatype. The xml has the encoding flag utf8. Everything is working fine if the contenttype is declared as application/xml. However if you use application/my.type+xml I'm receiving a RuntimeException (java.lang.RuntimeException: [was class java.io.CharConversionException] Invalid UTF-8 middle byte 0x4c (at char #961, byte #54)). The mockserver does not return the xml utf8 encoded. If you add the charset=utf8 to the custom mediatype it is working again. I think the mockserver should support the mediatye application/*+xml.
James D Bloom
@jamesdbloom
@Chr3is 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
@Chr3is which version of MockServer are you using? I have just improved the handling of content-type header formats, but it would be good to ensure there is a test covering your exact format. Can you please tell the exact string your using for content-type?
James D Bloom
@jamesdbloom
@Chr3is the new parsing logic can happily handle application/my.type+xml, application/my.type+xml;charset=utf-8 or application/my.type+xml; Charset="utf-8" without any issue
this logic is available in version 5.8.0 (the latest version)
Christoph
@Chr3is
And the response is utf8 encoded? The spring web client who handled the response had the problem if the xml string I wanted to return contained chars like the german Ö or Ä. The media type was something like application/my.company.userdata+xml
@jamesdbloom I will take a look at the version tomorrow
James D Bloom
@jamesdbloom
@Chr3is If you still having any issue please respond on Slack and also provide the MockServer log output so I can see what is happening.
Christoph
@Chr3is
Will do this tomorrow at work. We compared the response in an hex editor and the Ö wasnt utf8 encoded which leaded to the CharConversionException
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?