Skip to content

PTHMINT-101: Add dev-only custom base URL support#52

Open
zulquer wants to merge 3 commits intomasterfrom
PTHMINT-101
Open

PTHMINT-101: Add dev-only custom base URL support#52
zulquer wants to merge 3 commits intomasterfrom
PTHMINT-101

Conversation

@zulquer
Copy link
Copy Markdown
Collaborator

@zulquer zulquer commented Apr 1, 2026

Allow passing a custom API base_url for local development while preventing custom URLs in non-dev builds. Client now accepts base_url and resolves it via _resolve_base_url (uses MSP_SDK_BUILD_PROFILE, MSP_SDK_ALLOW_CUSTOM_BASE_URL, MSP_SDK_CUSTOM_BASE_URL); _normalize_base_url validates/normalizes the URL. Sdk forwards base_url to Client. Added unit tests covering default test/live URLs, dev-only custom URL acceptance, env-provided URL, and blocking in release/when flag disabled. README updated with usage and guardrails.

Allow passing a custom API base_url for local development while preventing custom URLs in non-dev builds. Client now accepts base_url and resolves it via _resolve_base_url (uses MSP_SDK_BUILD_PROFILE, MSP_SDK_ALLOW_CUSTOM_BASE_URL, MSP_SDK_CUSTOM_BASE_URL); _normalize_base_url validates/normalizes the URL. Sdk forwards base_url to Client. Added unit tests covering default test/live URLs, dev-only custom URL acceptance, env-provided URL, and blocking in release/when flag disabled. README updated with usage and guardrails.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.94%. Comparing base (ee15a54) to head (f4708bd).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #52      +/-   ##
==========================================
+ Coverage   90.81%   90.94%   +0.13%     
==========================================
  Files         147      147              
  Lines        2579     2607      +28     
==========================================
+ Hits         2342     2371      +29     
+ Misses        237      236       -1     

☔ 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a development-only mechanism to override the API base URL (via constructor parameter or env var) while enforcing guardrails to block custom URLs outside a “dev” profile.

Changes:

  • Extend Client and Sdk to accept base_url and resolve it with environment-based guardrails.
  • Add unit tests for default URL selection and dev/release allow/block behavior.
  • Update README with guidance for enabling the dev-only override.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/multisafepay/client/client.py Implements base URL resolution/normalization with dev-only guardrails.
src/multisafepay/sdk.py Forwards base_url from Sdk to Client.
tests/multisafepay/unit/client/test_unit_client.py Adds unit tests for default URLs and guardrail behavior at the Client level.
tests/multisafepay/unit/test_unit_sdk.py Adds unit tests ensuring Sdk propagates URL behavior/guardrails.
README.md Documents dev-only configuration and usage for custom base URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Reject invalid custom base URLs with query strings, fragments, or malformed hosts. Add unit coverage for invalid URL cases and document environment-variable precedence for custom base URLs.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Improve Client._normalize_base_url by rejecting URLs that include path parameters (parsed.params) and standardize the error message to "Invalid base URL.". Update unit tests to expect the new message, add a test ensuring an explicit base_url argument takes precedence over environment settings, and add a test that rejects base URLs containing params.
@zulquer zulquer requested a review from danielcivit April 7, 2026 08:03
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.

2 participants