Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Schemathesis only ran a single POST test and marked as success, when a failure would be expected #2057

Open
2 tasks done
pb-own opened this issue Feb 16, 2024 · 2 comments
Assignees
Labels
Status: Needs more info Proceeding requires additional info from the author Type: Bug Errors or unexpected behavior

Comments

@pb-own
Copy link

pb-own commented Feb 16, 2024

Checklist

  • I checked the FAQ section of the documentation
  • I looked for similar issues in the issue tracker
  • [x ] I am using the latest version of Schemathesis

Describe the bug

During positive testing against a simple POST that does not send a request body we receive back a 415 (unsupported media type). This test is marked as success and no further testing on the operation are carried out. The --checks switch was not used in the test run.

The mock was expecting a request body, responding with a 415.

The question is why only a single test which passed?
I assume that as no request body was in the specification, the test data was limited to a single test.
But why the pass?

To Reproduce

🚨 Mandatory 🚨: Steps to reproduce the behavior:

st run sampleapi.yaml --base-url http://localhost:8080/crawl --cassette-path sampleapi-results.yaml

  1. Run this command '...'
  2. See error

Please include a minimal API schema causing this issue:

openapi: 3.0.1
info:
  title: Website crawl for AIS POC
  contact:
    name: xxx
    url: xxx
    email: xxx
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  version: 0.0.1
tags:
- name: crawl
  description: Crawl endpoints
paths:
  /crawl:
    post:
      tags:
      - crawl
      summary: Creates a new crawl if one doesn't already exist. Returns information
        about the website crawl for the request
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                crawlResponse:
                  type: string
                  nullable: true

Environment

- OS: macOS
- Python version: 3.11.5
- Schemathesis version: 3.24.3
- Spec version: 3.0.1

Additional context

Attached cassette output
st-output.yaml.zip

@pb-own pb-own added Status: Needs Triage Requires initial assessment to categorize and prioritize Type: Bug Errors or unexpected behavior labels Feb 16, 2024
@Stranger6667
Copy link
Member

Hi @pb-own

I assume that as no request body was in the specification, the test data was limited to a single test.

You are right!

But why the pass?

I assume you'd expect Schemathesis tests to fail because 415 is not documented?

As you mentioned, the --checks option was not used hence only the not_a_server_error check was used which checks for 5xx status codes. The API returned 415, so the check passed.

Or its more a behavior mismatch that Schemathesis does not detect? I.e. the test is considered positive, but the API indicated a client error and it is not reported?

For the latter case I have this check implemented for my own usage, but I see it hard to detect such mismatches for an arbitrary case hence it is not included in the built-in checks. For example, Schemathesis may send some ID in the payload, but the API responds 404 (or 422, or 400, or something else), which is a reasonable response for an unknown ID, but its a positive test case from the spec perspective, even though the API indicates a client error.

@Stranger6667 Stranger6667 added Status: Needs more info Proceeding requires additional info from the author and removed Status: Needs Triage Requires initial assessment to categorize and prioritize labels Apr 8, 2024
@Stranger6667
Copy link
Member

Checking if the issue is still relevant. Let me know if the comment above is helpful, otherwise I'd be happy to elaborate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs more info Proceeding requires additional info from the author Type: Bug Errors or unexpected behavior
Projects
None yet
Development

No branches or pull requests

2 participants