Repository navigation
Staff API v1 contract and conformance suite - #33
Merged
Merged
Conversation
Add normative connect page requirements, PKCE encoding with the RFC 7636 test vector, and exchange rules. Define status transitions, sort tie-breaks, /meta caching headers and same-origin URLs, and list the Laravel divergences. Add sla_breached to the OpenAPI Ticket schema.
Treat /meta as served only for a 200 JSON object with a string api_version and name what came back otherwise. Validate both /meta responses against the Meta schema and check that an invalid token gets the public shape with Vary and Cache-Control. Add the optional connect fixture and exchange tests, including a per-IP 429 check that runs last. Pick status targets from the default transition table, cover same-status and forbidden transitions, expect exactly 201 for replies and notes, and use soft assertions in clean-up blocks.
A backend may restrict status changes, but a refused change must be 422 with errors.status and a same-status change a 200 no-op. Laravel's table becomes a recommended default. The suite tries round-trip candidates, treats a refusal as not allowed from here, and checks a refused transition only when ESCALATED_CONFORMANCE_FORBIDDEN_TRANSITION names one. Exchange validation errors are 422 before any code lookup. The wrong-verifier test revokes any minted token before asserting.
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.
Writes down the staff REST API once, so every backend serves the same API to the browser extension and other clients.
What's here
contracts/staff-api-v1.md: the contract. Endpoints, request and response shapes, pagination, errors, rate limits, and the new pieces the extension needs: publicGET /meta,updated_since,last_customer_reply_at, the helpdesk sign-in flow (connect page, one-time code, PKCE,POST /auth/exchange,POST /auth/revoke). The "Connect page requirements" and "Exchange rules" sections are normative.contracts/staff-api-v1.openapi.yaml: the same contract as OpenAPI 3.1 (lints clean with Redocly).conformance/: a black-box suite (Node, TypeScript, Vitest). Each backend's CI boots a seeded install and points it at the API with a few env vars. It talks HTTP only, checks every response against the OpenAPI schemas, and skips cleanly when a backend does not serve the contract yet or lacks an optional feature..github/workflows/contracts.yml: lints the OpenAPI file and typechecks the suite.Laravel 1.9.20 is the reference. Where it differs from the contract, the change log says so; those get fixed in escalated-laravel next.
Expected on Laravel 1.9.20 today
GET /metais 404 there, so the suite reports one failure ("does not serve staff API contract v1") and skips the rest. Once/metalands, these will fail until the Laravel work is done:/auth/exchange,/auth/revoke,updated_since,last_customer_reply_at, the Ticket schema (last_reply_at,sla_breached,is_following,followers_count), macros (stepsvsactions), and the 422 on a refused status change (Laravel answers 500).Verified
/metaeach give one clear failure with the rest skipped; a backend that accepts a wrong PKCE verifier fails and the token it minted is revoked.