Skip to content

test: cover gateway inbound filters and webhook bind edges - #181

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/missing-test-coverage-5788
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/missing-test-coverage-5788

Conversation

@cursor

@cursor cursor Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Risky behavior now covered

  • Discord drops bot authors and messages with no author, strips only a leading LICH_DISCORD_BOT_ID mention, and posts with allowed_mentions.parse empty so a reply cannot ping the room. A thrown handler becomes a one-line agent error and does not close the socket.
  • Twitch does not answer its own nick, sends PASS oauth: once (no doubled prefix), drops a reply that sanitizes to empty, and strips a leading / before PRIVMSG.
  • Telegram treats a non-array getUpdates result as no updates, skips bots and chat-less updates, keeps chat id 0, uses the media placeholder, and resets poll backoff to the first delay after a successful poll.
  • Webhook bind allows only exact loopback names (127.0.0.1, localhost, ::1, including padding and case). Lookalikes ([::1], 127.1, ::ffff:127.0.0.1) stay refused, and the token is not logged. Non-object JSON is 400. Numeric chat and user ids are stringified. A chunked body over the byte cap, with no content-length, is 413 and never reaches the handler.

Test files added/updated

  • Added test/gateway_inbound.test.ts
  • Updated test/gateway.test.ts

Why this reduces regression risk

These are the chat-adapter and webhook edges from the gateway work (#174, #178) that the existing bus, reconnect, and policy tests do not hit. A regression here is a bot echo loop, a Twitch command sent from the bot, a mention ping, a public bind without a token, or an unbounded webhook body. Sleep and sockets are scripted, so the new cases do not wait on live network or the 2–30s backoff.

Validation

  • node node_modules/vitest/vitest.mjs run test/gateway_inbound.test.ts test/gateway.test.ts — 49 passed
  • node node_modules/typescript/bin/tsc --noEmit — passed
  • Full suite not run; known environment failures remain when bun or dist/cli.js is missing.
Open in Web View Automation 

Discord ignores bots and strips only a leading mention before a mention-disabled post. Twitch ignores its own nick and a command-only reply. Telegram skips bots and chat-less updates and resets poll backoff after success. Webhook binds stay exact-match loopback, and a chunked body over the cap is rejected.

Co-authored-by: moikapy <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant