Skip to content

fix: rewrite trigger-auth tests to avoid Bun.serve CI flakiness#42

Open
electronicBlacksmith wants to merge 1 commit intoghostwright:mainfrom
electronicBlacksmith:upstream/fix/trigger-auth-test-stability
Open

fix: rewrite trigger-auth tests to avoid Bun.serve CI flakiness#42
electronicBlacksmith wants to merge 1 commit intoghostwright:mainfrom
electronicBlacksmith:upstream/fix/trigger-auth-test-stability

Conversation

@electronicBlacksmith
Copy link
Copy Markdown

What Changed

Rewrote /trigger endpoint auth tests to use AuthMiddleware directly with constructed Request objects instead of starting a Bun.serve instance and fetching via HTTP.

Why

The original tests used Bun.serve({port: 0}) + fetch("http://localhost:PORT/..."), which returned undefined response status in GitHub Actions CI. The root cause is an IPv4/IPv6 DNS resolution mismatch on Ubuntu runners: Bun.serve binds to 0.0.0.0 (IPv4) but localhost resolves to ::1 (IPv6) in CI.

The middleware logic tested is identical - this change only affects the test harness. All 5 test cases still verify the same auth behaviors: missing header rejection, invalid token rejection, insufficient scope rejection, operator token acceptance, and admin token acceptance.

How I Tested

  • bun test src/core/__tests__/trigger-auth.test.ts - 5 pass, 11 expect() calls
  • bun run lint - clean
  • bun run typecheck - clean

Checklist

  • Tests pass (bun test)
  • Lint passes (bun run lint)
  • Typecheck passes (bun run typecheck)
  • No secrets or .env files included
  • Files stay under 300 lines
  • No Cardinal Rule violations
  • No default exports or barrel files added

Tests AuthMiddleware directly with constructed Request objects instead
of starting a Bun.serve instance and fetching via HTTP.

The original tests used Bun.serve({port: 0}) + fetch(localhost), which
returned undefined response status in GitHub Actions CI due to IPv4/IPv6
DNS resolution differences on Ubuntu runners. The middleware logic is
identical - this change only affects the test harness.
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