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

Out of bounds for length 0 #125

Closed ctwinovalon closed 3 months ago

ctwinovalon commented 4 months ago

Ran --server xyz --contract file.json

Ran for a while on various endpoints and died on one of them with:

java.lang.StringIndexOutOfBoundsException: Range [-1, 0) out of bounds for length 0
...
com.endava.cats.generator.simple.StringGenerator.generateExactLength(StringGenerator.java:127)
ctwinovalon commented 4 months ago

Looks like this section: https://github.com/Endava/cats/blob/44fb35199dcdc17d12f23059ae3765687bdf841c/src/main/java/com/endava/cats/generator/simple/StringGenerator.java#L125-L132

The test if (initialValue.length() != length) { should be if (initialValue.length() > 0 && initialValue.length() != length) {

en-milie commented 4 months ago

Hi @ctwinovalon. Can you please attach an OpenApi spec i can use to reproduce the issue?

ctwinovalon commented 4 months ago

api-docs3.json

en-milie commented 4 months ago

Thank you for providing the specs. This is now fixed in: https://github.com/Endava/cats/commit/1f936a9b8a80232a9bcb9a56f5e2c4b777fb38c7

en-milie commented 3 months ago

It should be fixed in: https://github.com/Endava/cats/releases/tag/cats-11.7.0