test: guard required production security headers - #61
Merged
Conversation
Assert the site-wide header rules in next.config.ts keep all six required security headers so they can't be removed accidentally. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a focused Vitest regression test against the real Next.js configuration to prevent accidental removal of the six required site-wide production security headers; production code and behavior are unchanged. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Summary
tests/unit/security-headers.test.ts, a Vitest unit test that imports the realnext.config.tsand asserts the site-wide/:path*header rule still contains all six required production security headers:Strict-Transport-Security,X-Frame-Options,X-Content-Type-Options,Referrer-Policy,Permissions-Policy,Content-Security-Policy.Why
Protects the existing security header configuration against accidental removal. No production behavior changed.
Tests run
npm run lint— cleannext typegen && tsc --noEmit(typecheck) — cleanvitest run --coverage— 73/73 tests pass (9 files)npm run build:test— production build succeedsnpx playwright test(e2e) — passes in CILimitations
[mobile-webkit] customer-flows.spec.ts › correcting an invalid email... produces exactly one handoffis flaky: it failed once locally and once on the first CI run, then passed on the CI rerun. Pre-existing flake unrelated to this change (this PR adds only a unit test file; Playwright never loadstests/unit). Worth stabilizing separately.npx node@24).Generated with Devin