Repository navigation
test: take client addresses in the session-store and connection-limit tests from test-constants - #702
Conversation
…ection-limit tests from test-constants Move the hardcoded IPv4/IPv6 addresses and network keys in session-store-policy.vitest.ts and connection-limits.vitest.ts into named constants in tests/test-constants.ts (SonarCloud S1313). No behaviour change.
Standards review (head
|
Spec review against #701 (head
|
| Issue asks | Done |
|---|---|
Move the client addresses flagged in session-store-policy.vitest.ts (alerts #113–#118) into tests/test-constants.ts |
Yes. Every address and network-key literal in the file, including lines 102–107, 119, 122, 124 and 132, now comes from TEST_IPS / TEST_SUBNETS |
The same in connection-limits.vitest.ts (alerts #119, #120, lines 166–167) |
Yes. Lines 165–167 and the 2001:db8::1 on 171 use TEST_IPS constants |
| Named constants for client and network addresses, documentation ranges where used | Yes. The new names say what each value is (*_CLIENT_KEY_64, *_SUBNET_48, PRIVATE_192_2_24, DOCUMENTATION_V6_EXPANDED_UPPER). The IPv6 fixtures were already in 2001:db8::/32. The IPv4 fixtures stay on the existing private-range constants because networkKeyFor's /24 grouping is what the tests check, so swapping to 192.0.2.0/24 would change the fixtures without adding anything |
| Check the other test files added in the same change | Done. Searched every test line added by b523efc1 for IPv4/IPv6 literals in single, double and template strings without //NOSONAR: these two files were the only hits |
| No behaviour change | Holds. Test-only diff; every replacement has the same string value, except fd12:3456::1 → TEST_IPS.UNIQUE_LOCAL_V6 (fd00::5), still a ULA (fc00::/7), so the assertion checks the same thing |
Checks: lint, lint:sonar, typecheck, npm test, then scripts/sonar-pr.sh clean |
See the checks comment. sonar-pr.sh: gate OK, 0 issues, 0 hotspots. The alerts close when the branch's SonarCloud result reaches main (still open on the default branch until then; none open on refs/pull/702/merge) |
Findings: none.
Checks at head
|
| Check | Result |
|---|---|
npm run lint |
pass, 0 errors |
npm run lint:sonar |
0 errors; 2 warnings, both in app/config/trust-proxy.ts (untouched here). Changed files: clean |
npm run typecheck |
pass |
npm test |
pass: 206 files passed, 2 skipped; 3182 tests passed, 11 skipped |
scripts/sonar-pr.sh 702 |
exit 0: quality gate OK at d68163189bf2, 0 open issues, 0 hotspots |
CI on this head (run 47461180305):
| Check | Result |
|---|---|
docker-image-scan |
pass |
dependency-review |
pass |
| SonarCloud Code Analysis | pass |
build-lint-test |
fail, but only at the Security audit step. Lint, typecheck, build and unit/integration tests passed. npm audit --audit-level=high fails on the HIGH advisories for engine.io (GHSA-c8pq-854x-25q2, also hits socket.io) and cross-spawn (GHSA-w3gc-668g-rf8f, also hits eslint). main fails the same way at b523efc1 (run 47459232633), so this PR didn't cause it. #703 (for #700) fixes both. Once it merges, I'll merge origin/main into this branch so build-lint-test goes green |
…lient-addresses-in-the-sessio
|
Checks at head
|
| Check | Result |
|---|---|
npm run lint |
pass, 0 errors |
npm run lint:sonar |
0 errors; the same 2 warnings in app/config/trust-proxy.ts (untouched here) |
npm run typecheck |
pass |
npm test |
pass: 206 files passed, 2 skipped; 3187 tests passed, 11 skipped |
npm audit --audit-level=high |
pass |
scripts/sonar-pr.sh 702 |
exit 0: quality gate OK at 01196810b68c, 0 open issues, 0 hotspots |
CI (run 47461976665): build-lint-test pass, docker-image-scan pass, dependency-review pass, SonarCloud Code Analysis pass (Trivy skipped, as the workflow does on PRs).



Closes #701
What
SonarCloud S1313 (hardcoded IP addresses) flagged test fixtures in two test files added with the resource-limits work. This moves every address and network key in them into named constants in
tests/test-constants.ts, as the testing rule asks. No behaviour change: only test code moves.tests/test-constants.ts: new constantsTEST_SUBNETS.PRIVATE_192_2_24,DOCUMENTATION_V6_CLIENT_KEY_64,LOCALHOST_V6_CLIENT_KEY_64,DOCUMENTATION_V6_SUBNET_48,DOCUMENTATION_V6_SUBNET_ALT_48, andTEST_IPS.DOCUMENTATION_V6_EXPANDED_UPPER, each with//NOSONARlike the existing entries.tests/unit/middleware/session-store-policy.vitest.ts: the expected/24,/48and/64keys and the expanded upper-case IPv6 address now come from those constants, plus the existingTEST_SUBNETS.PRIVATE_192andPRIVATE_10_24.tests/unit/services/connection-limits.vitest.ts:::1,fe80::1%eth0and2001:db8::1use the existingTEST_IPSconstants; the ULA samplefd12:3456::1becomes the existingTEST_IPS.UNIQUE_LOCAL_V6(fd00::5), still a unique-local address, so the test checks the same thing.The other test files added in the same change were scanned for IP literals in single, double and template strings without
//NOSONAR; these two files were the only ones with any.Checks (local)
npm run lint: 0 errorsnpm run lint:sonar: 0 errors; the 2 warnings are inapp/config/trust-proxy.ts, which this PR doesn't touch. The changed files alone: cleannpm run typecheck: cleannpm test: 206 files passed, 2 skipped; 3182 tests passed, 11 skippedSonarCloud:
scripts/sonar-pr.shresult posted below once the analysis runs.