https://linen.dev logo
Join the conversationJoin Slack
Channels
announcements
cdk-avengers
general
introduce-yourself
random
setup
wiremock-cloud
wiremock-open-source
wiremock-studio
Powered by Linen
wiremock-open-source
  • m

    Manan Girdhar

    01/30/2023, 9:26 AM
    I just wanted to know can we run wiremock on local machine instead of running it on a server. currently we are running wiremocks to automate different security tools on jenkins server. but we are not able to run the same setup on our local machine.
    r
    • 2
    • 11
  • s

    Sundar

    01/30/2023, 11:57 AM
    Hi Team, i have started the wiremock using "i start the wiremock using the command "java -cp wiremock-jre8-standalone-2.35.0.jar;wiremock-webhooks-extension-2.35.0.jar com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --extensions org.wiremock.webhooks.Webhooks --https-port 8001 --https-keystore ./wiremock.jks"
  • s

    Sundar

    01/30/2023, 11:57 AM
    i have added the cem file to the wiremock.jks as well
  • s

    Sundar

    01/30/2023, 11:57 AM
    when i try to call https post method. getting error as "Error: write EPROTO 64261128:error:10000410:SSL routines😮PENSSL_internal:SSLV3_ALERT_HANDSHAKE_FAILURE:../../../../src/third_party/boringssl/src/ssl/tls_record.cc:594:SSL alert number 40"
    t
    • 2
    • 21
  • s

    Sundar

    01/31/2023, 5:33 AM
    Hi Team, how can i pass a parameter value from the request body and put that value in the webhook body
  • s

    Sundar

    01/31/2023, 5:37 AM
    wireMockServer.stubFor(post("/one")
                    .willReturn(ok())
                    .withPostServeAction("webhook", webhook()
                            .withMethod(POST)
                            .withUrl("<http://my-target-host/callback>")
                            .withHeader("Content-Type", "application/xml")
                            .withTransformers("xml/response/responsetest.xml")
                            .withBodyFile("xml/response/responsetest.xml"))
    );
    getting error on method ".withTransformers"
    • 1
    • 1
  • s

    Sundar

    01/31/2023, 8:22 AM
    Do we have any option to get the wehbook response to a string variable in java project
    t
    • 2
    • 1
  • s

    Sundar

    01/31/2023, 2:35 PM
    Any suggestion or document to test wiremock webhook using rest assured or any other framework ?
  • s

    Shruti Sagar Mishra

    02/15/2023, 5:25 PM
    Hey Everyone, I am trying to setup wiremock with my emulator to capture and modify(similar to what mitmproxy does) http and https request for android native app. 1. I have installed the certificate in emulator. 2. I want to only intercept 2-3 any call (there are 100s of different call to different host). So basically want to whitelist every other call except the ones I wan to put stub for.
    HashMap<ExecutionDataKeys, Object> executionStates = new HashMap<>();
    WireMockServer wireMockServer = new WireMockServer(
            new WireMockConfiguration().port(8080)
                    .notifier(new Slf4jNotifier(true))
    );
    wireMockServer.start();
    ArrayList<String> hostNames = new ArrayList<>(
            Arrays.asList(
                    "<https://host1.com>",
                    "<https://host2.com>",
            ));
    
    hostNames.forEach(host->{
        wireMockServer.stubFor(any(urlMatching(host+".*"))
                .atPriority(10)
                .willReturn(aResponse().proxiedFrom(host)));
    });
    I have also set proxy in emulator to localhost:8080. But it seems whitlisting is not working. all of my request are getting blocked. P.S. I am trying to use appium along with wiremock to test state changes in application [10:53 PM] I have already waster 3-4 days on this, and feeling kind exausted in this. [10:53 PM] Please advice
    r
    • 2
    • 48
  • o

    Omkar Goulay

    02/17/2023, 6:26 AM
    Hi, Is there a documentation on stubbing
    application/x-www-form-urlencoded
    request?
    r
    • 2
    • 2
  • s

    Sundar

    02/17/2023, 6:38 AM
    how can i add wiremock opensource project as a service in services.msc
    r
    • 2
    • 1
  • a

    Albert Edlin Tan

    02/23/2023, 7:56 AM
    Hi
  • a

    Albert Edlin Tan

    02/23/2023, 7:56 AM
    have anyone encountered an issue in which the response template mapping is not happening for a standalone version?
  • a

    Albert Edlin Tan

    02/23/2023, 7:59 AM
    I have 2 wiremock servers using wiremock v2.31.0, I copied my Dockerfile on both server and run the docker build to create the image on that server. 1 server works, while the other doesn't.
    t
    • 2
    • 2
  • a

    Albert Edlin Tan

    02/23/2023, 7:59 AM
    server version: NAME="Amazon Linux" VERSION="2" ID="amzn" ID_LIKE="centos rhel fedora" VERSION_ID="2" PRETTY_NAME="Amazon Linux 2" ANSI_COLOR="0;33"
  • a

    Albert Edlin Tan

    02/23/2023, 7:59 AM
    let me know if you need more info
  • a

    Anitt Rajendran

    02/27/2023, 9:41 PM
    Hi Everyone , just a quick question - Is it possible to import OpenAPI spec to wiremock opensource other than using wiremock cloud ? is there any way we can have this feature added as part of wiremock opensource ?
    t
    • 2
    • 6
  • a

    Alessandro Bramati

    03/02/2023, 9:52 AM
    Hi everyone, I'm trying to call via Wiremock an external endpoint protected by mutual authentication; here the config:
    wireMockConfiguration = options()
                            .disableRequestJournal()
                            .usingFilesUnderDirectory(rootFolder)
                            .port(Integer.parseInt(getProperty("port")))
                            .adminAuthenticator(getAdminAuthenticator())
                            .jettyAcceptors(Integer.parseInt(getPropertyOrDefault("acceptor.threads", DEFAULT_ACCEPTOR_THREADS)))
                            .keystorePath(getProperty("keystore.path"))
                            .keystorePassword(getProperty("keystore.password"))
                            .trustStorePath(getProperty("truststore.path"))
                            .trustStorePassword(getProperty("truststore.password"))
                            .extensions(
                                    new AdminRequestLoggingFilter(),
                                    new ServiceRequestLoggingFilter(),
                                    new ServiceResponseLoggingFilter(),
                                    new ResponseTemplateTransformer(true));
    Here the error:
    SL failure trying to make a proxied request from WireMock to ...
    PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    My keystore contains my private cert and the truststore contains the server certificate (everything ok with curl). Is there something missing? Thanks Alessandro
    r
    • 2
    • 21
  • a

    Aaron

    03/02/2023, 4:23 PM
    Do the
    basicAuth
    keys support regex matching? https://stackoverflow.com/questions/75614289/wiremock-json-template-basicauth-and-doesnotmatch-not-working I ran this locally and was getting the same error, even with switching to
    basicAuthCredentials
    .
    t
    • 2
    • 3
  • m

    Mukesh Bijalwan

    03/03/2023, 1:09 PM
    Hello, I was trying to run Wiremock studio from my local machine. When i launch it from window it throws below error. Could somebody help me if i am missing anything.:
    t
    • 2
    • 3
  • s

    Sundar

    03/08/2023, 12:10 PM
    how can i pass a xml file in the response using .withPostServeAction
    • 1
    • 1
  • y

    Yash Agarwal

    03/14/2023, 9:56 AM
    i am setting up a new project. Using
    "org.springframework.cloud:spring-cloud-starter-contract-stub-runner"
    But I am getting the following error and not sure why. Any help ?
    Request was not matched
                                                   =======================
    
    -----------------------------------------------------------------------------------------------------------------------
    | Closest stub                                             | Request                                                  |
    -----------------------------------------------------------------------------------------------------------------------
                                                               |
    GET                                                        | GET
    /ldap_directory_items/v2/group_members?key=key&name=APP-O  | /ldap_directory_items/v2/group_members?key=key&name=APP-O
    AUTH2-ABCD&size=100000                                     | AUTH2-ABCD&size=100000
                                                               |
                                                               |
    -----------------------------------------------------------------------------------------------------------------------
    t
    • 2
    • 7
  • a

    Alex P

    03/20/2023, 7:43 PM
    Hi! I am trying to use the form data of a request in the response. The request body looks like this
    flag1[enabled]=true&transfer[destination]=target_account&metadata[userId]=1-2-3-4&metadata[sessionId]=a-b-c
    I am having a hard time to use the values in the response. I am parsing the form via
    {{formData request.body 'params' urlDecode=true}}
    and I can see the values fine when doing
    {{#each params}}
    {{@index}} - {{@key}} - {{this}}
    {{/each}}
    But I cannot access the individual fields, no matter what I try, e.g.,
    {{"metadata[userId]"}}
    {{metadata\[userId\]}}
    {{metadata.userId}}
    My Google-fu also failed me 😕
    t
    • 2
    • 3
  • a

    Alex P

    03/21/2023, 8:39 AM
    On another note: I am using some
    assign
    and a
    formData
    expressions at the top of my response (referenced via
    bodyFileName
    ) and it seems that they get replaced by an empty line, i.e., I have a few empty lines before my JSON response body starts. For now I just cram everything in one line and start the JSON object there, too, but it is really unreadable 😕
    {{#assign 'a'}}...{{/assign}}{{#assign 'b'}}...{{/assign}}{{formData ...}}{
      "id": ...
    ...
    }
    Is there a better way to suppress the empty lines in this case?
    t
    • 2
    • 2
  • a

    Alex P

    03/23/2023, 2:17 PM
    I am trying to mock two different requests to the same endpoint. One mock is set up like this
    "request": {
            "method": "POST",
            "urlPattern": "/store|/v2/store",
            "queryParameters": {
              "client": {
                "matches": "STORE-ABC-.+"
              },
    ...
              }
            }
    and the second looks like this
    "request": {
            "method": "POST",
            "urlPattern": "/store|/v2/store",
            "queryParameters": {
              "client": {
                "matches": "STORE-123-.+"
              },
    ...
            }
          },
    Both have additional but the same query parameters to match. Both also have different body patterns to match. When I send this request (from WireMock's log)
    POST /v2/store?client=STORE-123-12345&user=userId&realm=realm&key=sessionId
    I see that WireMock only tries the other request (STORE-ABC) but fails because it cannot match some parts of the body patterns of STORE-ABC, even though STORE-123 would match. So I wonder if WireMock even tries the STORE-123 mock because I cannot see it in the log. More curiosly, at the very end I get a "closest stub" that is a completely different stub where of course neither URL nor body match; how come it shows this, and not for example the stubs it tried?
    • 1
    • 3
  • a

    Alex P

    03/23/2023, 2:19 PM
    Can I disable a mapping without removing the file from the
    mappings
    folder, e.g., by adding a
    disabled: true
    field or so? 🤔
    t
    • 2
    • 2
  • a

    Alex P

    03/23/2023, 3:41 PM
    I wonder if I can set some values in the stub to use as template values in the response. For example, let's say I have a generic response for a
    DELETE
    endpoint, and I have a response
    bodyFileName
    that has something like
    {
      "message": "Deleted {{arguments.count}} items"
    }
    And then I would have a stub like this
    {
      "request": ...,
      "response": {
        "bodyFileName": ...,
        "arguments": {
          "count": 1
        }
    ...
    }
    Or can I use the
    metadata
    for that? 🤔
    t
    a
    • 3
    • 8
  • a

    Alex P

    03/23/2023, 4:34 PM
    Can I somehow keep track of things within a scenario between requests? For example, let's say I get a POST with an ID that was generated by my test subject, and I need that ID in a later GET in that scenario 🤔
  • a

    Alex P

    03/23/2023, 5:11 PM
    When querying the request journal, can I find out which stub matched? Right now I do not see
    id
    or
    name
    in the response of
    __admin/requests/find
    🤔 (Sorry for the bombardement of questions 😄 )
    • 1
    • 1
  • d

    Devaraj Rathinasamy

    03/24/2023, 9:36 PM
    Hi, Is there a way to exclude/ignore some specific headers from being proxied with wiremock proxying/recording? Please let me know if there are any options available. For instance, I would like to exclude the header X-forwarded-for before wiremock proxying the request to the destination.
    t
    • 2
    • 2
Powered by Linen
Title
d

Devaraj Rathinasamy

03/24/2023, 9:36 PM
Hi, Is there a way to exclude/ignore some specific headers from being proxied with wiremock proxying/recording? Please let me know if there are any options available. For instance, I would like to exclude the header X-forwarded-for before wiremock proxying the request to the destination.
t

Tom

03/27/2023, 10:36 AM
Hi @Devaraj Rathinasamy the only way to do this at the moment is to write a
StubRequestFilter
extension class that removes the header prior to subsequent processing.
✅ 1
d

Devaraj Rathinasamy

03/27/2023, 2:56 PM
Thank you! Let me try it with the filter.
View count: 3