Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Description
Re-introduce Know Your Class and Section (KYCAS) data into the PESUAuth API by restoring the old
get_know_your_class_and_section()helper, adapted to use the new authenticated PESU Academy endpointPOST /Academy/a/getStudentClassInfo.The previous public endpoint (
/Academy/getStudentClassInfo) was deprecated by PESU Academy and now returns 404. The new endpoint requires an authenticated session (JSESSIONID + CSRF token) that the login step already provides. This PR uses that authenticated session transparently — no additional API parameter or round-trip is needed from the user's perspective.know_your_class_and_sectionboolean parameter back to theauthenticate()method (defaultfalse)know_your_class_and_sectionkey in the responsePOST /Academy/a/getStudentClassInforequirescontrollerMode=370,actionType=174, andloginId=<SRN>, all of which are handled internallyfieldsparam) applies to bothprofileandknow_your_class_and_sectionindependently, matching the original behaviorKYCASFetchError(HTTP 502) with the same error-handling pattern as other upstream failures🧱 Type of Change
🧪 How Has This Been Tested?
tests/unit/)tests/functional/)tests/integration/)✅ Checklist
scripts/run_tests.py)pre-commit run --all-files).envvars updated (if applicable)scripts/benchmark/benchmark_requests.py)🛠️ Affected API Behaviour
app/app.py– Modified/authenticateroute logicapp/pesu.py– Updated scraping or authentication handling🧩 Models
app/models/request.py– Input validation or request schema changesapp/models/response.py– Authentication response formattingapp/models/profile.py– Profile extraction logicapp/models/kycas.py– New KYCAS response model🐳 DevOps & Config
Dockerfile– Changes to base image or build process.github/workflows/*.yaml– CI/CD pipeline or deployment updatespyproject.toml/requirements.txt– Dependency version changes.pre-commit-config.yaml– Linting or formatting hook changes📊 Benchmarks & Analysis
scripts/benchmark_auth.py– Performance or latency measurement changesscripts/analyze_benchmark.py– Benchmark result analysis changesscripts/run_tests.py– Custom test runner logic or behavior updates📸 Screenshots / API Demos
🧠 Additional Notes
Implementation details
get_know_your_class_and_section()usedBeautifulSoup; the new version usesselectolax.HTMLParserfor consistency with the rest of the codebaseKYCASModelusesvalidation_alias="class"/serialization_alias="class"becauseclassis a Python reserved keyword, accessed internally asclass_fieldmodel_dump(by_alias=True)was added inapp.pyto ensureclass_fieldserializes as"class"in JSON output (no-op forProfileModelsince it has no aliases)Files changed
app/exceptions/authentication.pyKYCASFetchError(HTTP 502)app/models/kycas.pyapp/models/__init__.pyKYCASModelapp/models/request.pyknow_your_class_and_section: boolfieldapp/models/response.pyknow_your_class_and_section: KYCASModelfieldapp/pesu.pyKYCAS_HEADER_TO_KEY_MAP,get_know_your_class_and_section()method,know_your_class_and_sectionparam onauthenticate(), updatedDEFAULT_FIELDSapp/app.pyby_alias=Trueinmodel_dumpapp/docs/authenticate.py