Skip to content

test: cover checkout members the caller is not allowed to set - #112

Merged
damaz91 merged 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:test/checkout-field-ownership
Nov 12, 2026
Merged

damaz91 merged 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:test/checkout-field-ownership

Conversation

@vishkaty

Copy link
Copy Markdown
Contributor

Category (Required)

  • Core Protocol: Changes to the base communication layer, global context, or breaking refactors. (Requires Technical Council approval)
  • Governance/Contributing: Updates to GOVERNANCE.md, CONTRIBUTING.md, or CODEOWNERS. (Requires Governance Council approval)
  • Capability: New schemas (Discovery, Cart, etc.) or extensions. (Requires Maintainer approval)
  • Documentation: Updates to README, or documentations regarding schema or capabilities. (Requires Maintainer approval)
  • Infrastructure: CI/CD, Linters, or build scripts. (Requires DevOps Maintainer approval)
  • Maintenance: Version bumps, lockfile updates, or minor bug fixes. (Requires DevOps Maintainer approval)
  • SDK: Language-specific SDK updates and releases. (Requires DevOps Maintainer approval)
  • Samples / Conformance: Maintaining samples and the conformance suite. (Requires Maintainer approval)
  • UCP Schema: Changes to the ucp-schema tool (resolver, linter, validator). (Requires Maintainer approval)
  • Community Health (.github): Updates to templates, workflows, or org-level configs. (Requires DevOps Maintainer approval)

Description

checkout.json marks continue_url, expires_at, messages and order with
ucp_request: omit, so a caller has no schema legal way to set them. A create
handler that builds its response by spreading the raw request body will still
let a caller supplied value through, because the SDK request model simply has
no field to stop it.

That bug was real in both reference servers and was fixed in samples#193 for
nodejs and samples#196 for python. Nothing in this suite checks it, so a
regression would go unnoticed. This adds the check.

What it does

The module posts a raw JSON body carrying values for all four members, which is
what a client not using the SDK can do, and asserts the values the business set
come back instead:

  • in the create response
  • and in the stored checkout, read back afterwards, which rules out a handler
    that merely strips them from the response while persisting them

A third test sends none of the four, so a server that starts rejecting their
absence is caught too.

Verification

Against the reference server, with python-sdk pinned to v2026-04-08-6 exactly
as this suite pins it:

server result
as it stands 3 tests OK
omit members removed from the create exclude set, so the handler adopts what the caller sent 2 of 3 FAIL, the control stays green

The two failures name the leaked value in both places:

AssertionError: continue_url is business owned (checkout.json ucp_request: omit);
  the caller-supplied value must not appear in the create response
AssertionError: continue_url is business owned (checkout.json ucp_request: omit);
  the caller-supplied value must not appear in the stored checkout

Full suite: 17 of 18 files pass. order_test.py fails on the two pre existing
500s from samples#218, which this does not touch. pre-commit run --all-files
passes.

Sequencing

#107 restructures the suite across 58 files. If it lands first this module moves
to the new layout. Happy to rebase either way round.

@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Sep 18, 2026

@damaz91 damaz91 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.

LGTM — thank you for adding conformance coverage for "ucp_request": "omit" field ownership on Checkout, @vishkaty!

Layering CALLER_SUPPLIED (continue_url, expires_at, messages, and order) onto the raw POST /checkout-sessions payload and verifying via test_create_does_not_adopt_caller_supplied_omit_members and test_create_does_not_persist_caller_supplied_omit_members that none of those business-owned values appear in either the create response or the subsequent GET /checkout-sessions/{id} read—paired with test_create_without_omit_members_is_unaffected—cleanly tests the checkout.json contract.

@damaz91 damaz91 added status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Oct 30, 2026
Three cases asserting that a create does not adopt or persist members the
request schema marks `omit`, and that a create without them is unaffected.

