Repository navigation
test: contract tests against the providers' official specs and opt-in live suites - #15
Merged
Merged
Conversation
Audit of the Meta, Twilio, seven.io and Telegram adapters against the providers' official specs and docs (docs/audits/2026-11-20-provider-apis.md). - seven.io: tell the owner to use the JSON webhook request method and log signed non-JSON webhooks instead of dropping them silently; cut SMS at the documented 1520 characters; map 101/500/501/407004 correctly; read sms_mo Unix timestamps and the HLR roaming object. - Twilio: 21610 and OptOutType=STOP revoke consent; 21611 is transient. - Telegram: never cut the HTML text inside an entity. - Follow api.rest.prefix for webhook URLs, status callbacks, file links and the raw-body middleware. - Keep surrogate pairs whole when cutting text; honour HTTP-date Retry-After. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Meta's official OpenAPI (facebook/openapi business-messaging-api_v23.0.yaml) requires template.language.policy; "deterministic" is its only value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… add opt-in live suites - tests/contract-*.test.js (offline, in npm test): requests, responses and webhooks checked against Meta's facebook/openapi, Twilio's twilio-oai, seven.io's api-schemes and the Telegram Bot API tables, pinned in tests/contract/specs by scripts/contract-specs.mjs (commit + sha256 for the OpenAPI sources). Known defects of the official specs are listed and ignored explicitly. - tests/live/*.live.test.js (npm run test:live, never in CI): Telegram, Twilio test credentials, Meta test number, seven.io; credentials only from ~/.config/magic-messagegate-live/.env (mode 600); paid sends, webhook changes and interactive steps behind their own switches; webhook end to end through a cloudflared tunnel with restore. - yaml (maintained, already in the tree) as a dev dependency for the Meta spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
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.
Stacked on #13 (base
fix/provider-audit; GitHub retargets it tomainwhen #13 is merged). The contract tests assert the fixed behaviour from #13.Contract tests (offline, part of
npm test)tests/contract-{meta,twilio,seven,telegram}.test.jscapture every adapter request in memory and validate it against the provider's own pinned specification; the specs' examples are fed back through the adapters and webhook handlers.tests/contract/specs/)facebook/openapibusiness-messaging-api_v23.0.yaml@e96a1c9d+ sha256twilio/twilio-oaitag 2.11.1 (api_v2010,lookups_v2,content_v1) + sha256; Twilio's own signature test vector from twilio-nodeseven-io/api-schemesjson/openapi.json@0c976749+ sha256; webhook examples from docs.seven.ionpm run contract:specsrebuilds the snapshots,-- --checkreports upstream changes (network, maintainer only). Dependency-free validator intests/contract/validator.js;yaml(maintained, already in the lockfile) added as a dev dependency for the Meta YAML.Found by the contract tests:
template.language.policy→ MessageGate now sends"deterministic"(separatefixcommit).indexpattern, missingcopy_codesub_type, incoming webhook schemas inheriting outgoing required fields; Twiliotwilio/cardmissingbody, Lookup fields not nullable; seven.io example sender invalid). Each is listed with evidence indocs/contract-tests.mdand ignored explicitly; every other error fails.Live suites (
npm run test:live, never in CI)tests/live/{telegram,twilio,meta,seven}.live.test.js, modelled on Magic Mail's suites. Credentials only from~/.config/magic-messagegate-live/.env(mode 600 enforced), never printed; request log masks tokens/SIDs/numbers; host allowlist.LIVE_PROVIDERSselects providers. Safe by default (Twilio test credentials + magic numbers through the full send path, Meta test number, own Telegram chat, seven.io balance only). Paid sends (LIVE_ALLOW_PAID=1), webhook changes (LIVE_WEBHOOKS=1, cloudflared quick tunnel) and owner interaction (LIVE_INTERACTIVE=1) each need a switch; webhook tests restore what they change (Telegram webhook, Meta number-level override, seven.io hooks created/deleted by id, Twilio per-message callback). Keys per provider:docs/live-tests.md.Not run live yet: no credentials file exists on the maintainer machine. Without it all 24 live tests skip with the reason. The harness itself is tested offline (
tests/live-harness.test.js), and the tunnel path was checked manually: a seven.io-signed DLR posted to the publictrycloudflare.comURL → 200, unsigned → 401.Local: lint, format:check,
npm test201 pass (twice), test:admin, build, verify,npm pack --dry-run(30 files, no tests/specs shipped).🤖 Generated with Claude Code