freenet-public / got-swag

:monkey_face: A tool to test Swagger-powered APIs automatically through monkey testing and custom test suites
Other
45 stars 9 forks source link

Add POST monkey testing #6

Open morris opened 7 years ago

morris commented 7 years ago

Notes:

morris commented 7 years ago

v2 will focus on more intelligent monkey testing. Payload/body generation in POST and PUT is quite involved:

  1. Payloads may be generated by traversing a schema and randomly using memorized properties.
  2. Properties may be generated by inspecting its type and name and randomly generating value (e.g. dates, person names, etc.).
  3. Payloads can be derived from known request-response pairs and examples.
  4. Array lengths are hard to determine.
  5. Tree structure depth must be limited and is also hard to determine.
  6. Payload data is often coupled, so (1) and (2) probably have low chances of generating business-valid payloads.

First attempt may look something like this:

  1. Randomly select a memorized object similar to the parameter schema*. Prefer examples.
  2. If none is found, start with an empty object.
  3. Generate missing properties by using memorized properties, randomly.
  4. Generate missing properties by using random properties generated from name/type.
  5. For missing inner objects and arrays, descend.
  6. Use random array lengths of 0-5.
  7. Limit tree depth to 5.

(*) Here we'll need some sort of JSON structural diff. It should compare all keys and sub-keys, but ignore values and order.