opentable / wiremock-body-transformer

Wiremock Body Transformer Extension
Apache License 2.0
65 stars 42 forks source link

Question regarding running extension within docker #46

Open thasherwin opened 4 years ago

thasherwin commented 4 years ago

Can you please help? The bellow example works fine when using version 1.1.3 but it does not work when using version 1.1.6.. Can you please let me know what i am missing?

Thanks!

FROM rodolpheche/wiremock

COPY stubs /home/wiremock

ADD https://repo1.maven.org/maven2/com/opentable/wiremock-body-transformer/1.1.3/wiremock-body-transformer-1.1.3.jar /var/wiremock/extensions/

CMD ["--extensions", "com.opentable.extension.BodyTransformer"]

When trying to execute /random request example using 1.1.6 it gives me. If i execute this using version 1.1.3 everything works fine

`HTTP ERROR 500 Problem accessing /random. Reason:

Server Error

Caused by: java.lang.IllegalArgumentException: urlRegex' not present at wiremock.com.google.common.base.Preconditions.checkArgument(Preconditions.java:141) at com.github.tomakehurst.wiremock.common.Metadata.checkKeyPresent(Metadata.java:88) at com.github.tomakehurst.wiremock.common.Metadata.checkPresenceValidityAndCast(Metadata.java:73) at com.github.tomakehurst.wiremock.common.Metadata.getString(Metadata.java:53) at com.opentable.extension.BodyTransformer.transform(BodyTransformer.java:112) at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.applyTransformations(InMemoryStubMappings.java:100) at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:79) at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:179) at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:50) at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:47) at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:120) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:873) at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542) at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345) at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480) at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247) at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) at wiremock.org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:753) at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126) at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at wiremock.org.eclipse.jetty.server.Server.handle(Server.java:502) at wiremock.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370) at wiremock.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267) at wiremock.org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) at wiremock.org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) at wiremock.org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117) at wiremock.org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) at wiremock.org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) at wiremock.org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) at wiremock.org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:132) at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) at java.lang.Thread.run(Thread.java:748) `

thasherwin commented 4 years ago

Found a solution/workaround. For some reasons i have to mention urlRegex transfer also for it to work.. It seems mandatory.. Not sure why?? but the the below example stub works fine on version 1.1.6

{

  "request": {
    "method": "GET",
    "urlPath": "/transformxx"
  },
  "response": {
    "status": 200,
    "body": "{\"randomInteger\": \"$(!RandomInteger)\"}",
    "headers": {
      "Content-Type": "application/json"
    },
      "transformers": [
          "body-transformer"
        ],
        "transformerParameters": {
          "urlRegex": "transformxx"
        }
  }
}
ns-cma commented 3 years ago

Meet the exact same issue, thanks for the help thasherwin !!!