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.11k stars 75 forks source link

Empty JSON body by ExamplesFields Fuzzer #63

Closed a-waider closed 1 year ago

a-waider commented 1 year ago

The ExamplesFields fuzzer should produce tests for every endpoint with all defined examples. My endpoints require a not empty JSON body otherwise they will respond with HTTP 400. CATS generates for every request an additional example with an empty JSON body:

{}

The examples in the openAPI document do not include an empty JSON body. Is this behaviour expected?

en-milie commented 1 year ago

Hi @a-waider. Can you plead post an OpenApi spec file as an example?

a-waider commented 1 year ago

This is a stripped down openAPI document:

openapi: 3.0.1
info:
  title: Some title
  version: 1.0.0
servers:
  - url: http://localhost:8080
    description: Local development
    variables: {}
paths:
  /some/path:
    post:
      summary: some summary
      operationId: someID
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/someRequestSchema"
            examples:
              default:
                description: some description
                value:
                  key:
                    - key1: 1
                      key2: 2
                      key3:
                        - key: 3
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/someResponseSchema"

CATS ExamplesFields fuzzer generates 2 Tests for it:

From the description I would expect that only tests for the specified examples would be generated. Therefore CATS should only create 1 test for the default example.

en-milie commented 1 year ago

Can you please check with https://github.com/Endava/cats/releases/tag/cats-8.5.0

a-waider commented 1 year ago

Yes, it seems to be working now as I would expect it. Thanks for your very quick response :)