Skip to content

Conversation

@zulquer
Copy link
Collaborator

@zulquer zulquer commented Jul 17, 2025

This pull request introduces a utility method for URL-encoding path segments to ensure safe inclusion in URLs and updates various API endpoint calls to use this method. It also adds comprehensive unit tests for the new method. The most important changes are grouped below by theme.

Core Functionality

  • Added encode_path_segment as a static method in AbstractManager to URL-encode path segments, ensuring safe inclusion in API endpoint URLs. This method uses urllib.parse.quote with safe="" to encode all unsafe characters. (src/multisafepay/api/base/abstract_manager.py)

API Endpoint Updates

  • Updated multiple API methods across different managers (capture_manager.py, gateway_manager.py, issuer_manager.py, order_manager.py, payment_method_manager.py, recurring_manager.py) to use the new encode_path_segment method for encoding path parameters such as order_id, gateway_code, and reference. This ensures consistent and safe URL construction. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Unit Testing

  • Added a comprehensive suite of unit tests for encode_path_segment in a new test file, test_abstract_manager.py. The tests cover various input scenarios, including strings with special characters, spaces, Unicode, empty strings, numbers, and reserved characters, ensuring robust validation of the method's behavior. (tests/multisafepay/unit/api/base/test_abstract_manager.py)

These changes enhance the safety and reliability of URL construction in the API, preventing potential issues with improperly encoded path parameters.

@codecov
Copy link

codecov bot commented Jul 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.40%. Comparing base (0a9b2fc) to head (7644134).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #23      +/-   ##
==========================================
- Coverage   90.76%   90.40%   -0.37%     
==========================================
  Files         106      106              
  Lines        2306     2323      +17     
==========================================
+ Hits         2093     2100       +7     
- Misses        213      223      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zulquer zulquer requested a review from danielcivit July 17, 2025 10:35
@danielcivit danielcivit merged commit 446bd2c into master Jul 17, 2025
6 checks passed
@danielcivit danielcivit deleted the PTHMINT-74 branch July 17, 2025 11:23
@danielcivit danielcivit restored the PTHMINT-74 branch July 17, 2025 13:01
@danielcivit danielcivit deleted the PTHMINT-74 branch July 17, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants