test(getClientIp-accessibility): verify Data Accessibility & Header R…#5408
test(getClientIp-accessibility): verify Data Accessibility & Header R…#5408realtushartyagi wants to merge 1 commit into
Conversation
…esolution Protocols
|
@realtushartyagi is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
👋 Hey @realtushartyagi! Thanks for your contribution! 🎉 Unfortunately, this PR has been automatically closed because it is not linked to any open issue. To resolve this, please do the following:
We look forward to reviewing your PR once an issue is linked! 🚀 |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a Vitest test suite to validate getClientIp behavior across common proxy/header scenarios, including spoofing detection and fallback behavior.
Changes:
- Introduces header-resolution tests for
X-Forwarded-For,cf-connecting-ip, andx-real-ip - Adds spoofing-detection assertion via
console.warn - Adds coverage for default/fallback IP behavior and trusted-proxy boundary traversal
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const request = new Request('https://commitpulse.com', { | ||
| headers: new Headers({ | ||
| 'x-forwarded-for': '203.0.113.1, 198.51.100.1, 192.0.2.1', | ||
| }), | ||
| }); |
| import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; | ||
| import { getClientIp } from './getClientIp'; | ||
|
|
||
| describe('getClientIp Data Accessibility & Header Resolution Tests', () => { |
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it('1. reliably accesses the leftmost client IP in an X-Forwarded-For proxy chain when proxies are universally trusted', () => { |
|
Applying labels for scoring. \level:beginner\ because this is a single-file test suite, \ ype:testing\ since it adds coverage, and \quality:clean\ for clear, well-structured tests. |
Description
This PR Adds header resolution and IP access tests for utils/getClientIp.
Fixes #4657
Pillar
Visual Preview
Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.