Skip to content

Commit ced67e8

Browse files
test(streak): assert CSP security headers (JhaSourav07#880)
## Description Fixes JhaSourav07#702 Added additional security header assertions for the streak SVG API route Content-Security-Policy configuration. ## Changes Made * Asserted CSP allows inline SVG styles using `style-src 'unsafe-inline'` * Asserted CSP allows Google Fonts stylesheet source * Asserted CSP does not include `script-src` ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [ ] 🕐 Pillar 3 — Timezone Logic Optimization * [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview Not applicable — test-only change. ## Checklist before requesting a review: * [x] I have read the `CONTRIBUTING.md` file. * [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). * [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). * [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). * [ ] I have updated `README.md` if I added a new theme or URL parameter. * [x] I have started the repo. * [x] I have made sure that i have only one commit to merge in this PR. * [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). * [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
1 parent 09f0709 commit ced67e8

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

app/api/streak/route.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,14 @@ describe('GET /api/streak', () => {
189189
});
190190

191191
describe('security headers', () => {
192-
it('sets a strict Content-Security-Policy that blocks all external resources', async () => {
192+
it('sets a strict Content-Security-Policy with safe SVG styling rules', async () => {
193193
const response = await GET(makeRequest({ user: 'octocat' }));
194194
const csp = response.headers.get('Content-Security-Policy');
195195

196196
expect(csp).toContain("default-src 'none'");
197-
// SVG badges rely on inline styles for theming, so unsafe-inline must be allowed.
198197
expect(csp).toContain("style-src 'unsafe-inline'");
198+
expect(csp).toContain('https://fonts.googleapis.com');
199+
expect(csp).not.toContain('script-src');
199200
});
200201
});
201202

0 commit comments

Comments
 (0)