Coder Social home page Coder Social logo

Comments (4)

mroach avatar mroach commented on May 22, 2024 4

I also got stuck with this issue and was surprised to find it's doing string matching on a JSON body. Request matching already has queryStringParameters to match on a proper object which is great. I imagine the next logical extension would be doing this for request bodies, whether they be JSON or HTML multi-part.

Something like this for a parsable body.

  • The "*" lives-on as a string wildcard.
  • Fields can be marked as optional
  • Constraints on enum-type fields. Though this may be getting out of scope for a first draft of this.
request:
  method: POST
  path: /auth/sessions
  bodyParams:
    username: "*"
    password: "*"
    remember_me:
      one_of: ["true", "false"]
    another_field:
      optional: true

Same thing with JSON config:

{
  "request": {
    "method": "POST",
    "path": "/auth/sessions",
    "bodyParams": {
      "username": "*",
      "password": "*",
      "remember_me": {
        "one_of": [
          "true",
          "false"
        ]
      },
      "another_field": {
        "optional": true
      }
    }
  }
}

from mmock.

dkoontz avatar dkoontz commented on May 22, 2024 3

I am running into this exact same issue. I have a body where I want to match on one parameter, but the others will vary by test case and aren't relevant to the data I'm submitting. Example:

{ "A": "THIS FIELD IS CONSISTENT", "B": "THIS FIELD VARIES AND CAN BE IGNORED" }

I would like to be able to specify the body as

{ "A": "A REQUIRED VALUE", "B": * }

from mmock.

ericchaves avatar ericchaves commented on May 22, 2024 1

I am running into this exact same issue. I have a body where I want to match on one parameter, but the others will vary by test case and aren't relevant to the data I'm submitting. Example:

{ "A": "THIS FIELD IS CONSISTENT", "B": "THIS FIELD VARIES AND CAN BE IGNORED" }

I would like to be able to specify the body as

{ "A": "A REQUIRED VALUE", "B": * }

@dkoontz I had a similar issue until I figured that body payload must match the text exactly, the wildcard just allow anything in that position of the string. check if your submitted payload matches the break lines and spaces in your request config. I had a similar issue because my payload was sent as compacted JSON (one line, no spaces) and the config had break lines.

For example:

request:
 method: GET
  path: /
  body: >
    { "A": "A REQUIRED VALUE", "B": * }

should match a payload

{ "A": "A REQUIRED VALUE", "B": "THIS FIELD VARIES AND CAN BE IGNORED" }

but won't match

{ "A": "A REQUIRED VALUE", 
  "B": "THIS FIELD VARIES AND CAN BE IGNORED" }

from mmock.

dennypenta avatar dennypenta commented on May 22, 2024

apparently it counts spaces as well on wildcard matching and ignores the application/json header to compare the objects.
so currently it supports only full body wildcard and not a partial matching

from mmock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.