Skip to content

Prefer Supertab-hosted content blocks when minting - #19

Merged
filias merged 2 commits into
mainfrom
fix/prefer-supertab-hosted-block
Oct 16, 2026
Merged

filias merged 2 commits into
mainfrom
fix/prefer-supertab-hosted-block

Conversation

@filias

@filias filias commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

When several <content> blocks match a resource, obtain_license_token() now picks one whose server is on the supertab_base_url host before a more specific match from another provider. If no Supertab-hosted block matches, it still falls back to the best match overall.

Before this change, Python picked the most specific match regardless of host. A multi-provider license.xml could therefore send the customer's client credentials to a third party's token server even when a Supertab block also matched. TS (selectMintableContent) and PHP (selectTokenEndpoint) already prefer the Supertab host; this brings Python in line.

Hosts are compared by hostname and port, case-insensitive, with default ports filled in from the scheme. So https://api-connect.supertab.co:443/... counts as Supertab, the same as TS's URL.host. A server that can't be parsed is treated as non-Supertab, so one malformed block elsewhere in license.xml can't stop a valid match from minting.

The new test covers four cases: the Supertab block winning, the fallback when no Supertab block matches, an explicit default port, and an unrelated malformed server. The conformance suite asserts the same thing in customer-*--multi-provider-supertab-wins (v0.5.0). Those scenarios go green once this lands and the runner PR moves Python's pin to v0.5.0.

Released together with the still-unreleased license-less mint (STC-921) under [Unreleased].

@filias
filias marked this pull request as ready for review October 16, 2026 14:34
@filias
filias requested review from nick434434 and ranael-garem and a balanced review from Copilot October 16, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Host classification mishandles explicit default ports and lets malformed unrelated server URLs abort minting.

2 open findings
What changed in this PR

Aligns Python token minting with the TypeScript and PHP SDKs by preferring matching Supertab-hosted content blocks.

Changes:

  • Prioritizes Supertab-hosted matches while retaining best-match fallback.
  • Adds tests for preference and fallback behavior.
  • Documents the change under [Unreleased].
File Description
tests/​customer/​test_tokens.py Tests provider preference and fallback.
supertab_connect/​customer/​token.py Adds host-based token endpoint selection.
CHANGELOG.md Documents Supertab-hosted block priority.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread supertab_connect/customer/token.py Resolved
Comment thread supertab_connect/customer/token.py Resolved
@filias
filias merged commit ac2d78b into main Oct 16, 2026
4 checks passed
filias added a commit that referenced this pull request Oct 16, 2026
Moves the Python conformance job from `v0.3.0` to `v0.5.0`. That version adds the no-match and multi-provider customer scenarios (`connect-sdk-conformance#5`). The runner is fixed so it reports what the SDK actually does:

- **`customer-match`** now calls `_select_token_endpoint`, the selector `obtain_license_token` uses. The runner used to call an older helper of its own, and on no match it reported "no token needed" even though the SDK mints license-less against `{baseUrl}/token`. It now reports the Agreement lane in the same shape TS and PHP use: `{matched:false, matched_url_pattern:null, token_server:<base URL>, requires_token:true}`.
- **`customer-obtain`** passes `supertab_base_url=MOCK_ORIGIN`. Without it, a license-less mint went to the production API.

Builds on #19 (merged), which makes the Python SDK prefer Supertab-hosted blocks; the `customer-*--multi-provider-supertab-wins` scenarios rely on it.
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