Endava / cats

CATS is a REST API Fuzzer and negative testing tool for OpenAPI endpoints. CATS automatically generates, runs and reports tests with minimum configuration and no coding effort. Tests are self-healing and do not require maintenance.
Apache License 2.0
1.17k stars 74 forks source link

Very long string is getting generated for "zip" (zip code/pin code) field #105

Closed ganeshnikam18 closed 6 months ago

ganeshnikam18 commented 7 months ago

CATS version: 10.3.0

What is the issue? If any requestBody schema has "zip" field, the cats is generating very long string for this field. For other string field cats generated correct random strings of 5 - 10 char length. petstore-country-code.json

In this file Pet is defined as below: "Pet": { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "tag": { "type": "string" }, "zip": { "type": "string" }, "countryCode": { "type": "string", "pattern": "^[A-Z]{2}$" } } },

When we execute HappyPath fuzzer for this file, CATS generates below fuzzed body:

"payload": "{\"zip\":\"718951363927897923360586256180007154435308929228851126446436180141171429804609172230175966541623515461280772929060207152401.963566832870923380059481281857380419995538769907442566957194029356142283127464923521227008552846241712373738766797097576278838561608772.689087567263479742349714296829196377275980732993337744196137894166195402548357612062278404841149224582026639901937149506405666469933302.6711145576437248243454401062813189308873159340\",\"countryCode\":\"WLF\",\"name\":\"BoheTys\",\"id\":9,\"tag\":\"UVB9A\"}"

To Reproduce Steps to reproduce the behaviour:

  1. For the server side, I am running Spotlight Prism Mock Server:
  2. Run the mock version with this spec file
  3. Then from other machine run the cats tool with HappyPathFuzzer
  4. Check the payload in the generated test cases.

Expected behaviour Small and concise string should be generated for "zip" field

What is the root cause?

What is the fix? I have added below fix for this issue. If you find is appropriate then please add it t.patch

en-milie commented 7 months ago

Good catch. Thanks for the fix.

en-milie commented 6 months ago

Available in: https://github.com/Endava/cats/releases/tag/cats-11.1.0

en-milie commented 6 months ago

Closing this.