Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Check the test payloads against PESU Academy's live response shape

Aperta
#217 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Read CONTRIBUTING.md and docs/upstream.md first, then inspect the parser methods and tests/unit/test_pesu.py. Run the existing test suite before working, using the credential and single-session rules in the issue. Done means the capture script, redacted fixtures, offline parser tests, guard test, refresh README, and requested documentation updates satisfy all acceptance criteria without exposing credentials.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

pesuacademy student profile tests and ci/cd

🔄 Updated for v5.0.0 (2026-10-08). Rewritten for 5.0.0. pesu-auth no longer parses HTML: it reads JSON from PESU Academy's mobile API through pydantic models (#241). The offline tests already run the real parser, the models in app/models/upstream.py, over payloads shaped like the live responses (LOGIN_PAYLOAD and PROFILE_PAYLOAD in tests/unit/conftest.py), so the original goal is mostly met. What's missing is a check that those hand-written payloads still match what PESU actually sends. The original HTML-fixture proposal is in the edit history.

⚠️ PES University students only. This change needs a live test against PESU Academy with real PESU credentials (see "Tests that need credentials" in CONTRIBUTING.md). Run the whole suite with your credentials in .env and paste the summary line into your PR. Every run makes real logins to PESU Academy, so run it when you need it, not in a loop.

Summary

pesu-auth's biggest risk is PESU Academy changing its mobile API. The unit tests parse LOGIN_PAYLOAD and PROFILE_PAYLOAD, which were written by hand from the live API's key names and types, with invented values. Nothing checks that they stay like the live API. If PESU renames a key or changes a type, the unit tests keep passing against the old shape. Only the live tests notice, and only for the values they compare. Add a live shape check: compare the structure (keys and value types, never values) of PESU's real responses with the test payloads, so the payloads can't silently drift.

Background

  • app/models/upstream.py declares exactly the fields pesu-auth reads: LoginResponse (mobileJsonObject.login, accessToken) and ProfileResponse (MESSAGE, the STUDENT_INFO fields, and instituteName and gender from STUDENT_PHOTO). Everything else is ignored as the response is parsed.
  • tests/unit/conftest.py: LOGIN_PAYLOAD and PROFILE_PAYLOAD are "shaped like the real responses (key names and types taken from the live API, values invented)". They also contain personal fields the service must never keep (photo, parents, address), so tests can prove those are dropped.
  • In production, a field PESU stops sending is counted as profile_parse_errors_total{reason="missing_field"} and a changed type as unexpected_value, and both are returned as null. That catches drift after it reaches users; this issue catches it in the test suite.
  • Never commit a real response, even redacted: the profile response holds the student's photo, address, marks and parents' details. A shape check needs no saved data at all.

Proposed change

  1. A shape helper (in tests/conftest.py or a small tests/shape.py): reduce a JSON value to its structure. Keep keys and the JSON type of each value (str, int, null, object, list), and drop the values themselves.
  2. A live test (tests/functional/test_upstream_shape.py, marked secret_required): log in with the .env account using the same constants as app/pesu.py (LOGIN_URL, LOGIN_FORM, MOBILE_HEADERS, then DISPATCHER_URL and PROFILE_FORM with the access token). For every field the models read, assert that the live response has it in the same place with the same type as in LOGIN_PAYLOAD / PROFILE_PAYLOAD. A field the account has no value for (null or "", such as a graduated student's ClassName) matches any type; say so in a comment.
    • The test must never print, log or put into an assertion message any value: only key paths and type names. Check this with a deliberately failing run.
    • Close the client on every path, as app/pesu.py does.
  3. Report extra keys, but don't fail on them. PESU sends many fields pesu-auth doesn't read. Listing the key paths that appear in the live response but not in the payloads (names only) helps whoever updates the payloads next.
  4. Document it in CONTRIBUTING.md's testing section: what to do when the shape test fails (update the payloads in tests/unit/conftest.py and, if a field pesu-auth reads changed, the models), and that the payloads must never hold real values.

Review note for maintainers

Check the test's output on a failing run: it must contain key paths and type names only.

Acceptance criteria

  • A live test fails if any field the models read is missing from PESU's response or has a different type than in the test payloads
  • No response value appears in test output, logs or assertion messages, and no response is saved to disk
  • Extra keys are reported by name without failing
  • CONTRIBUTING.md explains how to act on a failure

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.md first. It covers forking, setting up with uv, and running the tests.
  • Branch from dev in your fork, and open the PR against dev with a Conventional Commit title and Closes #217 in the description.
  • Bump the minor version in pyproject.toml and run uv lock (CI checks this). uv run pre-commit run --all-files must 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pesu-dev/auth

Tutte le issue di pesu-dev/auth

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.