fix(e2e): redeem pairing codes at the public endpoint

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
This commit is contained in:
yuez committed 2026-11-02 11:11:40 +08:00
1 parent 3a797ac3f7
commit c24f30fe71
2 files changed
+4 -2

No files matched your search

+3 -1
View File
@@ -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"
+1 -1
View File
@@ -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}…"