[x] I checked the FAQ section of the documentation
[x] I looked for similar issues in the issue tracker
[x] I am using the latest version of Schemathesis
Describe the bug
Validating responses fails when an endpoint specifies a security parameter and a custom test client is passed as the session argument to case.call_and_validate(), such as in this example from the documentation.
To Reproduce
🚨 Mandatory 🚨: Steps to reproduce the behavior:
Running this test example with pytest should reproduce the issue:
FAILED tests/test_schema.py::test_api[GET /] - requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=80): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7c2e41ffa6...
Checklist
Describe the bug
Validating responses fails when an endpoint specifies a
security
parameter and a custom test client is passed as thesession
argument tocase.call_and_validate()
, such as in this example from the documentation.To Reproduce
🚨 Mandatory 🚨: Steps to reproduce the behavior:
Running this test example with
pytest
should reproduce the issue:This gives me the following error:
This is the OpenAPI schema:
Expected behavior
The test given above should pass
Environment
Additional context
I believe the issue is in this check: https://github.com/schemathesis/schemathesis/blob/master/src/schemathesis/specs/openapi/checks.py#L351 The check is creating a
requests.Session
which will lead to an actual HTTP call. It should be using the specified session instead.