From c24f30fe714bfce358908342d627e1b66aa03929 Mon Sep 17 00:00:00 2001 From: yuez Date: Mon, 2 Nov 2026 11:11:40 +0800 Subject: [PATCH] fix(e2e): redeem pairing codes at the public endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both harnesses posted the redeem body to `/api/v1/pair`, which mints a code and requires a device/CLI token, so `e2e_pair` got a 401 and every run died at "FATAL: pair redeem failed" before the first scenario. Redeeming is the public half of pairing (ADR 0001): the code is the capability, and the endpoint is `POST /api/v1/pair/redeem`, unauthenticated and rate limited. - `scripts/e2e/lib.sh` and `scripts/e2e/visual.sh` post the `{code, deviceName, kind}` body to `/api/v1/pair/redeem` - the suite reaches A0 again: `run-api.sh` runs A0–A14, `run-ui.sh` B1–B15 --- scripts/e2e/lib.sh | 4 +++- scripts/e2e/visual.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/e2e/lib.sh b/scripts/e2e/lib.sh index 5985c87..07b814e 100644 --- a/scripts/e2e/lib.sh +++ b/scripts/e2e/lib.sh @@ -159,9 +159,11 @@ e2e_pair() { code="$(jq -r '.code // empty' <<<"$created")" [ -n "$code" ] || e2e_fail "pair.create returned no code: $created" + # Redeeming is the *public* half of pairing: the code is the capability, so + # this call carries no authorization (ADR 0001, docs/protocol.md §3.1). token="$(curl -sS --max-time 10 -X POST -H 'Content-Type: application/json' \ -d "{\"code\":\"$code\",\"deviceName\":\"$name\",\"kind\":\"laptop\"}" \ - "$E2E_BASE/api/v1/pair" | jq -r '.token // empty')" + "$E2E_BASE/api/v1/pair/redeem" | jq -r '.token // empty')" [ -n "$token" ] || e2e_fail "pair redeem failed" E2E_DEVICE_TOKEN="$token" E2E_PAIR_CODE="$code" diff --git a/scripts/e2e/visual.sh b/scripts/e2e/visual.sh index 2ca2f77..482ed82 100755 --- a/scripts/e2e/visual.sh +++ b/scripts/e2e/visual.sh @@ -46,7 +46,7 @@ done echo "instance: $ST workspace: $WSID" CODE=$(cmd '{"method":"pair.create","params":{}}' | jq -r '.code') -DEVTOKEN=$(curl -fsS -X POST "$BASE/api/v1/pair" -H 'Content-Type: application/json' \ +DEVTOKEN=$(curl -fsS -X POST "$BASE/api/v1/pair/redeem" -H 'Content-Type: application/json' \ -d "{\"code\":\"$CODE\",\"deviceName\":\"Playwright\",\"kind\":\"laptop\"}" | jq -r '.token') echo "paired device token: ${DEVTOKEN:0:8}…"