Refactor WebAuth session handling and improve error handling#5
Merged
Refactor WebAuth session handling and improve error handling#5
Conversation
…ty and maintainability
…mprove test execution
…ce test execution
…ce test execution
…nd improve header handling
…Encoding and remove unnecessary headers
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.
This pull request introduces major improvements to the Steam web authentication code, focusing on refactoring for clarity, maintainability, and modern Python practices. The main changes include a significant rewrite of the
steam/webauth.pyauthentication logic, enhancements to the HTTP session setup, and the addition of GitHub Actions workflows for automated testing and reporting.Refactor and modernization of Steam web authentication:
Refactored
steam/webauth.pyto use more Pythonic naming conventions (PEP8), improved error handling, and clearer method separation. The authentication flow is now more robust, with methods like_start_login_session,_poll_login_status, and_finalize_loginreplacing older, less clear implementations. Headers and session handling are also improved for better emulation of a real browser. [1] [2] [3] [4] [5] [6] [7] [8]Extracted and improved the HTTP session creation logic in
steam/utils/web.py, allowing custom headers and simplifying session setup for all web requests. [1] [2]Continuous integration improvements:
.github/workflows/test.ymlto run tests across multiple OS and Python versions, and upload JUnit XML results as artifacts..github/workflows/test_report.ymlto publish and display test reports from CI artifacts using the dorny/test-reporter action.Developer experience enhancements:
Makefileto add awebauth_gencommand for generating VCR cassettes for webauth tests, and improved theinittarget to install Poetry via pipx for consistent dependency management. [1] [2]This pull request refactors and modernizes the Steam web authentication logic, focusing on improving maintainability, API consistency, and code style. The changes introduce a more robust session creation mechanism, update authentication flows to use instance-level sessions with custom headers, and revise method and variable names to follow PEP8 conventions. Additionally, the test response scrubber is enhanced for better reliability and data anonymization.Authentication and Session Handling Improvements
WebAuthclass to use an instance-levelrequests.Sessionconfigured via the newmake_requests_sessionutility, allowing for custom headers and better mimicking of browser behavior. [1] [2]send_api_request,_get_rsa_key,_start_session_with_credentials,_poll_login_status,_finalize_login, etc.) to consistently use the instance session and updated their signatures and logic for clarity and error handling. [1] [2] [3] [4] [5] [6] [7]API Consistency and Code Style
steam/webauth.pyto conform to PEP8 naming conventions, improving readability and maintainability. [1] [2]Testing and Data Scrubbing
tests/generete_webauth_vcr.pyto defensively handle byte/string conversion and comprehensively anonymize sensitive fields in test recordings. Also, improved VCR configuration for better test hygiene.Minor Cleanups
gzip) and streamlined code for clarity.User Experience Improvements
These changes collectively make the authentication flow more robust, maintainable, and user-friendly, while also improving the reliability of automated tests.