Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
The AP2 test sent a placeholder mandate and expected completion, but the mock Platform profile never declared AP2, so AP2 was never negotiated and a Business that ignores mandates passed. Serve an opt-in Platform profile that declares checkout, the AP2 Mandates extension and a signing key, and run the AP2 tests only when AP2 is in the capability intersection computed per the UCP intersection algorithm. Add a negative case that completion without a checkout mandate is refused with mandate_required. Skip the positive case until a signed SD-JWT+kb mandate fixture exists, since a verifying Business must reject the placeholder. AP2 names, URLs and the key field differ between UCP releases, so the descriptor covers only the suite's current 2026-04-08 target. Refs Universal-Commerce-Protocol#114
aeoess
force-pushed
the
test/ap2-negotiation
branch
from
October 9, 2026 22:52
5516246 to
18f1c96
Compare
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.
Description
Refs #114.
test_ap2_mandate_completionsent the placeholder mandateheader.payload.signature~kb_signatureand expected the checkout to complete. The mock Platform profile never declared AP2, so AP2 was never negotiated, and a Business that ignores mandates passed the only AP2 test.This PR makes the AP2 tests run only when AP2 is actually negotiated, and adds the missing negative case.
/profiles/shopping-agent-ap2.json, that declares checkout, the AP2 Mandates extension extending checkout, and a public P-256 signing key for the trusted platform provider flow. The default profile is unchanged, because a Business that supports AP2 must refuse every completion without a mandate once AP2 is negotiated, which would affect every other test. Any existing keys in the profile are preserved.capability_intersection()implements the UCP intersection algorithm: name match, highest mutual version, and repeated pruning of extensions whose parent is absent. The AP2 tests skip unless AP2 is in that intersection. A Business that merely lists AP2 in a shape that does not negotiate is skipped, not tested.test_complete_without_mandate_is_rejectedrequires that completion withoutap2.checkout_mandatedoes not complete and carriesmandate_required.test_ap2_mandate_completionnow skips with an explicit reason. Once AP2 is negotiated, a Business that verifies the mandate must reject the placeholder, so the test cannot stay a passing positive. A real positive needs a signed SD-JWT+kb mandate fixture and a signing model, which this PR does not attempt.Release scope
AP2 names changed between UCP releases. In 2026-04-08 the capability is
dev.ucp.shopping.ap2_mandate, with/specification/ap2-mandates,/specification/checkoutand top-levelsigning_keys. In 2026-08-25, and in current HEAD at the time of this investigation, the capability isdev.ucp.common.payment.ap2_mandate, with the payment extension paths,/specification/shopping/checkoutandkeys. #114 cited the newer name from the spec atucp@4a3aa10f. This PR follows the suite's current 2026-04-08 target.ap2_release()describes that release only and returnsNonefor others, in which case the tests skip.Not in this PR
samples. The current sample server does not declare AP2, so both AP2 tests skip against it.Open question for review
The 2026-04-08 AP2 spec does not bind
mandate_requiredto one error form. The test accepts either, each in its own shape: HTTP 200 requires the UCP error envelope (ucp.status=error) with an error message whose code ismandate_required, and any other status requires a top-levelcodeofmandate_required. Happy to narrow this if you prefer one form.How it was tested
Against the Python sample server from
samples@c2e04403, withpython-sdk@v2026-04-08-6as pinned in CI and the flower shop data. V1 to V4 used local, unsubmitted modifications of the sample to exercise both outcomes.mandate_requiredFull suite against the unmodified sample: 73 passed, 3 skipped, 2 failed, compared with 74 passed, 1 skipped, 2 failed without this change. The two failures are
order_test.py::OrderTest::test_order_fulfillment_retrievalandtest_order_update, which return HTTP 500 with and without this change. The difference is the two AP2 tests now skipping.ruff checkandruff format --checkpass.Type of change
Checklist
order_testfailures occur with and without this change, see above.