Skip to content

Add conformance runner for the cross-SDK parity suite - #31

Merged
filias merged 2 commits into
mainfrom
conformance-runner
Oct 16, 2026
Merged

filias merged 2 commits into
mainfrom
conformance-runner

Conversation

@filias

@filias filias commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Adds conformance/run.php, the PHP runner for the cross-SDK parity suite (getsupertab/connect-sdk-conformance). It reads one scenario on stdin, drives the real SDK, and prints the normalized decision, the same as the TS and Python runners. Once it lands, PHP can get the same conformance CI job TS and Python already have.

This replaces #26, which was written against pre-2.0 main. Differences from #26:

  • customer-match now uses the SDK's own endpoint selection (LicenseTokenClient::selectTokenEndpoint, reached through a bound closure) instead of matching all blocks with ContentMatcher. Since 2.0 the parser keeps serverless blocks, so the old version matched a block PHP's obtain path would never mint against. It also picks up the Supertab-host preference.
  • customer-obtain now passes baseUrl: MOCK_ORIGIN. In Add PHP conformance runner #26 it used the SDK's production default, so a license-less mint went to the real API.
  • verify and enforce are unchanged from Add PHP conformance runner #26.

The runner sits outside src/ and tests/, so phpcs and phpunit don't touch it.


Review notes (delete on merge)

Against the conformance feat/php-runner branch: 45 checks, 0 failed, PHP 15/15 on PHP 8.1. The two serverless-permitted scenarios pass through their existing php overrides. Their reason text is out of date and gets rewritten in the conformance PR.

🤖 Generated with Claude Code

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

Customer-obtain retains the production base URL, allowing fallback token requests to bypass the mock server.

1 open finding
What changed in this PR

Adds a PHP runner for the cross-SDK conformance suite, exercising real SDK behavior and emitting normalized JSON decisions.

Changes:

  • Supports verify, enforce, customer-match, and customer-obtain scenarios.
  • Uses the SDK’s endpoint selection for customer matching.
File Description
conformance/​run.php Adds stdin scenario handling, SDK calls, and normalized output.

🧠 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 conformance/run.php Resolved
@filias
filias marked this pull request as ready for review October 16, 2026 07:42
@filias
filias merged commit a53613b into main Oct 16, 2026
5 checks passed
nick434434 added a commit that referenced this pull request Nov 4, 2026
## Why
WordPress adds backslashes to `$_SERVER` (`wp_magic_quotes()`). `handleRequest()` reads headers from there through `fromGlobals()`. As a result, `Signature-Input`, `Signature-Agent` and `User-Agent` arrive as `\"https://crawler.exa.ai\"`, and no signature from a WordPress merchant verifies. Five merchants that send events over HTTP are affected, about 16k signed requests a week, all `unverifiable/unsupported_agent`. Removing the backslashes makes 40 of 40 sampled rows valid.

The SDK stays framework-agnostic. The WordPress-specific unslashing goes in the plugin (getsupertab/connect-wp, PR to follow). This PR only lets callers pass their own `$_SERVER`-shaped array.

## Changes
- New `RequestContext::fromServer(array $server, array $requestHeaders = [])` with the old `fromGlobals()` body.
- `fromGlobals()` now calls `fromServer($_SERVER, getallheaders())`. No behavior change.
- Test in `tests/Http/RequestContextTest.php`.

## Release notes (v2.2.0, all changes since v2.1.0)

### Added
- `RequestContext::fromServer(array $server, array $requestHeaders = [])` builds a context from a `$_SERVER`-shaped array. Hosts that modify `$_SERVER` can pass a cleaned copy. WordPress, for example, adds backslashes to it, which broke signature verification for plugin merchants. `fromGlobals()` now delegates to it and behaves the same. (this PR)

### Internal (no runtime changes)
- Added `conformance/run.php`, the PHP runner for the cross-SDK parity suite (#31).
- CI runs the cross-SDK conformance corpus (#33), now pinned to v0.5.0 (#34).
- On a no-match, the conformance runner now reports the SDK's Agreement-lane result instead of "no token needed" (#34).
- Fixed a flaky status test by padding EC coordinates in the test JWK (#32).

`CHANGELOG.md` has these entries under `[2.2.0] - 2026-11-04`, and `composer.json` is set to `v2.2.0`. After merging, tag `v2.2.0`.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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