Fuzz the API against its OpenAPI schema with Schemathesis
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 58/100
Direzione di ricerca
Start with pyproject.toml, tests/unit/test_openapi_docs.py, the integration tests, and the app entry point to understand dependency setup, TestClient lifespan patching, and schema loading. Add tests/unit/test_api_fuzz.py with deterministic, capped checks and update CONTRIBUTING.md; done means the offline suite passes without 500s or undocumented responses, coverage remains 100%, and findings are fixed or tracked.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🔄 Updated for v5.0.0 (2026-10-08). Still open. Since 5.0.0 (#241) the lifespan makes no upstream calls, so only
pesu_academy.authenticateneeds patching. Profile fields can now benull, and the profile has 17 fields, which the generated requests and the schema checks must allow for. #228 implements this issue; rebase it ontodev.
Summary
pesu-auth publishes a detailed OpenAPI schema, and tests/unit/test_openapi_docs.py checks the documented examples. But nothing checks that the API behaves as the schema promises for arbitrary input. Schemathesis generates thousands of requests from an OpenAPI schema (valid, edge-case and malformed) and checks every response. Add it to the offline test suite, so that any input that produces a 500, an undocumented status code, or a body that doesn't match the schema fails a test.
Background
- The schema is
app.openapi(), with FastAPI's fake 422s removed (_openapi_without_phantom_validation_errors). - The error contract (
docs/api-contract.md): every error is{status, message, timestamp}; validation failures are 400, never 422; 422 means PESU Academy's profile response couldn't be parsed. Every error carries a fixed publicmessage; the log-onlydetailnever reaches the response. - Tests must not call PESU Academy. Since 5.0.0 the lifespan makes no upstream calls, so patching
pesu_academy.authenticateis enough;tests/unit/test_openapi_docs.pyandtests/unit/test_app_unit.pyshow how.
Proposed change
- Add
schemathesisto thedevgroup (follow theupdate-dependenciesskill). tests/unit/test_api_fuzz.py:- load the schema from the ASGI app (
app), following Schemathesis's current documentation for ASGI/FastAPI apps and pytest (the API changed in v4, so use the version you install); - patch the PESU side:
pesu_academy.authenticatereturning a fixed success for one known username (with a profile when one is asked for, every field present and somenull, as the real API returns them) and raisingAuthenticationErrorotherwise.prefetch_client_with_csrf_tokenandclose_clientno longer exist; - enable these checks:
not_a_server_error,status_code_conformance,content_type_conformanceandresponse_schema_conformance.
- load the schema from the ASGI app (
- Keep it fast: cap the examples (for example 200 per operation) and set a fixed seed, so CI is deterministic. Document how to run a deeper local fuzz with more examples.
- Fix what it finds, or open a separate issue for anything that's bigger than a small fix, and link it here. Expected areas: very long strings (see #192), unusual Unicode, wrong content types,
/metricswith oddfmtvalues orAuthorizationheaders. - Mention the fuzz test in
CONTRIBUTING.md's testing section.
Acceptance criteria
- Schemathesis runs in the normal (offline) test suite, fast and deterministic
- No generated input produces a 500 or an undocumented response
- Anything it found is fixed or tracked in linked issues
- Coverage stays at 100%
How to contribute
- Wait until you're assigned. Comment to ask for this issue, then wait for a maintainer to assign it to you before writing any code. PRs for unassigned issues are closed without review.
- Read
CONTRIBUTING.mdfirst. It covers forking, setting up withuv, and running the tests. - Branch from
devin your fork, and open the PR againstdevwith a Conventional Commit title andCloses #218in the description. - Bump the minor version in
pyproject.tomland runuv lock(CI checks this).uv run pre-commit run --all-filesmust pass, and coverage must stay at 100%. - Update the README,
app/docs/and comments in the same PR as the behaviour they describe. - Never log, print, store or echo a password or token, including in tests, PR descriptions and screenshots.
- Lingua principale
- Python
- Stelle
- 22
- Fork
- 29
- Merge medio
- 22h 1m
- PR unite (30g)
- 20
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pesu-dev/auth
-
Check the README for dead links and fix the misleading Docker Hub badgeForse di nuovo libera @knownshah l’ha presa 16 giorni fa e non c’è nessuna pull request aperta. Apertadocumentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
pesu-dev/auth#220 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Run the same checks locally and in CI: pre-commit hooks in CI, and hooks that match CIForse già presa @achyu-dev l’ha presa 1 giorno fa. Apertabug tests and ci/cd
pesu-dev/auth#250 · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
bug documentation enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 54/100
I maintainer di solito rispondono entro 1 giorno
-
Commit SHA should be used instead of tag git based deployForse già presa @aditeyabaral l’ha presa 10 giorni fa. Apertabug
pesu-dev/auth#236 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Private Functions in `app.py` needs to be in separate fileForse già presa @aditeyabaral l’ha presa 10 giorni fa. Apertaapi enhancement
pesu-dev/auth#235 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pesu-dev/auth
Issue simili
-
customer-reported question
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Azure/azure-sdk-for-python#49548 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
btclib-org/btclib-wallet#409 ·
I maintainer di solito rispondono entro 1 giorno
-
Phase 2 PSA Capability & Career Profile
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
fastmachinelearning/hls4ml#1582 ·
I maintainer di solito rispondono entro 3 giorni
-
Sort modelsApertaenhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno