fix(channels): deterministic discord token-leak test (RCA #1763 Finding 2) #1771

Closed
agent-dev-a wants to merge 1 commits from fix-1763-webhook-token-redaction-skip into main
Member

Summary

Replaces the flaky network-dependent TestDiscordAdapter_SendMessage_ErrorDoesNotLeakToken with a deterministic fake-transport test. Fixes RCA #1763 Finding 2.

Changes

  • Add optional httpClient field to DiscordAdapter (test-only injection point)
  • Use injected client in SendMessage when non-nil; fall back to default timeout client otherwise
  • Replace t.Skip test with fake http.RoundTripper that returns a URL-bearing error; assert adapter still redacts the token

Scope

  • ONE finding only (Finding 2 — webhook token redaction skip)
  • Single PR
  • molecule-core only

Test plan

  • go test ./workspace-server/internal/channels passes
  • All TestDiscordAdapter_* tests pass
  • No production behavior change when httpClient is nil

Fixes #1763

## Summary Replaces the flaky network-dependent `TestDiscordAdapter_SendMessage_ErrorDoesNotLeakToken` with a deterministic fake-transport test. Fixes RCA #1763 Finding 2. ## Changes - Add optional `httpClient` field to `DiscordAdapter` (test-only injection point) - Use injected client in `SendMessage` when non-nil; fall back to default timeout client otherwise - Replace `t.Skip` test with fake `http.RoundTripper` that returns a URL-bearing error; assert adapter still redacts the token ## Scope - ONE finding only (Finding 2 — webhook token redaction skip) - Single PR - molecule-core only ## Test plan - [x] `go test ./workspace-server/internal/channels` passes - [x] All `TestDiscordAdapter_*` tests pass - [x] No production behavior change when `httpClient` is nil Fixes #1763
agent-dev-a added 1 commit 2026-05-24 04:00:47 +00:00
fix(channels): make discord token-leak test deterministic (RCA #1763 Finding 2)
Block internal-flavored paths / Block forbidden paths (pull_request) Waiting to run
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
CI / Python Lint & Test (pull_request) Waiting to run
CI / all-required (pull_request) Waiting to run
CI / Detect changes (pull_request) Waiting to run
E2E API Smoke Test / detect-changes (pull_request) Waiting to run
E2E Chat / detect-changes (pull_request) Waiting to run
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Waiting to run
Handlers Postgres Integration / detect-changes (pull_request) Waiting to run
Harness Replays / detect-changes (pull_request) Waiting to run
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Waiting to run
Lint no tenant GITEA or GITHUB token write / Scan for repo-host token write into tenant workspace surface (pull_request) Waiting to run
lint-required-no-paths / lint-required-no-paths (pull_request) Waiting to run
Secret scan / Scan diff for credential-shaped strings (pull_request) Waiting to run
gate-check-v3 / gate-check (pull_request) Waiting to run
qa-review / approved (pull_request) Waiting to run
security-review / approved (pull_request) Waiting to run
sop-checklist / all-items-acked (pull_request) Waiting to run
sop-checklist / review-refire (pull_request) Waiting to run
sop-tier-check / tier-check (pull_request) Waiting to run
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Successful in 8s
audit-force-merge / audit (pull_request) Waiting to run
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Has been cancelled
E2E API Smoke Test / E2E API Smoke Test (pull_request) Has been cancelled
CI / Platform (Go) (pull_request) Has been cancelled
CI / Canvas (Next.js) (pull_request) Has been cancelled
CI / Shellcheck (E2E scripts) (pull_request) Has been cancelled
CI / Canvas Deploy Reminder (pull_request) Has been cancelled
E2E Chat / E2E Chat (pull_request) Has been cancelled
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Has been cancelled
Harness Replays / Harness Replays (pull_request) Has been cancelled
54b6ce0d57
TestDiscordAdapter_SendMessage_ErrorDoesNotLeakToken previously relied
on a real network dial to an unroutable address and t.Skip'd when the
request unexpectedly succeeded.  This made the test flaky and caused
silent loss of security-coverage in environments where the dial did not
fail.

- Add optional httpClient field to DiscordAdapter so tests can inject a
  fake http.RoundTripper.
- Replace the skip-based test with a deterministic fake-transport that
  returns an error containing the webhook URL, then assert the adapter
  still redacts the token.
- Zero behavioral change when httpClient is nil (production path).

Fixes RCA #1763 Finding 2 — webhook token redaction skip.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
agent-dev-a closed this pull request 2026-05-24 04:03:17 +00:00
Some checks are pending
Block internal-flavored paths / Block forbidden paths (pull_request) Waiting to run
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
CI / Python Lint & Test (pull_request) Waiting to run
CI / all-required (pull_request) Waiting to run
Required
Details
CI / Detect changes (pull_request) Waiting to run
E2E API Smoke Test / detect-changes (pull_request) Waiting to run
E2E Chat / detect-changes (pull_request) Waiting to run
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Waiting to run
Handlers Postgres Integration / detect-changes (pull_request) Waiting to run
Harness Replays / detect-changes (pull_request) Waiting to run
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Waiting to run
Lint no tenant GITEA or GITHUB token write / Scan for repo-host token write into tenant workspace surface (pull_request) Waiting to run
lint-required-no-paths / lint-required-no-paths (pull_request) Waiting to run
Secret scan / Scan diff for credential-shaped strings (pull_request) Waiting to run
gate-check-v3 / gate-check (pull_request) Waiting to run
qa-review / approved (pull_request) Waiting to run
security-review / approved (pull_request) Waiting to run
sop-checklist / all-items-acked (pull_request) Waiting to run
sop-checklist / review-refire (pull_request) Waiting to run
sop-tier-check / tier-check (pull_request) Waiting to run
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Successful in 8s
audit-force-merge / audit (pull_request) Waiting to run
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Has been cancelled
Required
Details
E2E API Smoke Test / E2E API Smoke Test (pull_request) Has been cancelled
Required
Details
CI / Platform (Go) (pull_request) Has been cancelled
CI / Canvas (Next.js) (pull_request) Has been cancelled
CI / Shellcheck (E2E scripts) (pull_request) Has been cancelled
CI / Canvas Deploy Reminder (pull_request) Has been cancelled
E2E Chat / E2E Chat (pull_request) Has been cancelled
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Has been cancelled
Harness Replays / Harness Replays (pull_request) Has been cancelled
E2E Peer Visibility (literal MCP list_peers) / E2E Peer Visibility (pull_request)
Required

Pull request closed

Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#1771