fix: rewrite trigger-auth tests to avoid Bun.serve CI flakiness#42
Open
electronicBlacksmith wants to merge 1 commit intoghostwright:mainfrom
Open
Conversation
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.
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.
What Changed
Rewrote
/triggerendpoint auth tests to useAuthMiddlewaredirectly with constructedRequestobjects instead of starting aBun.serveinstance and fetching via HTTP.Why
The original tests used
Bun.serve({port: 0})+fetch("http://localhost:PORT/..."), which returnedundefinedresponse status in GitHub Actions CI. The root cause is an IPv4/IPv6 DNS resolution mismatch on Ubuntu runners:Bun.servebinds to0.0.0.0(IPv4) butlocalhostresolves 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() callsbun run lint- cleanbun run typecheck- cleanChecklist
bun test)bun run lint)bun run typecheck).envfiles included