Skip to content

Commit 401717f

Browse files
authored
test(validation): check query validation boundaries for org param (JhaSourav07#2262)
## Description Fixes JhaSourav07#1437 Program: GSSoC 2026 This PR handles the implementation of validation boundary unit testing for the incoming `?org=` query parameter under variation 2. Previously, normal organization string parameters were evaluated, but passing explicit spaces and format violations required isolated boundary test coverage to guarantee input schema safety. ### Changes Made * Added 1 target schema validation boundary test case inside `lib/validations.test.ts`. * Mocked an invalid parameter payload passing an organization configuration value set to `'invalid_org_name_with_spaces'`. * Asserted that the system validation layer catches the alphanumeric format violation using `.safeParse()` to align with repository design guidelines. ### Why this matters Secures internal endpoint ingestion routers from processing out-of-bound organization string formats, ensuring the routing engine is protected against unexpected upstream runtime issues or malicious injections. ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`npm run test`). - [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 starred 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 server for faster collaboration, mentorship, and PR support.
2 parents 018763e + 9019264 commit 401717f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/validations.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,18 @@ describe('streakParamsSchema — org parameter validation', () => {
771771
expect(fieldError).toBe('Invalid organization name format');
772772
}
773773
});
774+
775+
it('should reject org parameter with invalid alphanumeric format', () => {
776+
const result = streakParamsSchema.safeParse({
777+
user: 'octocat',
778+
org: 'invalid_org_name_with_spaces',
779+
});
780+
781+
expect(result.success).toBe(false);
782+
if (!result.success) {
783+
expect(result.error.flatten().fieldErrors.org?.[0]).toBe('Invalid organization name format');
784+
}
785+
});
774786
});
775787

776788
describe('ogParamsSchema', () => {

0 commit comments

Comments
 (0)