Placed as `shopping/checkout/field_ownership_test.py` and registered as
`shopping.checkout.field_ownership_test`, following the layout Universal-Commerce-Protocol#121 landed and
dropping the redundant `checkout_` prefix the way `checkout_lifecycle_test`
became `shopping.checkout.lifecycle_test`. The path and the module name are a
suggestion and easy to change.

Universal-Commerce-Protocol#120 made `SUITE_REGISTRY` the only path `--suite=all` runs, so the entry is
what makes the module execute at all: without it `--suite=all` resolves 78
cases and selects none of these three, and with it 81.

Run against the sample server from samples main: 3 passed on their own, and
81 passed for the whole suite with one skip elsewhere.
@vishkaty
vishkaty force-pushed the test/checkout-field-ownership branch from 9288e31 to 56cded9 Compare November 11, 2026 19:39
@vishkaty

Copy link
Copy Markdown
Contributor Author

Rebased onto main at 1201fb78 now that #121 has landed. Flagging what moved, since the two
approvals above were given when this file sat at the repository root.

The test content is unchanged. What changed is where it lives and how it is registered:

The path and the module name are a suggestion, not a position. If you would rather it kept the
old name, or sat elsewhere, say so and I will move it.

Measured on this head against the sample server from samples main: the module alone gives 3
passed, and --suite=all gives 81 passed with one skip elsewhere. Without the registry entry
--suite=all resolves 78 and selects none of the three, which is the reason the entry is part
of this change rather than a follow up.

@damaz91
damaz91 merged commit 965738a into Universal-Commerce-Protocol:main Nov 12, 2026
14 checks passed
vishkaty added a commit to vishkaty/conformance that referenced this pull request Nov 17, 2026
Four cases over cart conversion: conversion uses cart contents over the
payload, a second conversion returns the existing checkout, cancel returns the
cart state before deletion, and cart discount codes carry forward.

Placed as `shopping/cart/cart_test.py` in a new `shopping/cart/` package,
following the layout Universal-Commerce-Protocol#121 landed, and registered as `shopping.cart.cart_test`.

What makes the module execute: without the registry entry `--suite=all`
resolves 83 cases and selects none of these four, and with it 87.

Rebased onto main past Universal-Commerce-Protocol#122. The only conflict was the registry list, where
Universal-Commerce-Protocol#112 and Universal-Commerce-Protocol#122 had each added an entry. The cart entry sits at the head of the
shopping list, which keeps that list grouped by subpackage in alphabetical
order.

Obligations are cited by section name, in the module docstring and at each
case, rather than by line number. The line numbers the module carried were
correct when it was written and had since drifted, one of them onto an
unrelated paragraph, which is the hazard of citing a moving document by line.

Two cases were judging a conformant business wrongly, and both are corrected
here. The discount case used the presence of the code in the response as its
evidence that the code had applied, but a business may return a code it
received without applying it, as the reference does for an unknown code. With
a configured code that does not apply at the business under test, the case
therefore ran with nothing applied, and it failed a business that carried its
applied codes forward and dropped the unapplied one with a
`discount_code_invalid` warning, which discount.md allows. Application now
needs an applied entry naming the code or a discount in totals, so such a
code skips the case instead. Carry-forward is still satisfied by naming the
code, and a discount standing in for it must now be at least as large as the
one on the cart, so an unrelated discount no longer counts.

The contents comparison took line items as a bag of id and quantity pairs,
which failed a business expressing two units as two single-unit lines. It now
sums quantity per item id and leaves out lines naming a parent, which still
catches a business that takes its quantities from the request payload.

Verified against the flower shop reference: the module alone gives 4 passed
and 0 skipped; --suite=all gives 87 executed, 85 passed, 2 skipped, 0
failures; the pinned pre-commit, ruff, ruff format and cspell are clean. Nine
servers each breaking one obligation redden their own case and nothing else,
and the two corrections above are each held by a server that fails the old
code and passes the new one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants